@Override public Optional<CoverageCoordAxis> subset(SubsetParams params) { Optional<CoverageCoordAxisBuilder> buildero = subsetBuilder(params); return !buildero.isPresent() ? Optional.empty(buildero.getErrorMessage()) : Optional.of(new TimeOffsetAxis(buildero.get())); }
public static<T> Optional<T> empty(String errMessage) { return new Optional<>(null, errMessage); }
/** * * @param endpoint cdmrFeature:url, local GRIB data or index file, or NetcdfDataset location * @return FeatureDatasetCoverage or null on failure. use openCoverageDataset to get error message * @throws IOException */ static public FeatureDatasetCoverage open(String endpoint) throws IOException { Optional<FeatureDatasetCoverage> opt = openCoverageDataset(endpoint); return opt.isPresent() ? opt.get() : null; }
@Override public List<Dataset> getDatasetsLogical() { try { ucar.nc2.util.Optional<DatasetNode> opt = readCatref(); if (!opt.isPresent()) throw new RuntimeException(opt.getErrorMessage()); DatasetNode proxy = opt.get(); return proxy.getDatasets(); } catch (IOException e) { throw new RuntimeException(e); } }
static public Optional<FeatureDatasetCoverage> openNcmlString(String ncml) throws IOException, FileNotFoundException { NetcdfDataset ncd = NcMLReader.readNcML(new StringReader(ncml), null); DtCoverageDataset gds = new DtCoverageDataset(ncd); if (gds.getGrids().size() > 0) { Formatter errlog = new Formatter(); FeatureDatasetCoverage cc = DtCoverageAdapter.factory(gds, errlog); return ucar.nc2.util.Optional.of(cc); } return Optional.empty("Could not open NcML as Coverage"); }
if (!estimatedSizeo.isPresent()) throw new InvalidRangeException("Request contains no data: " + estimatedSizeo.getErrorMessage());
@Override public Optional<CoverageCoordAxis> subset(double minValue, double maxValue, int stride) { // LOOK not implemented, maybe illegal ?? return Optional.of(new TimeAxis2DSwath(new CoverageCoordAxisBuilder(this))); }
private Optional<CoverageCoordAxisBuilder> subsetValuesDiscontinuous(double minValue, double maxValue, int stride) { return Optional.empty("subsetValuesDiscontinuous not done yet"); // LOOK }
if (opt.isPresent()) return opt.get(); errlog.format("%s", opt.getErrorMessage()); return null; if (opt.isPresent()) { // its a GRIB file return opt.get(); } else if (!opt.getErrorMessage().startsWith(CoverageDatasetFactory.NOT_GRIB_FILE) && !opt.getErrorMessage().startsWith(CoverageDatasetFactory.NO_GRIB_CLASS)) { errlog.format("%s%n", opt.getErrorMessage()); // its a GRIB file with an error return null;
@Test public void TestCFWriterCoverageSize() throws IOException, InvalidRangeException { String endpoint = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1"; logger.info("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.GRID, gds.getCoverageType()); // CFGridCoverageWriter2 adds another (dependent) time coordinate, so we need to test this case ucar.nc2.util.Optional<Long> opt = CFGridCoverageWriter2.writeOrTestSize(gds, Lists.newArrayList("Temperature_isobaric"), new SubsetParams(), false, true, null); Assert.assertTrue(opt.isPresent()); long size = opt.get(); Assert.assertEquals(25245084, size); // Includes sizes of non-coverage variables. } }
public synchronized ucar.nc2.util.Optional<DatasetNode> readCatref() throws IOException { if (proxy != null) return ucar.nc2.util.Optional.of(proxy); CatalogBuilder builder = new CatalogBuilder(); Catalog cat = builder.buildFromCatref(this); if (builder.hasFatalError() || cat == null) { return ucar.nc2.util.Optional.empty("Error reading catref " + getURI() + " err=" + builder.getErrorMessage()); } this.proxy = cat; return ucar.nc2.util.Optional.of(proxy); }
if (!estimatedSizeo.isPresent()) throw new InvalidRangeException("Request contains no data: " + estimatedSizeo.getErrorMessage());
@Override public Optional<CoverageCoordAxis> subset(double minValue, double maxValue, int stride) { // LOOK not implemented, maybe illegal ?? return Optional.of(new TimeAxis2DFmrc(new CoverageCoordAxisBuilder(this))); }
@Override public Optional<CoverageCoordAxis> subset(SubsetParams params) { Optional<CoverageCoordAxisBuilder> buildero = subsetBuilder(params); return !buildero.isPresent() ? Optional.empty(buildero.getErrorMessage()) : Optional.of(new CoverageCoordAxis1D(buildero.get())); }
if (opt.isPresent()) result.featureDataset = opt.get(); else result.errLog.format("%s", opt.getErrorMessage());
public Optional<CoverageCoordAxis> subsetByIndex(Range range) { try { CoordAxisHelper helper = new CoordAxisHelper(this); CoverageCoordAxisBuilder builder = helper.subsetByIndex(range); return Optional.of(new CoverageCoordAxis1D(builder)); } catch (InvalidRangeException e) { return Optional.empty(e.getMessage()); } }
@Override public Optional<CoverageCoordAxis> subset(SubsetParams params) { if (params == null) return Optional.of(new TimeAxis2DSwath(new CoverageCoordAxisBuilder(this))); /* CalendarDate rundate = (CalendarDate) params.get(SubsetParams.runtime); boolean runtimeAll = (Boolean) params.get(SubsetParams.runtimeAll); boolean latest = (rundate == null) && !runtimeAll; // default is latest int run_index = -1; if (latest) { run_index = runCoord.getNcoords() - 1; } else if (rundate != null){ double rundateTarget = runCoord.convert(rundate); CoordAxisHelper helper = new CoordAxisHelper(runCoord); run_index = helper.findCoordElement(rundateTarget, true); // LOOK Bounded } if (run_index >= 0) { CoverageCoordAxis1D time1D = getTimeAxisForRun(run_index); return time1D.subset(params); } */ // no subsetting needed return Optional.of(new TimeAxis2DSwath(new CoverageCoordAxisBuilder(this))); }
public Optional<List<CoverageCoordAxis>> subset(SubsetParams params, AtomicBoolean isConstantForcast, boolean makeCFcompliant) { return Optional.empty("not implemented by "+getClass().getName());