@Override protected void setDataset(CoordSysContainer dataset) { if (shape != null) throw new RuntimeException("Cant change axis, once dataset is set"); shape = new int[2]; assert dependsOn.size() == 2; CoverageCoordAxis axis1 = dataset.findCoordAxis(dependsOn.get(0)); if (axis1 == null) throw new IllegalStateException("TimeAxis2DSwath cant find axis with name "+dependsOn.get(0)); CoverageCoordAxis axis2 = dataset.findCoordAxis(dependsOn.get(1)); if (axis2 == null) throw new IllegalStateException("TimeAxis2DSwath cant find axis with name "+dependsOn.get(1)); shape[0] = axis1.getNcoords(); shape[1] = axis2.getNcoords(); assert shape[0] * shape[1] == this.getNcoords(); }
@Override protected void setDataset(CoordSysContainer dataset) { if (this.shape != null) return; // set in constructor List<CoverageCoordAxis> dependentAxes = new ArrayList<>(); int[] shape = new int[2]; int count = 0; for (String axisName : dependsOn) { CoverageCoordAxis axis = dataset.findCoordAxis(axisName); if (axis == null) { if (this.shape == null) // ok is hape has already been set throw new IllegalStateException("LatLonAxis2D cant find axis " + axisName); } else { shape[count] = axis.getNcoords(); dependentAxes.add(axis); } } this.shape = shape; }
@Override protected void setDataset(CoordSysContainer dataset) { if (shape != null) throw new RuntimeException("Cant change axis once set"); shape = new int[2]; String runtimeName = dependsOn.get(0); CoverageCoordAxis runtime = dataset.findCoordAxis(runtimeName); if (runtime == null) throw new IllegalStateException("FmrcTimeAxis2D cant find runtime axis with name "+runtimeName); assert runtime instanceof CoverageCoordAxis1D; assert runtime.getAxisType() == AxisType.RunTime; runCoord = (CoverageCoordAxis1D) runtime; shape[0] = runtime.getNcoords(); shape[1] = ncoords / shape[0]; }
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 List<CoverageCoordAxis> makeTime2DCoordinates(CoordinateTime2D time2D) { trackDateRange(time2D.makeCalendarDateRange(null)); // default calendar List<CoverageCoordAxis> result = new ArrayList<>(); CoverageCoordAxis covTime; if (ds.getType() == GribCollectionImmutable.Type.SRC) { covTime = makeUniqueTimeAxis(time2D); CoordinateRuntime rt = time2D.getRuntimeCoordinate(); //if (!alreadyHave(result, rt.getName())) result.add(makeRuntimeCoord(rt)); } else if (ds.getType().isUniqueTime()) { covTime = makeUniqueTimeAxis(time2D); result.add(makeRuntimeAuxCoord(time2D, covTime.getNcoords())); } else if (time2D.isOrthogonal()) { covTime = makeTimeOffsetAxis(time2D); CoordinateRuntime rt = time2D.getRuntimeCoordinate(); //if (!alreadyHave(result, rt.getName())) result.add(makeRuntimeCoord(rt)); } else if (time2D.isRegular()) { covTime = makeFmrcRegTimeAxis(time2D); CoordinateRuntime rt = time2D.getRuntimeCoordinate(); //if (!alreadyHave(result, rt.getName())) result.add(makeRuntimeCoord(rt)); // LOOK ? } else throw new IllegalStateException("Time2D with type= " + ds.getType()); result.add(covTime); return result; }
if (isTime2D(axis)) continue; if (axis.getDependenceType() == CoverageCoordAxis.DependenceType.independent) result[count++] = axis.getNcoords();
Assert.assertEquals(csys.getXAxis().getNcoords(), csyss.getXAxis().getNcoords()); Assert.assertEquals(csys.getYAxis().getNcoords(), csyss.getYAxis().getNcoords());
builder.setDataType(NcStream.convertDataType(axis.getDataType())); builder.setAxisType(convertAxisType(axis.getAxisType())); builder.setNvalues(axis.getNcoords()); if (axis.getUnits() != null) builder.setUnits(axis.getUnits()); if (axis.getDescription() != null) builder.setDescription(axis.getDescription()); builder.setResolution(axis.getResolution()); if (!axis.isRegular() && axis.getNcoords() < MAX_INLINE_NVALUES) { double[] values = axis.getValues(); ByteBuffer bb = ByteBuffer.allocate(8 * values.length);
Assert.assertEquals(csys.getXAxis().getNcoords(), csyss.getXAxis().getNcoords()); Assert.assertEquals(csys.getYAxis().getNcoords(), csyss.getYAxis().getNcoords());
@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()); } } } }
Assert.assertEquals(csys.getXAxis().getNcoords(), csyss.getXAxis().getNcoords()); Assert.assertEquals(csys.getYAxis().getNcoords(), csyss.getYAxis().getNcoords());
@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()); } }
Assert.assertEquals(4, reftime.getNcoords()); double[] want = new double[]{0., 12., 24., 36.}; CompareNetcdf2 cn = new CompareNetcdf2(); Assert.assertNotNull(time); Assert.assertTrue(time instanceof TimeAxis2DFmrc); Assert.assertEquals(16, 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()); } } } }
Assert.assertEquals(12, time.getNcoords());
Assert.assertEquals(1, reftime.getNcoords()); double[] runtimeValues = new double[]{0.}; CompareNetcdf2 cn = new CompareNetcdf2(); Assert.assertEquals(4, time.getNcoords()); double[] timeValues = new double[]{102.,126.,150,174}; // midpoints assert cn.compareData("time", time.getCoordsAsArray(), Array.makeFromJavaArray(timeValues), false);
Assert.assertEquals(4, reftime.getNcoords()); double[] want = new double[]{0., 12., 24., 36.}; CompareNetcdf2 cn = new CompareNetcdf2(); Assert.assertNotNull(time); Assert.assertTrue(time instanceof TimeAxis2DFmrc); Assert.assertEquals(16, time.getNcoords());
Assert.assertNotNull(time); Assert.assertNotNull("time axis", time); Assert.assertEquals(8, time.getNcoords()); double[] want = new double[]{3.0, 6.0, 9.0, 12.0, 15.0, 18.0, 21.0, 24.0}; CompareNetcdf2 cn = new CompareNetcdf2();
Assert.assertNotNull(runtimeAxis); Assert.assertTrue(runtimeAxis instanceof CoverageCoordAxis1D); Assert.assertEquals(1, runtimeAxis.getNcoords()); CoverageCoordAxis1D runtimeAxis1D = (CoverageCoordAxis1D) runtimeAxis; if (runtime != null) Assert.assertEquals(1, timeAxis.getNcoords()); CoverageCoordAxis1D timeAxis1D = (CoverageCoordAxis1D) timeAxis; if (offsetVal != null)
Assert.assertNotNull(runtimeAxis); Assert.assertTrue(runtimeAxis instanceof CoverageCoordAxis1D); Assert.assertEquals(1, runtimeAxis.getNcoords()); CoverageCoordAxis1D runtimeAxis1D = (CoverageCoordAxis1D) runtimeAxis; Assert.assertEquals("runtime coord", runtime, runtimeAxis.makeDate(runtimeAxis1D.getCoordMidpoint(0)));