@Override public int getRank() { return getShape().length; }
@Test public void testNcml() throws IOException, InvalidRangeException { String catalog = "/catalog/hioos/model/wav/swan/oahu/catalog.xml"; Catalog cat = TdsLocalCatalog.open(catalog); String id = "hioos/model/wav/swan/oahu/SWAN_Oahu_Regional_Wave_Model_(500m)_best.ncd"; Dataset ds = cat.findDatasetByID(id); assert (ds != null) : "cant find dataset id="+id; assert ds.getFeatureType() == FeatureType.GRID; DataFactory fac = new DataFactory(); try (DataFactory.Result dataResult = fac.openFeatureDataset( ds, null)) { assert !dataResult.fatalError; assert dataResult.featureDataset != null; FeatureDatasetCoverage gds = (FeatureDatasetCoverage) dataResult.featureDataset; String gridName = "salt"; VariableSimpleIF vs = gds.getDataVariable(gridName); Assert.assertNotNull(gridName, vs); Assert.assertEquals(1, gds.getCoverageCollections().size()); CoverageCollection cc = gds.getCoverageCollections().get(0); Coverage grid = cc.findCoverage(gridName); Assert.assertNotNull(gridName, grid); CoverageCoordSys gcs = grid.getCoordSys(); Assert.assertNotNull(gcs); int[] expectShape = new int[] {65, 30, 194, 294}; Assert.assertArrayEquals(expectShape, grid.getShape()); Attribute att = grid.findAttributeIgnoreCase("_FillValue"); assert att != null; assert att.getDataType() == DataType.FLOAT; assert Float.isNaN((Float) att.getNumericValue()); } }
Assert.assertNotNull(covName, cover); int[] shape = cover.getShape(); logger.debug("{}", Misc.showInts(shape)); Assert.assertArrayEquals(new int[]{1631, 1465}, shape);
Assert.assertArrayEquals(expectShape, cov.getShape());
Coverage grid = cc.findCoverage(gridName); Assert.assertNotNull(gridName, grid); Assert.assertArrayEquals(new int[]{8, 103, 108}, grid.getShape());
Assert.assertArrayEquals(expectShape, grid.getShape());
Assert.assertArrayEquals(expectShape, grid.getShape());
assert cn.compareData("time", time.getCoordsAsArray(), Array.makeFromJavaArray(want), false); Assert.assertArrayEquals(new int[]{4, 2, 103, 108}, grid.getShape());
Assert.assertArrayEquals(expectShape, grid.getShape());