public Object isMine(FeatureType wantFeatureType, NetcdfDataset ncd, Formatter errlog) throws IOException { // If they ask for a grid, and there seems to be some grids, go for it if (wantFeatureType == FeatureType.GRID || wantFeatureType == FeatureType.SWATH) { ucar.nc2.dt.grid.GridDataset gds = new ucar.nc2.dt.grid.GridDataset( ncd); if (gds.getGrids().size() > 0) { return gds; } } return null; }
System.out.printf(" location= %s%n%n", gridDs.getLocation()); int countGrids = gridDs.getGrids().size(); int countCoordAxes = gridDs.getNetcdfDataset().getCoordinateAxes().size(); int countCoordSys = gridDs.getNetcdfDataset().getCoordinateSystems().size();
public Object isMine(FeatureType wantFeatureType, NetcdfDataset ncd, Formatter errlog) throws IOException { // If they ask for a grid, and there seems to be some grids, go for it if (wantFeatureType == FeatureType.GRID || wantFeatureType == FeatureType.SWATH) { ucar.nc2.dt.grid.GridDataset gds = new ucar.nc2.dt.grid.GridDataset( ncd); if (gds.getGrids().size() > 0) { return gds; } } return null; }
public List<VariableSimpleIF> getDataVariables() { List<VariableSimpleIF> result = new ArrayList<>( grids.size()); for (GridDatatype grid : getGrids()) { if (grid.getVariable() != null) // LOOK could make Adaptor if no variable result.add( grid.getVariable()); } return result; }
public List<VariableSimpleIF> getDataVariables() { List<VariableSimpleIF> result = new ArrayList<>( grids.size()); for (GridDatatype grid : getGrids()) { if (grid.getVariable() != null) // LOOK could make Adaptor if no variable result.add( grid.getVariable()); } return result; }
public List<VariableSimpleIF> getDataVariables() { List<VariableSimpleIF> result = new ArrayList<VariableSimpleIF>( grids.size()); for (GridDatatype grid : getGrids()) { if (grid.getVariable() != null) // LOOK could make Adaptor if no variable result.add( grid.getVariable()); } return result; }
if (gds.getGrids().size() > 0) return gds;
public void utestReadNcMLInputStream() throws Exception { String ncmlLoc = "file:G:/work/jasmin/snpp.ncml"; GridDataset fullDataset = GridDataset.open( ncmlLoc); System.out.printf("full size= %d%n", fullDataset.getGrids().size()); // read ncml through a InputStream. String ncml = "<netcdf xmlns=\"http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2\">\n" + "<aggregation type=\"union\">\n" + " <netcdf location=\"file:G:/work/jasmin/SVM01_npp_d20120120_t0531354_e0532596_b01189_c20120120120033631216_noaa_ops.h5\" />\n" + " <netcdf location=\"file:G:/work/jasmin/GMTCO_npp_d20120120_t0531354_e0532596_b01189_c20120120115420527613_noaa_ops.h5\" />\n" + " </aggregation>\n" + "</netcdf>"; NetcdfDataset aggregatedDataset = NcMLReader.readNcML( new ByteArrayInputStream(ncml.getBytes(CDM.utf8Charset)), null ); GridDataset emptyDataset = new GridDataset( aggregatedDataset ); System.out.printf("empty= %s%n", emptyDataset.getGrids().size()); assert emptyDataset.getGrids().size() == fullDataset.getGrids().size(); }
if (gds.getGrids().size() > 0) return gds;
public void testNcmlGrid() throws IOException { String filename = "file:" + TestDir.cdmUnitTestDir + "ncml/nc/seawifs/aggDirectory.ncml"; GridDataset gds = GridDataset.open( filename); logger.debug(" TestNcmlAggExisting.openGrid {}", filename); List grids = gds.getGrids(); assert grids.size() == 2; gds.close(); }
@Test public void testTimeAxisEval() throws IOException { /** * The following tests BugFixes.evalTimeAxes, called by ucar.nc2.dt.grid.GridCoordSys.isGridCoordSys */ String testFileFullPath = TestDir.cdmUnitTestDir + "ft/grid/echoTops_runtime.nc"; GridDataset runtimeDataset = new GridDataset(new NetcdfDataset(NetcdfFile.open(testFileFullPath))); if (runtimeDataset.getGrids().isEmpty()) { throw new RuntimeException("Runtime data file did not generate a dataset with grids"); } if (runtimeDataset.getGrids().get(0).getCoordinateSystem().getRunTimeAxis() == null) { throw new RuntimeException("Runtime data file did not generate a dataset with a RunTime axis"); } System.out.println("BugFixesTest - completed."); }
public static Count read(String filename) { long start = System.currentTimeMillis(); System.out.println("\n\nReading File " + filename); Count allCount = new Count(); try (GridDataset gds = GridDataset.open(filename)) { for (GridDatatype gdt : gds.getGrids()) { Count count = read(gdt); System.out.printf("%80s == %d/%d%n", gdt.getFullName(), count.nmiss, count.nread); allCount.add(count); } long took = System.currentTimeMillis() - start; float r = ((float) took) / allCount.nread; System.out.printf("%n%80s == %d/%d%n", "total", allCount.nmiss, allCount.nread); System.out.printf("%n that took %d secs total, %f msecs per record%n", took / 1000, r); } catch (IOException ioe) { ioe.printStackTrace(); Formatter out = new Formatter(System.out); GribCdmIndex.gribCollectionCache.showCache(out); } return allCount; }
public void openDatasetAndView(String url) throws IOException { Array temp_data; try (GridDataset dataset = GridDataset.open(url)) { for (GridDatatype grid : dataset.getGrids()) { temp_data = grid.readDataSlice(0, 0, -1, -1); assert grid.getMinMaxSkipMissingData(temp_data).min == 0.0; // min assert grid.getMinMaxSkipMissingData(temp_data).max == 42.0; // max } } }
@Test @Ignore("Does this file exist in a shared location?") public void testAaron() throws Exception{ // different scale/offset in aggregation try (GridDataset dataset = GridDataset.open("G:/work/braekel/dataset.ncml" )) { GridDatatype grid = null; for (GridDatatype thisGrid : dataset.getGrids()) { if (thisGrid.getName().equals("cref")) { grid = thisGrid; } } List<Range> ranges = new ArrayList<Range>(); ranges.add(new Range(0, 0)); ranges.add(new Range(0, 0)); ranges.add(new Range(638, 638)); ranges.add(new Range(3750, 4622)); Array arr = grid.getVariable().read(ranges); Index index = arr.getIndex(); index.set(new int[]{0, 0, 0, 834}); logger.debug("index {} value {}", index.currentElement(), arr.getDouble(index)); } }
for (GridDatatype gg : gds.getGrids()) { GridCoordSystem gcs = gg.getCoordinateSystem(); Grid grid = new Grid(gg.getFullName());
for (GridDatatype gg : gds.getGrids()) { GridCoordSystem gcs = gg.getCoordinateSystem(); Grid grid = new Grid(gg.getFullName());
public int readGridDataset() throws IOException { kind = KIND_GRID; int countFailures = 0; try (GridDataset gds = GridDataset.open(filename)) { NetcdfFile ncfile = gds.getNetcdfFile(); IOServiceProvider iosp = ncfile.getIosp(); isGrib1 = iosp instanceof Grib1Iosp; for (GridDatatype gdt : gds.getGrids()) { if (read(gdt)) counters.count(kind, "success"); else { counters.count(kind, "fail"); countFailures++; } } } return countFailures; }
@Ignore("takes too long") @Test public void testGridCoverageDataset() throws IOException { System.out.printf("Test Dataset %s%n", endpoint); try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, cc); CoverageCollection gcs = cc.findCoverageDataset(expectType); Assert.assertNotNull(expectType.toString(), gcs); // check DtCoverageCS try (GridDataset ds = GridDataset.open(endpoint)) { for (GridDatatype dt : ds.getGrids()) { if (expectType == FeatureType.FMRC && !dt.getFullName().startsWith("TwoD")) continue; if (expectType == FeatureType.GRID && dt.getFullName().startsWith("TwoD")) continue; GridCoordSystem csys = dt.getCoordinateSystem(); CoordinateAxis1DTime rtAxis = csys.getRunTimeAxis(); CoordinateAxis1D ensAxis = csys.getEnsembleAxis(); CoordinateAxis1D vertAxis = csys.getVerticalAxis(); Coverage cover = gcs.findCoverage(dt.getShortName()); if (cover == null) { System.out.printf("Cant find %s%n", dt.getFullName()); continue; } System.out.printf(" Grid %s%n", dt.getFullName()); readAllRuntimes(cover, dt, rtAxis, ensAxis, vertAxis); } } } }