public NetcdfFile open(String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { return new CdmRemote(location); } }
public NetcdfFile open(DatasetUrl location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { return new CdmRemote(location.trueurl); } }
public NetcdfFile open(String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { return new CdmRemote(location); } }
static private NetcdfFile acquireRemote(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return new CdmRemote(location); if (factory == null) factory = new RemoteFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireRemote(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return new CdmRemote(location); if (factory == null) factory = new RemoteFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireCdmRemote(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return new CdmRemote(location); if (factory == null) factory = new RemoteFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, new DatasetUrl(ServiceType.CdmRemote, location), buffer_size, cancelTask, spiObject); }
static int compareDatasets(String local, String remote, boolean readData) throws IOException { System.out.printf("--Compare %s to %s%n", local, remote); try (NetcdfFile ncfile = NetcdfDataset.openFile(local, null); NetcdfFile ncremote = new CdmRemote(remote)) { Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, false, false, false); boolean ok = mind.compare(ncfile, ncremote, new NcstreamObjFilter(), false, false, readData); if (!ok) { System.out.printf(" %s%n", f); } Assert.assertTrue(local + " != " + remote, ok); } return 1; }
static int compareDatasets(String local, String remote, boolean readData) throws IOException { try (NetcdfFile ncfile = NetcdfDataset.openFile(local, null); NetcdfFile ncremote = new CdmRemote(remote)) { Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, false, false, false); boolean ok = mind.compare(ncfile, ncremote, new NcstreamObjFilter(), false, false, readData); if (!ok) { System.out.printf("--Compare %s to %s%n", local, remote); System.out.printf(" %s%n", f); } Assert.assertTrue(local + " != " + remote, ok); } return 1; }
static public FeatureDataset factory(FeatureType wantFeatureType, String endpoint) throws IOException { if (endpoint.startsWith(SCHEME)) endpoint = endpoint.substring(SCHEME.length()); Document doc = getCapabilities(endpoint); Element root = doc.getRootElement(); Element elem = root.getChild("featureDataset"); String fType = elem.getAttribute("type").getValue(); // LOOK, may be multiple types String uri = elem.getAttribute("url").getValue(); if (debug) System.out.printf("CdmrFeatureDataset endpoint %s%n ftype= %s url=%s%n", endpoint, fType, uri); FeatureType ft = FeatureType.getType(fType); if (ft == null || ft == FeatureType.NONE || ft == FeatureType.GRID) { CdmRemote ncremote = new CdmRemote(uri); NetcdfDataset ncd = new NetcdfDataset(ncremote, null); return new GridDataset(ncd); } else { List<VariableSimpleIF> dataVars = FeatureDatasetPointXML.getDataVariables(doc); LatLonRect bb = FeatureDatasetPointXML.getSpatialExtent(doc); CalendarDateRange dr = FeatureDatasetPointXML.getTimeSpan(doc); return new PointDatasetRemote(ft, uri, dataVars, bb, dr); } }
static public FeatureDataset factory(FeatureType wantFeatureType, String endpoint) throws IOException { if (endpoint.startsWith(SCHEME)) endpoint = endpoint.substring(SCHEME.length()); Document doc = getCapabilities(endpoint); Element root = doc.getRootElement(); Element elem = root.getChild("featureDataset"); String fType = elem.getAttribute("type").getValue(); // LOOK, may be multiple types String uri = elem.getAttribute("url").getValue(); if (debug) System.out.printf("CdmrFeatureDataset endpoint %s%n ftype= %s url=%s%n", endpoint, fType, uri); FeatureType ft = FeatureType.getType(fType); if (ft == null || ft == FeatureType.NONE || ft == FeatureType.GRID) { CdmRemote ncremote = new CdmRemote(uri); NetcdfDataset ncd = new NetcdfDataset(ncremote, null); return new GridDataset(ncd); } else { List<VariableSimpleIF> dataVars = FeatureDatasetPointXML.getDataVariables(doc); LatLonRect bb = FeatureDatasetPointXML.getSpatialExtent(doc); CalendarDateRange dr = FeatureDatasetPointXML.getTimeSpan(doc); DateUnit timeUnit = FeatureDatasetPointXML.getTimeUnit(doc); String altUnits = FeatureDatasetPointXML.getAltUnits(doc); return new PointDatasetRemote(ft, uri, timeUnit, altUnits, dataVars, bb, dr); } }
@Test public void testChardata() { // was failing on char data being sign extended try { String filename = "/netcdf3/files/c0_64.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testByteOrder() { try { String filename = "/netcdf3/longOffset.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath + filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, true, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testVlen() { try { String filename = "/netcdf4/vlen/tst_vl.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testVlenInStructure() { try { String filename = "/netcdf4/vlen/IntTimSciSamp.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testTopVlenInt() { try { String filename = "/netcdf4/vlen/vlenInt.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testStringArray() { try { String filename = "/netcdf4/files/tst_string_data.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void zeroLenData() throws IOException { try (NetcdfFile ncremote = new CdmRemote(TestOnLocalServer.withHttpPath(urlPath + "/netcdf3/longOffset.nc"))) { Variable v = ncremote.findVariable(null, "time_whole"); Array data = v.read(); assert data.getSize() == 0; } }
@Test public void testVariableNameWithDot() { try { String filename = "/hdf5/grid_1_3d_xyz_aug.h5"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), false, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } } }
@Test public void backlashEscaped() throws IOException { try (NetcdfFile ncremote = new CdmRemote(TestOnLocalServer.withHttpPath(urlPath + "/hdf5/grid_1_3d_xyz_aug.h5"))) { Variable v = ncremote.findVariable("HDFEOS_INFORMATION/StructMetadata\\.0"); Assert.assertNotNull(v); Array data = v.read(); Assert.assertEquals(32000, data.getSize()); } }
static int timeDataRead(String remote, int stride) throws IOException, InvalidRangeException { logger.debug("--CdmRemote Read {} stride={}", remote, stride); try (NetcdfFile ncremote = new CdmRemote(remote)) { String gridName = "10_metre_V_wind_component_surface"; Variable vs = ncremote.findVariable(gridName); Assert.assertNotNull(gridName, vs); Section section = vs.getShapeAsSection(); Assert.assertEquals(3, section.getRank()); Section want = new Section().appendRange(1); want.appendRange(section.getRange(1).setStride(stride)); want.appendRange(section.getRange(2).setStride(stride)); long start = System.currentTimeMillis(); Array data = vs.read(want); long took = System.currentTimeMillis() - start; logger.debug("took={} size={}", took, data.getSize()); } return 1; }