@Override public NetcdfFile getNetcdfFile() { FeatureDatasetPoint proto; TimedCollection.Dataset td = datasets.getPrototype(); if (td == null) return null; String loc = td.getLocation(); Formatter errlog = new Formatter(); try { proto = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(FeatureType.ANY_POINT, loc, null, errlog); // LOOK kludge return proto.getNetcdfFile(); } catch (IOException e) { log.error(errlog.toString()); e.printStackTrace(); } return null; }
ucar.nc2.NetcdfFile ncfile = pfDataset.getNetcdfFile(); if ((ncfile == null) || !(ncfile instanceof NetcdfDataset)) { dataVars.addAll(pfDataset.getDataVariables());
ucar.nc2.NetcdfFile ncfile = pfDataset.getNetcdfFile(); if ((ncfile == null) || !(ncfile instanceof NetcdfDataset)) { dataVars.addAll(pfDataset.getDataVariables());
ucar.nc2.NetcdfFile ncfile = pfDataset.getNetcdfFile(); if ((ncfile == null) || !(ncfile instanceof NetcdfDataset)) { dataVars.addAll(pfDataset.getDataVariables());
@Test // the z coordinate doesnt fit into the structures, but must be transferred to the rewritten dataset public void testPointZCoord() throws Exception { String file = TestDir.cdmLocalTestDataDir + "point/pointUnlimited.nc"; Formatter buf = new Formatter(); try (FeatureDatasetPoint fdpoint = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(ucar.nc2.constants.FeatureType.POINT, file, null, buf)) { Assert.assertNotNull(fdpoint); List<DsgFeatureCollection> collectionList = fdpoint.getPointFeatureCollectionList(); assert (collectionList.size() == 1) : "Can't handle point data with multiple collections"; DsgFeatureCollection fc = collectionList.get(0); assert fc instanceof PointFeatureCollection; NetcdfFile ncfile = fdpoint.getNetcdfFile(); Assert.assertNotNull(ncfile); Assert.assertNotNull("cant find variable 'z' in netcdf file", ncfile.findVariable("z")); FeatureDatasetPoint rewrite = rewriteDataset(fdpoint, "nc3", new CFPointWriterConfig(NetcdfFileWriter.Version.netcdf3)); collectionList = rewrite.getPointFeatureCollectionList(); fc = collectionList.get(0); assert fc instanceof PointFeatureCollection; ncfile = rewrite.getNetcdfFile(); Assert.assertNotNull(ncfile); Assert.assertNotNull("cant find variable 'z' in rewritten netcdf file", ncfile.findVariable("z")); rewrite.close(); } }
@Test // the z coordinate doesnt fit into the structures, but must be transferred to the rewritten dataset public void testStationMultidimZCoord() throws Exception { String file = TestDir.cdmLocalTestDataDir + "point/stationMultidim.ncml"; Formatter buf = new Formatter(); try (FeatureDatasetPoint fdpoint = (FeatureDatasetPoint) FeatureDatasetFactoryManager.open(FeatureType.STATION, file, null, buf)) { Assert.assertNotNull(fdpoint); List<DsgFeatureCollection> collectionList = fdpoint.getPointFeatureCollectionList(); assert (collectionList.size() == 1) : "Can't handle point data with multiple collections"; DsgFeatureCollection fc = collectionList.get(0); assert fc instanceof StationTimeSeriesFeatureCollection; NetcdfFile ncfile = fdpoint.getNetcdfFile(); Assert.assertNotNull(ncfile); Assert.assertNotNull("cant find variable 'z' in netcdf file", ncfile.findVariable("z")); FeatureDatasetPoint rewrite = rewriteDataset(fdpoint, "nc3", new CFPointWriterConfig(NetcdfFileWriter.Version.netcdf3)); collectionList = rewrite.getPointFeatureCollectionList(); fc = collectionList.get(0); assert fc instanceof StationTimeSeriesFeatureCollection; ncfile = rewrite.getNetcdfFile(); Assert.assertNotNull(ncfile); Assert.assertNotNull("cant find variable 'z' in rewritten netcdf file", ncfile.findVariable("z")); Variable data = ncfile.findVariable("data"); Assert.assertNotNull("cant find variable 'data' in rewritten netcdf file", data); Assert.assertEquals(2, data.getRank()); Assert.assertEquals("obs", data.getDimension(0).getShortName()); Assert.assertEquals("z", data.getDimension(1).getShortName()); rewrite.close(); } }