if (getResolution() != 0.0) f.format(" resolution=%f", resolution); f.format("%n");
values.setAttribute("start", Double.toString(axis.getStartValue())); values.setAttribute("end", Double.toString(axis.getEndValue())); if (axis.getResolution() != 0.0) values.setAttribute("resolution", Double.toString(axis.getResolution()));
builder.setStartValue(axis.getStartValue()); builder.setEndValue(axis.getEndValue()); builder.setResolution(axis.getResolution());
@Test public void test2DTimeCoordinates() throws IOException { String filename = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km.ncx4"; String gridName = "Pressure_surface"; try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, cc); Assert.assertEquals(2, cc.getCoverageCollections().size()); CoverageCollection cd = cc.findCoverageDataset(FeatureType.FMRC); Assert.assertNotNull(FeatureType.FMRC.toString(), cd); Coverage cov = cd.findCoverage(gridName); Assert.assertNotNull(gridName, cov); CoverageCoordSys csys = cov.getCoordSys(); Assert.assertNotNull("CoverageCoordSys", csys); CoverageCoordAxis runtime = csys.getAxis(AxisType.RunTime); Assert.assertNotNull(AxisType.RunTime.toString(), runtime); Assert.assertTrue(runtime.getClass().getName(), runtime instanceof CoverageCoordAxis1D); Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, runtime.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.independent, runtime.getDependenceType()); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), runtime.makeDate(0)); Assert2.assertNearlyEquals(6.0, runtime.getResolution()); CoverageCoordAxis time = csys.getAxis(AxisType.TimeOffset); Assert.assertNotNull(AxisType.TimeOffset.toString(), time); Assert.assertTrue(time.getClass().getName(), time instanceof TimeOffsetAxis); Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, time.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.independent, time.getDependenceType()); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), time.makeDate(0)); Assert2.assertNearlyEquals(6.0, time.getResolution()); Assert.assertEquals(true, csys.isTime2D(time)); } }
@Test public void testTimeOffsetSubsetWhenTimePresent() throws IOException { String filename = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1"; String gridName = "Temperature_isobaric"; logger.debug("file {} coverage {}", filename, gridName); try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, cc); CoverageCollection cd = cc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.GRID.toString(), cd); Coverage cov = cd.findCoverage(gridName); Assert.assertNotNull(gridName, cov); CoverageCoordSys csys = cov.getCoordSys(); Assert.assertNotNull("CoverageCoordSys", csys); CoverageCoordAxis time = csys.getAxis(AxisType.Time); Assert.assertNotNull(AxisType.Time.toString(), time); Assert.assertTrue(time.getClass().getName(), time instanceof CoverageCoordAxis1D); Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, time.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.independent, time.getDependenceType()); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), time.makeDate(0)); Assert2.assertNearlyEquals(6.0, time.getResolution()); CoverageCoordAxis runtime = csys.getAxis(AxisType.RunTime); Assert.assertNotNull(AxisType.RunTime.toString(), runtime); Assert.assertTrue(runtime.getClass().getName(), runtime instanceof CoverageCoordAxis1D); Assert.assertEquals(CoverageCoordAxis.Spacing.regularPoint, runtime.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.scalar, runtime.getDependenceType()); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), runtime.makeDate(0)); } }
@Test public void testBestTimeCoordinates() throws IOException { String filename = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km.ncx4"; String gridName = "Pressure_surface"; try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, cc); Assert.assertEquals(2, cc.getCoverageCollections().size()); CoverageCollection cd = cc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.GRID.toString(), cd); Coverage cov = cd.findCoverage(gridName); Assert.assertNotNull(gridName, cov); CoverageCoordSys csys = cov.getCoordSys(); Assert.assertNotNull("CoverageCoordSys", csys); CoverageCoordAxis time = csys.getAxis(AxisType.Time); Assert.assertNotNull(AxisType.Time.toString(), time); Assert.assertTrue(time.getClass().getName(), time instanceof CoverageCoordAxis1D); Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, time.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.independent, time.getDependenceType()); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), time.makeDate(0)); Assert2.assertNearlyEquals(6.0, time.getResolution()); Assert.assertEquals(false, csys.isTime2D(time)); CoverageCoordAxis runtime = csys.getAxis(AxisType.RunTime); Assert.assertNotNull(AxisType.RunTime.toString(), runtime); Assert.assertTrue(runtime.getClass().getName(), runtime instanceof CoverageCoordAxis1D); Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, runtime.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.dependent, runtime.getDependenceType()); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), runtime.makeDate(0)); } }