public static NetcdfDataset acquireDataset(URI uri) throws IOException { if (getFormat(uri) == FileFormat.FC) { return acquireFeatureCollection(uri.toString()); } else { return NetcdfDataset.acquireDataset(uri.toString(), null); } }
public FmrcImpl(String filename) throws IOException { this( ucar.nc2.dataset.NetcdfDataset.acquireDataset(filename, null)); }
static public NetcdfDataset acquireDataset(String location, boolean enhance, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, enhance ? defaultEnhanceMode : null, -1, cancelTask, null); }
static public NetcdfDataset acquireDataset(String location, boolean enhance, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, enhance ? defaultEnhanceMode : null, -1, cancelTask, null); }
/** * Same as openDataset, but file is acquired through the File Cache, with defaultEnhanceMode. * You still close with NetcdfDataset.close(), the release is handled automatically. * You must first call initNetcdfFileCache() for caching to actually take place. * * @param location location of file, passed to FileFactory * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfDataset object * @throws java.io.IOException on read error */ static public NetcdfDataset acquireDataset(String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, defaultEnhanceMode, -1, cancelTask, null); }
/** * Same as openDataset, but file is acquired through the File Cache, with defaultEnhanceMode. * You still close with NetcdfDataset.close(), the release is handled automatically. * You must first call initNetcdfFileCache() for caching to actually take place. * * @param location location of file, passed to FileFactory * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfDataset object * @throws java.io.IOException on read error */ static public NetcdfDataset acquireDataset(String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, defaultEnhanceMode, -1, cancelTask, null); }
/** * Same as openDataset, but file is acquired through the File Cache, with defaultEnhanceMode, * without the need of setting the enhanceMode via the signature. * You still close with NetcdfDataset.close(), the release is handled automatically. * You must first call initNetcdfFileCache() for caching to actually take place. * * @param location location of file, passed to FileFactory * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfDataset object * @throws java.io.IOException on read error */ static public NetcdfDataset acquireDataset(DatasetUrl location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, defaultEnhanceMode, -1, cancelTask, null); }
/** * Same as openDataset, but file is acquired through the File Cache, with defaultEnhanceMode. * You still close with NetcdfDataset.close(), the release is handled automatically. * You must first call initNetcdfFileCache() for caching to actually take place. * * @param location location of file, passed to FileFactory * @param enhanceMode how to enhance. if null, then no enhancement * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfDataset object * @throws java.io.IOException on read error */ static public NetcdfDataset acquireDataset(DatasetUrl location, boolean enhanceMode, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, enhanceMode ? defaultEnhanceMode : null, -1, cancelTask, null); }
/** * Same as openDataset, but file is acquired through the File Cache, with specified enhancements. * You still close with NetcdfDataset.close(), the release is handled automatically. * You must first call initNetcdfFileCache() for caching to actually take place. * * @param location location of file, passed to FileFactory * @param enhanceMode how to enhance. if null, then no enhancement * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfDataset object * @throws java.io.IOException on read error */ static public NetcdfDataset acquireDataset(DatasetUrl location, Set<Enhance> enhanceMode, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquireDataset(null, location, enhanceMode, -1, cancelTask, null); }
/** * Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems * and turn into a GridDataset. * * @param location netcdf dataset to open, using NetcdfDataset.acquireDataset(). * @param enhanceMode open netcdf dataset with this enhanceMode * @return GridDataset * @throws java.io.IOException on read error * @see ucar.nc2.dataset.NetcdfDataset#acquireDataset */ static public GridDataset open(String location, Set<NetcdfDataset.Enhance> enhanceMode) throws java.io.IOException { NetcdfDataset ds = ucar.nc2.dataset.NetcdfDataset.acquireDataset(null, location, enhanceMode, -1, null, null); return new GridDataset(ds, null); }
/** * Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems * and turn into a GridDataset. * * @param location netcdf dataset to open, using NetcdfDataset.acquireDataset(). * @param enhanceMode open netcdf dataset with this enhanceMode * @return GridDataset * @throws java.io.IOException on read error * @see ucar.nc2.dataset.NetcdfDataset#acquireDataset */ static public GridDataset open(String location, Set<NetcdfDataset.Enhance> enhanceMode) throws java.io.IOException { NetcdfDataset ds = ucar.nc2.dataset.NetcdfDataset.acquireDataset(null, location, enhanceMode, -1, null, null); return new GridDataset(ds, null); }
/** * Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems * and turn into a DtCoverageDataset. * * @param durl netcdf dataset to open, using NetcdfDataset.acquireDataset(). * @param enhanceMode open netcdf dataset with this enhanceMode * @return GridDataset * @throws java.io.IOException on read error * @see ucar.nc2.dataset.NetcdfDataset#acquireDataset */ static public DtCoverageDataset open(DatasetUrl durl, Set<NetcdfDataset.Enhance> enhanceMode) throws java.io.IOException { NetcdfDataset ds = ucar.nc2.dataset.NetcdfDataset.acquireDataset(null, durl, enhanceMode, -1, null, null); return new DtCoverageDataset(ds, null); }
public static NetcdfDataset acquireDataset(URI uri) throws IOException { if (getFormat(uri) == FileFormat.FC) { return acquireFeatureCollection(uri.toString()); } else { return NetcdfDataset.acquireDataset(uri.toString(), null); } }
/** * Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems * and turn into a GridDataset. * * @param location netcdf dataset to open, using NetcdfDataset.acquireDataset(). * @param enhanceMode open netcdf dataset with this enhanceMode * @return GridDataset * @throws java.io.IOException on read error * @see ucar.nc2.dataset.NetcdfDataset#acquireDataset */ static public GridDataset open(String location, Set<NetcdfDataset.Enhance> enhanceMode) throws java.io.IOException { NetcdfDataset ds = ucar.nc2.dataset.NetcdfDataset.acquireDataset(null, DatasetUrl.findDatasetUrl(location), enhanceMode, -1, null, null); return new GridDataset(ds, null); }
/** * Open a dataset as a TypedDataset. * * @param datatype open this kind of Typed Dataset; may be null, which means search all factories. * If datatype is not null, only return correct TypedDataset (eg PointObsDataset for DataType.POINT). * @param location URL or file location of the dataset * @param task user may cancel * @param errlog place errors here, may not be null * @return a subclass of TypedDataset * @throws java.io.IOException on io error */ static public TypedDataset open( FeatureType datatype, String location, ucar.nc2.util.CancelTask task, StringBuilder errlog) throws IOException { DatasetUrl durl = DatasetUrl.findDatasetUrl(location); NetcdfDataset ncd = NetcdfDataset.acquireDataset(durl, true, task); return open( datatype, ncd, task, errlog); }
@Test public void doOne() throws Exception { try (NetcdfFile ncfile = NetcdfDataset.acquireFile(durl, null); NetcdfDataset ncWrap = new NetcdfDataset(ncfile, true)) { NetcdfDataset ncd = NetcdfDataset.acquireDataset(durl, true, null); System.out.println(" dataset wraps= " + durl.trueurl); ucar.unidata.util.test.CompareNetcdf.compareFiles(ncd, ncWrap); } } }
private void doOne(String filename) throws Exception { try (NetcdfFile ncfile = NetcdfDataset.acquireFile(new DatasetUrl(null, filename), null); NetcdfDataset ncWrap = new NetcdfDataset(ncfile, true)) { NetcdfDataset ncd = NetcdfDataset.acquireDataset(new DatasetUrl(null, filename), true , null); System.out.println(" dataset wraps= " + filename); ucar.unidata.util.test.CompareNetcdf.compareFiles(ncd, ncWrap); ncd.close(); ncWrap.close(); } }
@Test public void TestNotCached() throws IOException { String filename = TestDir.cdmUnitTestDir + "ncml/nestedAgg/test.ncml"; try (NetcdfDataset ncd = NetcdfDataset.acquireDataset(DatasetUrl.findDatasetUrl(filename), true ,null)) { Variable time = ncd.findVariable("time"); assert time != null; assert time.getSize() == 19723 : time.getSize(); // System.out.printf(" time array = %s%n", NCdumpW.toString(time.read())); } }
static public TrajectoryObsDataset open(String netcdfFileURI, ucar.nc2.util.CancelTask cancelTask) throws IOException { DatasetUrl durl = DatasetUrl.findDatasetUrl(netcdfFileURI); NetcdfDataset ds = NetcdfDataset.acquireDataset(durl, true, cancelTask); if (RafTrajectoryObsDataset.isValidFile(ds)) return new RafTrajectoryObsDataset(ds); else if (SimpleTrajectoryObsDataset.isValidFile(ds)) return new SimpleTrajectoryObsDataset(ds); else if (Float10TrajectoryObsDataset.isValidFile(ds)) return new Float10TrajectoryObsDataset(ds); else if (ZebraClassTrajectoryObsDataset.isValidFile(ds)) return new ZebraClassTrajectoryObsDataset(ds); else if (ARMTrajectoryObsDataset.isValidFile(ds)) return new ARMTrajectoryObsDataset(ds); else return null; } }
@Test public void testUpdateCache() throws IOException, InvalidRangeException, InterruptedException { // make sure that the extra file is not in the agg move(extraFile); DatasetUrl durl = DatasetUrl.findDatasetUrl(location); // open the agg NetcdfFile ncfile = NetcdfDataset.acquireDataset(new NcmlStringFileFactory(), durl, null, -1, null, null); check(ncfile, 12); // now make sure that the extra file is in the agg moveBack(extraFile); // reread ncfile.syncExtend(); check(ncfile, 18); ncfile.close(); }