public static void main(String args[]) throws Exception, IOException, InstantiationException, IllegalAccessException { //String fileIn = "/home/yuanho/dev/netcdf-java-2.2/src/ucar/nc2/n0r_20040823_2215"; // uncompressed String fileIn = "/home/yuanho/Desktop/ufData/KTLX__sur_20080624.214247.uf"; // ucar.nc2.NetcdfFile.registerIOProvider( ucar.nc.iosp.uf.UFiosp.class); ucar.nc2.NetcdfFile ncf = ucar.nc2.NetcdfFile.open(fileIn); ncf.close(); }
protected void close(NetcdfFile ncfile) throws IOException { if (ncfile == null) return; cacheVariables(ncfile); ncfile.close(); }
protected void close(NetcdfFile ncfile) throws IOException { if (ncfile == null) return; cacheVariables(ncfile); ncfile.close(); }
protected void close(NetcdfFile ncfile) throws IOException { if (ncfile == null) return; cacheVariables(ncfile); ncfile.close(); }
} finally { if (ncFile != null) { ncFile.close();
/** * close out agg dataset when tests are finished */ @After public void closeAggDataset() { try { ncfile.close(); } catch (IOException e) { e.printStackTrace(); } } }
public Array reallyRead(Variable client, Section section, CancelTask cancelTask) throws IOException, InvalidRangeException { NetcdfFile ncfile = null; try { ncfile = open(location, null); Variable proxyV = findVariable(ncfile, client); if ((cancelTask != null) && cancelTask.isCancel()) return null; return proxyV.read(section); } finally { ncfile.close(); } } }
public Array reallyRead(Variable client, CancelTask cancelTask) throws IOException { NetcdfFile ncfile = null; try { ncfile = open(location, null); if ((cancelTask != null) && cancelTask.isCancel()) return null; Variable proxyV = findVariable(ncfile, client); return proxyV.read(); } finally { ncfile.close(); } }
protected Array read(DatasetOuterDimension dset) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; if (type == Type.joinNew) return null; // ?? NetcdfFile ncfile = null; try { ncfile = dset.acquireFile(null); return read(dset, ncfile); } finally { if (ncfile != null) ncfile.close(); } }
public static void main(String args[]) throws Exception, IOException, InstantiationException, IllegalAccessException { String fileIn = "/home/yuanho/NIDS/N0R_20041102_2111"; //String fileIn = "c:/data/image/Nids/n0r_20041013_1852"; ucar.nc2.NetcdfFile.registerIOProvider(ucar.nc2.iosp.nids.Nidsiosp.class); ucar.nc2.NetcdfFile ncf = ucar.nc2.NetcdfFile.open(fileIn); //List alist = ncf.getGlobalAttributes(); ucar.nc2.Variable v = ncf.findVariable("BaseReflectivity"); int[] origin = {0, 0}; int[] shape = {300, 36}; v.read(origin, shape); ncf.close(); }
protected Array read(DatasetOuterDimension dset) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; if (type == Type.joinNew) return null; // ?? NetcdfFile ncfile = null; try { ncfile = dset.acquireFile(null); return read(dset, ncfile); } finally { if (ncfile != null) ncfile.close(); } }
protected Array read(DatasetOuterDimension dset) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; if (type == Type.joinNew) return null; // ?? NetcdfFile ncfile = null; try { ncfile = dset.acquireFile(null); return read(dset, ncfile); } finally { if (ncfile != null) ncfile.close(); } }
@Test public void testProblem() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/testproj2.grb"; System.out.println("read file= "+filename); NetcdfFile ncfile = NetcdfDataset.openFile( filename, null); ncfile.close(); }
private boolean copyFile(String datasetIn, String datasetOut, NetcdfFileWriter.Version version) throws IOException { System.out.printf("TestNc4IospWriting copy %s to %s%n", datasetIn, datasetOut); NetcdfFile ncfileIn = ucar.nc2.NetcdfFile.open(datasetIn, null); FileWriter2 writer2 = new FileWriter2(ncfileIn, datasetOut, version, null); NetcdfFile ncfileOut = writer2.write(); compare(ncfileIn, ncfileOut, false, false, true); ncfileIn.close(); ncfileOut.close(); // System.out.println("NetcdfFile written = " + ncfileOut); return true; }
public static void main(String args[]) throws Exception, IOException, InstantiationException, IllegalAccessException { //String fileIn = "/home/yuanho/dev/netcdf-java-2.2/src/ucar/nc2/n0r_20040823_2215"; // uncompressed String fileIn = "c:/data/image/gini/n0r_20041013_1852"; ucar.nc2.NetcdfFile.registerIOProvider(ucar.nc2.iosp.gini.Giniiosp.class); ucar.nc2.NetcdfFile ncf = ucar.nc2.NetcdfFile.open(fileIn); List alist = ncf.getGlobalAttributes(); ucar.nc2.Variable v = ncf.findVariable("BaseReflectivity"); int[] origin = {0, 0}; int[] shape = {3000, 4736}; ArrayByte data = (ArrayByte) v.read(origin, shape); ncf.close(); }
@Test public void testGaussianLats() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/CCCma_SRES_A2_HGT500_1-10.grb"; System.out.println("\n\nReading File " + filename); NetcdfFile ncfile = NetcdfFile.open(filename); Group best = ncfile.findGroup("Best"); Variable lat = ncfile.findVariable(best, "lat"); assert lat.getSize() == 48; ncfile.close(); }
@Test public void testNcmlDirect() throws IOException, InvalidRangeException { String filename = "file:./"+TestNcML.topDir + "aggExisting.xml"; NetcdfFile ncfile = NcMLReader.readNcML(filename, null); logger.debug(" TestNcmlAggExisting.open {}", filename); testDimensions(ncfile); testCoordVar(ncfile); testAggCoordVar(ncfile); testReadData(ncfile); testReadSlice(ncfile); ncfile.close(); }
@Test public void testNcmlDatasetNoProtocolInFilename() throws IOException, InvalidRangeException { String filename = "./"+TestNcML.topDir + "aggExisting.xml"; NetcdfFile ncfile = NetcdfDataset.openDataset( filename, true, null); logger.debug(" TestNcmlAggExisting.open {}", filename); testDimensions(ncfile); testCoordVar(ncfile); testAggCoordVar(ncfile); testReadData(ncfile); testReadSlice(ncfile); ncfile.close(); }
@Test public void testNcmlDatasetNoProtocolInFilenameOrNcmlRelPath() throws IOException, InvalidRangeException { String filename = "./"+TestNcML.topDir + "aggExisting7.xml"; NetcdfFile ncfile = NetcdfDataset.openDataset( filename, true, null); logger.debug(" TestNcmlAggExisting.open {}", filename); testDimensions(ncfile); testCoordVar(ncfile); testAggCoordVar(ncfile); testReadData(ncfile); testReadSlice(ncfile); ncfile.close(); }
public void test3() throws IOException, InvalidRangeException { String filename = "file:./" + TestNcML.topDir + "aggSynthetic3.xml"; NetcdfFile ncfile = NcMLReader.readNcML(filename, null); testDimensions(ncfile); testCoordVar(ncfile); testAggCoordVar3(ncfile); testReadData(ncfile, "T"); testReadSlice(ncfile, "T"); ncfile.close(); }