@Override public List<VariableSimpleIF> getDataVariables() { List<VariableSimpleIF> result = new ArrayList<>(); for (CoverageCollection cc : covCollections) { for (Coverage cov : cc.getCoverages()) result.add(cov); } return result; }
public void toString(Formatter f) { Indent indent = new Indent(2); f.format("%sGridDatasetCoverage %s%n", indent, name); f.format("%s Global attributes:%n", indent); for (Attribute att : atts.getAttributes()) f.format("%s %s%n", indent, att); f.format("%s Date Range:%s%n", indent, calendarDateRange); f.format("%s LatLon BoundingBox:%s%n", indent, latLonBoundingBox); if (projBoundingBox != null) f.format("%s Projection BoundingBox:%s%n", indent, projBoundingBox); f.format("%n%s Coordinate Systems:%n", indent); for (CoverageCoordSys cs : coordSys) cs.toString(f, indent); f.format("%s Coordinate Transforms:%n", indent); for (CoverageTransform t : coordTransforms) t.toString(f, indent); f.format("%s Coordinate Axes:%n", indent); for (CoverageCoordAxis a : coordAxes) a.toString(f, indent); f.format("%n%s Grids:%n", indent); for (Coverage grid : getCoverages()) grid.toString(f, indent); }
private static boolean readRandom(FeatureDatasetCoverage covDataset, PrintWriter pw ) throws IOException, InvalidRangeException { CoverageCollection cc = covDataset.getCoverageCollections().get(0); int ncov = cc.getCoverageCount(); Random r = new Random(System.currentTimeMillis()); int randomIdx = r.nextInt(ncov); int count = 0; Coverage randomCov = null; for (Coverage c : cc.getCoverages()) { if (count == randomIdx) { randomCov = c; break; } count++; } if (randomCov == null) { pw.format("Bad random coverage"); return false; } SubsetParams subset = new SubsetParams().setTimePresent(); GeoReferencedArray geo = randomCov.readData(subset); Array data = geo.getData(); System.out.printf(" read data from %s shape = %s%n", randomCov.getName(), Misc.showInts(data.getShape())); return true; }
private void addCoverages(CoverageCollection subsetDataset, NetcdfFileWriter writer) { for (Coverage grid : subsetDataset.getCoverages()) { Variable v = writer.addVariable(null, grid.getName(), grid.getDataType(), grid.getIndependentAxisNamesOrdered()); addVariableAttributes(v, grid.getAttributes()); } }
private void writeCoverageData(CoverageCollection gdsOrg, SubsetParams subsetParams, CoverageCollection subsetDataset, NetcdfFileWriter writer) throws IOException, InvalidRangeException { for (Coverage coverage : subsetDataset.getCoverages()) { // we need to call readData on the original Coverage coverageOrg = gdsOrg.findCoverage(coverage.getName()); GeoReferencedArray array = coverageOrg.readData(subsetParams); // test conform to whatever axis.getCoordsAsArray() returns checkConformance(coverage, array, gdsOrg.getName()); Variable v = writer.findVariable(coverage.getName()); if (show) System.out.printf("CFGridCoverageWriter2 write coverage %s%n", v.getNameAndDimensions()); writer.write(v, array.getData()); } }
public int readCoverageDataset() throws IOException { kind = KIND_COVERAGE; int countFailures = 0; try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(filename)) { Attribute att = fdc.findGlobalAttributeIgnoreCase("file_format"); isGrib1 = att.getStringValue().equalsIgnoreCase("GRIB-1"); for (CoverageCollection cc : fdc.getCoverageCollections()) { for (Coverage cover : cc.getCoverages()) { if (readCoverage(cover)) counters.count(kind, "success"); else { counters.count(kind, "fail"); countFailures++; } } } } return countFailures; }
private void addCFAnnotations(CoverageCollection gds, NetcdfFileWriter writer, boolean shouldAddLatLon2D) { for (Coverage grid : gds.getCoverages()) { CoverageCoordSys gcs = grid.getCoordSys();
gridNames = new LinkedList<>(); for (Coverage coverage : gdsOrg.getCoverages()) { gridNames.add(coverage.getName());
CdmrFeatureProto.CoverageDataset.Builder encodeHeader(CoverageCollection gridDataset, String location) { CdmrFeatureProto.CoverageDataset.Builder builder = CdmrFeatureProto.CoverageDataset.newBuilder(); builder.setName(location); builder.setCoverageType(convertCoverageType(gridDataset.getCoverageType())); builder.setDateRange(encodeDateRange(gridDataset.getCalendarDateRange())); if (gridDataset.getLatlonBoundingBox() != null) builder.setLatlonRect(encodeRectangle(gridDataset.getLatlonBoundingBox())); if (gridDataset.getProjBoundingBox() != null) builder.setProjRect(encodeRectangle(gridDataset.getProjBoundingBox())); for (Attribute att : gridDataset.getGlobalAttributes()) builder.addAtts(NcStream.encodeAtt(att)); for (CoverageCoordSys gcs : gridDataset.getCoordSys()) builder.addCoordSys(encodeCoordSys(gcs)); for (CoverageTransform gct : gridDataset.getCoordTransforms()) builder.addCoordTransforms(encodeCoordTransform(gct)); for (CoverageCoordAxis axis : gridDataset.getCoordAxes()) builder.addCoordAxes(encodeCoordAxis(axis)); for (Coverage grid : gridDataset.getCoverages()) builder.addGrids(encodeGrid(grid)); return builder; }