public HorizCoordSys makeHorizCoordSys() { CoverageCoordAxis xaxis = getAxis(AxisType.GeoX); CoverageCoordAxis yaxis = getAxis(AxisType.GeoY); CoverageCoordAxis lataxis = getAxis(AxisType.Lat); CoverageCoordAxis lonaxis = getAxis(AxisType.Lon); CoverageTransform hct = getHorizTransform(); return HorizCoordSys.factory((CoverageCoordAxis1D) xaxis, (CoverageCoordAxis1D) yaxis, lataxis, lonaxis, hct); }
@Test public void testGaussianLats() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/cfs.wmo"; try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, cc); String gridName = "Albedo_surface_Average"; Assert.assertEquals(1, cc.getCoverageCollections().size()); CoverageCollection cd = cc.getCoverageCollections().get(0); Coverage cov = cd.findCoverage(gridName); Assert.assertNotNull(gridName, cov); CoverageCoordSys csys = cov.getCoordSys(); Assert.assertNotNull("CoverageCoordSys", csys); CoverageCoordAxis latAxis = csys.getAxis(AxisType.Lat); Assert.assertNotNull(AxisType.RunTime.toString(), latAxis); Assert.assertTrue(latAxis.getClass().getName(), latAxis instanceof CoverageCoordAxis1D); Assert.assertEquals(CoverageCoordAxis.Spacing.irregularPoint, latAxis.getSpacing()); Assert.assertEquals(CoverageCoordAxis.DependenceType.independent, latAxis.getDependenceType()); Attribute att = latAxis.findAttribute(CDM.GAUSSIAN); Assert.assertNotNull(att); Assert.assertEquals("true", att.getStringValue()); } }
@Test public void testScalarRuntimeCoordinate() throws IOException { String filename = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1.ncx4"; String gridName = "Pressure_surface"; try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) { Assert.assertNotNull(filename, cc); Assert.assertEquals(1, cc.getCoverageCollections().size()); CoverageCollection cd = cc.getCoverageCollections().get(0); Coverage cov = cd.findCoverage(gridName); Assert.assertNotNull(gridName, cov); CoverageCoordSys csys = cov.getCoordSys(); Assert.assertNotNull("CoverageCoordSys", csys); CoverageCoordAxis1D runtime = (CoverageCoordAxis1D) 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()); CalendarDate startDate = runtime.makeDate(runtime.getCoordMidpoint(0)); Assert.assertEquals(CalendarDate.parseISOformat(null, "2012-02-27T00:00:00Z"), startDate); } }
@Test public void testSrcTimePresent() throws IOException, InvalidRangeException { String endpoint = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1"; String covName = "Temperature_isobaric"; logger.debug("testSrcTimePresent Dataset {} coverage {}", endpoint, covName); try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, cc); CoverageCollection gcs = cc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull("gcs", gcs); Coverage cover = gcs.findCoverage(covName); Assert.assertNotNull(covName, cover); CoverageCoordSys cs = cover.getCoordSys(); CoverageCoordAxis timeAxis = cs.getAxis(AxisType.Time); Assert.assertNotNull("timeoffset axis", timeAxis); Assert.assertEquals(36, timeAxis.getNcoords()); SubsetParams params = new SubsetParams(); params.set(SubsetParams.timePresent, true); logger.debug(" subset {}", params); GeoReferencedArray geo = cover.readData(params); int[] resultShape = geo.getData().getShape(); int[] expectShape = new int[] {1, 29, 65, 93}; Assert.assertArrayEquals("shape", expectShape, resultShape); CoverageCoordSys geocs = geo.getCoordSysForData(); CoverageCoordAxis toAxis2 = geocs.getAxis(AxisType.Time); Assert.assertNotNull("timeoffset axis", toAxis2); Assert.assertEquals(1, toAxis2.getNcoords()); } }
@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)); } }
assertNotNull("csys", csys); CoverageCoordAxis1D time = (CoverageCoordAxis1D) csys.getAxis(AxisType.Time); assertNotNull("time", time); Assert.assertEquals(1, time.getNcoords());
@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()); } } } }
@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)); } }
public static void testGeoArray(GeoReferencedArray geo, CalendarDate runtime, CalendarDate time, Double offsetVal) { CoverageCoordSys geoCs = geo.getCoordSysForData(); CoverageCoordAxis runtimeAxis = geoCs.getAxis(AxisType.RunTime); Assert.assertNotNull(runtimeAxis); Assert.assertTrue(runtimeAxis instanceof CoverageCoordAxis1D); Assert.assertEquals("runtime coord", runtime, runtimeAxis.makeDate(runtimeAxis1D.getCoordMidpoint(0))); CoverageCoordAxis timeAxis = geoCs.getAxis(AxisType.TimeOffset); if (timeAxis == null) timeAxis = geoCs.getAxis(AxisType.Time);
CoverageCoordSys geoCs = geo.getCoordSysForData(); CoverageCoordAxis runtimeAxis = geoCs.getAxis(AxisType.RunTime); Assert.assertNotNull(runtimeAxis); Assert.assertTrue(runtimeAxis instanceof CoverageCoordAxis1D); Assert.assertEquals("runtime coord", runtime, runtimeAxis.makeDate(runtimeAxis1D.getCoordMidpoint(0))); CoverageCoordAxis1D timeAxis = (CoverageCoordAxis1D) geoCs.getAxis(AxisType.TimeOffset); Assert.assertNotNull(timeAxis); Assert.assertEquals(92, timeAxis.getNcoords());
Assert.assertNotNull(gcs); CoverageCoordAxis reftime = gcs.getAxis(AxisType.RunTime); Assert.assertNotNull(reftime); Assert.assertEquals(4, reftime.getNcoords());
CoverageCoordSys geoCs = geo.getCoordSysForData(); CoverageCoordAxis1D runtimeAxis = (CoverageCoordAxis1D) geoCs.getAxis(AxisType.RunTime); Assert.assertNotNull(runtimeAxis); Assert.assertEquals(4, runtimeAxis.getNcoords()); Assert2.assertNearlyEquals(6.0, runtimeAxis.getResolution()); CoverageCoordAxis timeAxis = geoCs.getAxis(AxisType.TimeOffset); Assert.assertNotNull(timeAxis); Assert.assertTrue(timeAxis instanceof CoverageCoordAxis1D);
Assert.assertNotNull(gcs); CoverageCoordAxis reftime = gcs.getAxis(AxisType.RunTime); Assert.assertNotNull(reftime); Assert.assertEquals(1, reftime.getNcoords());
CoverageCoordSys geoCs = geo.getCoordSysForData(); CoverageCoordAxis1D runtimeAxis = (CoverageCoordAxis1D) geoCs.getAxis(AxisType.RunTime); Assert.assertNotNull(runtimeAxis); Assert.assertEquals(3, runtimeAxis.getNcoords()); Assert2.assertNearlyEquals(6.0, runtimeAxis.getResolution()); CoverageCoordAxis timeAxis = geoCs.getAxis(AxisType.Time); if (timeAxis != null) { Assert.assertTrue(timeAxis instanceof CoverageCoordAxis1D); CoverageCoordAxis timeOffsetAxis = geoCs.getAxis(AxisType.TimeOffset); if (timeOffsetAxis != null) { Assert.assertTrue(timeOffsetAxis instanceof TimeOffsetAxis);
Assert.assertNotNull(gcs); CoverageCoordAxis reftime = gcs.getAxis(AxisType.RunTime); Assert.assertNotNull(reftime); Assert.assertEquals(4, reftime.getNcoords());
assertNotNull("csys", csys); CoverageCoordAxis1D time = (CoverageCoordAxis1D) csys.getAxis(AxisType.Time); assertNotNull("time", time); Assert.assertEquals(1, time.getNcoords());