private void addDimensions(CoverageCollection subsetDataset, NetcdfFileWriter writer) { // each independent coordinate is a dimension Map<String, Dimension> dimHash = new HashMap<>(); for (CoverageCoordAxis axis : subsetDataset.getCoordAxes()) { if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent) { Dimension d = writer.addDimension(null, axis.getName(), axis.getNcoords()); dimHash.put(axis.getName(), d); } if (axis.isInterval()) { if (null == dimHash.get(BOUNDS_DIM)) { Dimension d = writer.addDimension(null, BOUNDS_DIM, 2); dimHash.put(BOUNDS_DIM, d); } } } }
private void writeCoordinateData(CoverageCollection subsetDataset, NetcdfFileWriter writer) throws IOException, InvalidRangeException { for (CoverageCoordAxis axis : subsetDataset.getCoordAxes()) { Variable v = writer.findVariable(axis.getName()); if (v != null) { if (show) System.out.printf("CFGridCoverageWriter2 write axis %s%n", v.getNameAndDimensions()); writer.write(v, axis.getCoordsAsArray()); } else { logger.error("CFGridCoverageWriter2 No variable for %s%n", axis.getName()); } if (axis.isInterval()) { Variable vb = writer.findVariable(axis.getName() + BOUNDS); writer.write(vb, axis.getCoordBoundsAsArray()); } } }
@Test public void testGridCoverageDatasetRdavm() throws IOException, InvalidRangeException { if (showDetails) System.out.printf("%s%n", filename); try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, fdc); for (CoverageCollection cc : fdc.getCoverageCollections()) { System.out.printf(" %s type=%s%n", cc.getName(), cc.getCoverageType()); //for (CoverageCoordSys coordSys : cc.getCoordSys()) { //Assert.assertTrue( coordSys.isTime2D(coordSys.getAxis(AxisType.RunTime))); //Assert.assertTrue( coordSys.isTime2D(coordSys.getTimeAxis())); //} if (showDetails) for (CoverageCoordAxis axis : cc.getCoordAxes()) { if (axis.getAxisType().isTime()) System.out.printf(" %12s %10s %5d %10s %s%n", axis.getName(), axis.getAxisType(), axis.getNcoords(), axis.getDependenceType(), axis.getSpacing()); } } } }
for (CoverageCoordAxis axis : gds.getCoordAxes()) { Variable newV = writer.findVariable(axis.getName()); if (newV == null) {
@Ignore("files not present") @Test public void testGridCoverageDatasetFmrc() throws IOException, InvalidRangeException { System.out.printf("%s%n", filename); try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, fdc); CoverageCollection cc = fdc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.GRID.toString(), cc); System.out.printf(" %s type=%s%n", cc.getName(), cc.getCoverageType()); for (CoverageCoordSys coordSys : cc.getCoordSys()) { Assert.assertTrue( coordSys.isTime2D(coordSys.getAxis(AxisType.RunTime))); Assert.assertTrue( coordSys.isTime2D(coordSys.getTimeAxis())); } for (CoverageCoordAxis axis : cc.getCoordAxes()) { if (axis.getAxisType().isTime()) System.out.printf(" %12s %10s %5d %10s %s%n", axis.getName(), axis.getAxisType(), axis.getNcoords(), axis.getDependenceType(), axis.getSpacing()); } } } }
private void addCoordinateAxes(CoverageCollection subsetDataset, NetcdfFileWriter writer) { for (CoverageCoordAxis axis : subsetDataset.getCoordAxes()) { String dims; if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent) { dims = axis.getName(); } else if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.scalar) { dims = ""; } else { dims = axis.getDependsOn(); } boolean hasBounds = false; if (axis.isInterval()) { Variable vb = writer.addVariable(null, axis.getName()+BOUNDS, axis.getDataType(), dims+" "+BOUNDS_DIM); vb.addAttribute(new Attribute(CDM.UNITS, axis.getUnits())); hasBounds = true; } Variable v = writer.addVariable(null, axis.getName(), axis.getDataType(), dims); addVariableAttributes(v, axis.getAttributes()); v.addAttribute(new Attribute(CDM.UNITS, axis.getUnits())); // override what was in att list if (hasBounds) v.addAttribute(new Attribute(CF.BOUNDS, axis.getName()+BOUNDS)); if (axis.getAxisType() == AxisType.TimeOffset) v.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME_OFFSET)); } }
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; }
for (CoverageCoordAxis axis : gcd.getCoordAxes()) { rootElem.addContent(writeAxis(axis));