private IEnumerable <IPs[]> PrepareIPsForCells(string variableName, IEnumerable <ICellRequest> t) { bool is2D = dataSetInfo.GetTimeDim(variableName) == -1; if (is2D) { foreach (var item in t) { IPs[] ipsArray = new IPs[2]; IPs lat = latAxisIntegrator.GetIPsForCell(item.LatMin, item.LatMax); IPs lon = lonAxisIntegrator.GetIPsForCell(item.LonMin, item.LonMax); ipsArray[dataSetInfo.GetLatitudeDim(variableName)] = lat; ipsArray[dataSetInfo.GetLongitudeDim(variableName)] = lon; yield return(ipsArray); } } else { foreach (var item in t) { IPs[] ipsArray = new IPs[3]; IPs time = timeAxisIntegrator.GetTempIPs(item.Time); IPs lat = latAxisIntegrator.GetIPsForCell(item.LatMin, item.LatMax); IPs lon = lonAxisIntegrator.GetIPsForCell(item.LonMin, item.LonMax); ipsArray[dataSetInfo.GetTimeDim(variableName)] = time; ipsArray[dataSetInfo.GetLatitudeDim(variableName)] = lat; ipsArray[dataSetInfo.GetLongitudeDim(variableName)] = lon; yield return(ipsArray); } } }
private IEnumerable <int[][]> PrepareIndicesForCells(string variableName, IEnumerable <ICellRequest> t) { bool is2D = dataSetInfo.GetTimeDim(variableName) == -1; if (is2D) { foreach (var item in t) { int[][] idxArray = new int[2][]; int[] latIndices = latAxisDataMaskProvider.GetDataIndices(item.LatMin, item.LatMax); int[] lonIndices = lonAxisDataMaskProvider.GetDataIndices(item.LonMin, item.LonMax); idxArray[dataSetInfo.GetLatitudeDim(variableName)] = latIndices; idxArray[dataSetInfo.GetLongitudeDim(variableName)] = lonIndices; yield return(idxArray); } } else { foreach (var item in t) { int[][] idxArray = new int[3][]; int[] time = timeAxisDataMaskProvider.GetDataIndices(item.Time); int[] lat = latAxisDataMaskProvider.GetDataIndices(item.LatMin, item.LatMax); int[] lon = lonAxisDataMaskProvider.GetDataIndices(item.LonMin, item.LonMax); idxArray[dataSetInfo.GetTimeDim(variableName)] = time; idxArray[dataSetInfo.GetLatitudeDim(variableName)] = lat; idxArray[dataSetInfo.GetLongitudeDim(variableName)] = lon; yield return(idxArray); } } }
private DataDomain ConstructDataDomain(string variable, IGridDataSetMetaData dataSetInfo, IndexBoundingBox lonBB, IndexBoundingBox latBB, IndexBoundingBox timeBB) { int[] origin = null, shape = null; int varaibleRank = dataSetInfo.GetVariableRank(variable); if (varaibleRank > 3) { throw new InvalidOperationException("Variables with rank >3 are not supported"); } origin = new int[varaibleRank]; shape = new int[varaibleRank]; int latDimNum = dataSetInfo.GetLatitudeDim(variable); int lonDimNum = dataSetInfo.GetLongitudeDim(variable); int timeDimNum = dataSetInfo.GetTimeDim(variable); origin[latDimNum] = latBB.first; shape[latDimNum] = latBB.last - latBB.first + 1; if (latDimNum != lonDimNum) { origin[lonDimNum] = lonBB.first; shape[lonDimNum] = lonBB.last - lonBB.first + 1; } if (timeDimNum != -1) { origin[timeDimNum] = timeBB.first; shape[timeDimNum] = timeBB.last - timeBB.first + 1; } return(new DataDomain() { Origin = origin, Shape = shape }); }