TimeseriesIterator() { varIters = new ArrayList<>(); for (VarData vd : varData) { Array data = vd.array.getData(); if (debug) System.out.printf("%s shape=%s%n", vd.cov.getName(), Misc.showInts(data.getShape())); varIters.add(new VarIter(vd.cov, vd.array, data.getIndexIterator())); nvalues = (int) data.getSize(); if (timeAxis == null) { // assume they are all the same (!) CoverageCoordSys csys = vd.array.getCoordSysForData(); timeAxis = (CoverageCoordAxis1D) csys.getTimeAxis(); // LOOK may not be right } } }
private void checkConformance(Coverage gridSubset, GeoReferencedArray geo, String where) { CoverageCoordSys csys = gridSubset.getCoordSys(); CoverageCoordSys csysData = geo.getCoordSysForData(); //System.out.printf(" csys=%s%n", csys); //System.out.printf("csysData=%s%n", csysData); Section s = new Section(csys.getShape()); Section so = new Section(csysData.getShape()); boolean ok = s.conformal(so); int[] dataShape = geo.getData().getShape(); //System.out.printf("dataShape=%s%n", Misc.showInts(dataShape)); Section sdata = new Section(dataShape); boolean ok2 = s.conformal(sdata); if (!ok || !ok2) logger.warn("CFGridCoverageWriter2 checkConformance fails " +where); } }
private void checkLatLonSubset(CoverageCollection gcs, Coverage coverage, LatLonRect bbox, int[] expectedShape) throws Exception { System.out.printf(" coverage llbb = %s width=%f%n", gcs.getLatlonBoundingBox().toString2(), gcs.getLatlonBoundingBox().getWidth()); System.out.printf(" constrain bbox= %s width=%f%n", bbox.toString2(), bbox.getWidth()); SubsetParams params = new SubsetParams().setLatLonBoundingBox(bbox).setTimePresent(); GeoReferencedArray geo = coverage.readData(params); CoverageCoordSys gcs2 = geo.getCoordSysForData(); Assert.assertNotNull("CoordSysForData", gcs2); System.out.printf(" data cs shape=%s%n", Misc.showInts(gcs2.getShape())); System.out.printf(" data shape=%s%n", Misc.showInts(geo.getData().getShape())); Assert.assertArrayEquals("CoordSys=Data shape", gcs2.getShape(), geo.getData().getShape()); Assert.assertArrayEquals("expected data shape", expectedShape, geo.getData().getShape()); }
CoverageCoordSys gcs = array.getCoordSysForData(); if (!gcs.isRegularSpatial()) throw new IllegalArgumentException("Must have 1D x and y axes for " + array.getCoverageName());
public CdmrFeatureProto.GeoReferencedArray.Builder encodeGeoReferencedArray(GeoReferencedArray geoArray, boolean deflate) { CdmrFeatureProto.GeoReferencedArray.Builder builder = CdmrFeatureProto.GeoReferencedArray.newBuilder(); builder.setCoverageName(geoArray.getCoverageName()); builder.setDataType(NcStream.convertDataType(geoArray.getDataType())); builder.setVersion(3); // set to >= 3 for proto3 builder.setBigend(ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN); int shape[] = geoArray.getData().getShape(); for (int aShape : shape) builder.addShape(aShape); CoverageCoordSys csys = geoArray.getCoordSysForData(); for (String axisName : csys.getAxisNames()) // geoArray.getAxisNames()) // LOOK could use csys.getAxisNames(), but order may be incorrect, must match shape builder.addAxisName(axisName); builder.setCoordSysName(csys.getName()); if (deflate) { builder.setCompress(NcStreamProto.Compress.DEFLATE); long uncompressedSize = geoArray.getData().getSizeBytes(); builder.setUncompressedSize(uncompressedSize); } else { builder.setPrimdata(NcStreamDataCol.copyArrayToByteString( geoArray.getData())); } return builder; }
@Test @Category(NeedsExternalResource.class) public void testCdmRemoteCoverage() throws Exception { String ds = "http://thredds-test.unidata.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_0p25deg_ana/latest.xml"; try (DataFactory.Result result = new DataFactory().openFeatureDataset("thredds:resolve:" + ds, null)) { logger.debug("result errlog = {}", result.errLog); assert !result.fatalError; assert result.featureType == FeatureType.GRID; assert result.featureDataset != null; String gridName = "Temperature_isobaric"; FeatureDatasetCoverage dataset = (FeatureDatasetCoverage) result.featureDataset; Assert.assertNotNull(gridName, dataset.getDataVariable(gridName)); Assert.assertEquals(1, dataset.getCoverageCollections().size()); CoverageCollection cc = dataset.getCoverageCollections().get(0); Coverage grid = cc.findCoverage(gridName); Assert.assertNotNull(gridName, grid); CoverageCoordSys gcs = grid.getCoordSys(); Assert.assertNotNull("CoverageCoordSys", gcs); Assert.assertEquals("CoverageCoordSys rank", 5, gcs.getAxes().size()); SubsetParams params = new SubsetParams().set(SubsetParams.timePresent, true).setHorizStride(3); GeoReferencedArray geo = grid.readData(params); CoverageCoordSys geoCoordsys = geo.getCoordSysForData(); Assert.assertNotNull("geoCoordsys", geoCoordsys); int[] shape = geoCoordsys.getShape(); logger.debug("grid_section.getShape = {}", new Section(shape)); int[] expectShape = new int[] {1, 31, 241, 480}; Assert.assertArrayEquals("subset shape", expectShape, shape); } }
@Test public void TestGribCurvilinearSubset() throws IOException, InvalidRangeException { String endpoint = TestDir.cdmUnitTestDir + "ft/fmrc/rtofs/ofs.20091122/ofs_atl.t00z.F024.grb.grib2"; // GRIB Curvilinear logger.debug("open {}", endpoint); try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(endpoint)) { assert cc != null; Assert.assertEquals(1, cc.getCoverageCollections().size()); CoverageCollection gds = cc.getCoverageCollections().get(0); Assert.assertNotNull(endpoint, gds); Assert.assertEquals(FeatureType.CURVILINEAR, gds.getCoverageType()); Assert.assertEquals(7, gds.getCoverageCount()); HorizCoordSys hcs = gds.getHorizCoordSys(); Assert.assertNotNull(endpoint, hcs); Assert.assertTrue(endpoint, !hcs.isProjection()); Assert.assertNull(endpoint, hcs.getTransform()); String covName = "Mixed_layer_depth_surface"; Coverage coverage = gds.findCoverage(covName); Assert.assertNotNull(covName, coverage); LatLonRect bbox = new LatLonRect(new LatLonPointImpl(64.0, -61.), new LatLonPointImpl(59.0, -52.)); SubsetParams params = new SubsetParams().set(SubsetParams.timePresent, true).set(SubsetParams.latlonBB, bbox); GeoReferencedArray geo = coverage.readData(params); logger.debug("csys shape={}", Misc.showInts(geo.getCoordSysForData().getShape())); Array data = geo.getData(); logger.debug("data shape={}", Misc.showInts(data.getShape())); Assert.assertArrayEquals(geo.getCoordSysForData().getShape(), data.getShape()); int[] expectedShape = new int[] {1, 165, 161}; Assert.assertArrayEquals(expectedShape, data.getShape()); } }
logger.debug("geoCs shape={}", Misc.showInts(geo.getCoordSysForData().getShape())); Assert.assertArrayEquals(geo.getCoordSysForData().getShape(), data.getShape());
System.out.printf("CoordSysForData shape=%s%n", Misc.showInts(geo.getCoordSysForData().getShape()));
logger.debug("geoCs shape={}", Misc.showInts(geo.getCoordSysForData().getShape())); Assert.assertArrayEquals(geo.getCoordSysForData().getShape(), data.getShape());
@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()); } }
CoverageCoordSys geoCs = geo.getCoordSysForData();
CoverageCoordSys geoCs = geo.getCoordSysForData();
CoverageCoordSys geoCs = geoArray.getCoordSysForData(); logger.debug("{}\n", geoArray); logger.debug("geoArray shape={}", Misc.showInts(geoArray.getData().getShape()));
CoverageCoordSys geoCs = geoArray.getCoordSysForData(); logger.debug("{}", geoArray); logger.debug("geoArray shape={}", Misc.showInts(geoArray.getData().getShape()));
CoverageCoordSys geoCs = geo.getCoordSysForData();
public static void testGeoArray(GeoReferencedArray geo, CalendarDate runtime, CalendarDate time, Double offsetVal) { CoverageCoordSys geoCs = geo.getCoordSysForData();