/** * Open an existing netcdf file (read only). * * @param location location of file. * @return the NetcdfFile. * @throws java.io.IOException if error */ public static NetcdfFile open(String location) throws IOException { return open(location, null); }
/** * Open an existing netcdf file (read only). * * @param location location of file. * @return the NetcdfFile. * @throws java.io.IOException if error */ public static NetcdfFile open(String location) throws IOException { return open(location, null); }
/** * Open an existing file (read only), with option of cancelling, setting the RandomAccessFile buffer size for efficiency. * * @param location location of file. * @param buffer_size RandomAccessFile buffer size, if <= 0, use default size * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfFile object, or null if cant find IOServiceProver * @throws IOException if error */ static public NetcdfFile open(String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask) throws IOException { return open(location, buffer_size, cancelTask, null); }
/** * Open an existing file (read only), with option of cancelling. * * @param location location of the file. * @param cancelTask allow task to be cancelled; may be null. * @return NetcdfFile object, or null if cant find IOServiceProver * @throws IOException if error */ static public NetcdfFile open(String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return open(location, -1, cancelTask); }
public static void doon(String filename) throws IOException, InvalidRangeException { System.out.printf("BufrIosp compare = %s%n", filename); NetcdfFile ncfile = NetcdfFile.open(filename); BufrIosp iosp = (BufrIosp) ncfile.getIosp(); iosp.readAll(false); // iosp.compare(iosp.construct.recordStructure); }
NetcdfFile ncFile = null; try { ncFile = NetcdfFile.open(tis.getFile().getAbsolutePath()); metadata.set("File-Type-Description", ncFile.getFileTypeDescription());
private void openNetcdf(String filename) throws IOException { System.out.printf("%n***openNetcdf bufr %s%n", filename); try (NetcdfFile ncfile = NetcdfFile.open(filename)) { if (show) System.out.printf("%s%n", ncfile); } }
@org.junit.Test public void openNetcdfFile() throws Exception { try (NetcdfFile ncfile = NetcdfFile.open(name)) { assert true; } }
public void checkFile(String url) throws IOException { try (NetcdfFile file = NetcdfFile.open(url, null)) { assert file.findVariable(newVarName) != null : "cant find "+newVarName; } } }
public void readBothWays(String filename) throws IOException { NetcdfFile ncfile = NetcdfFile.open(filename); ncfile.sendIospMessage(NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE); //System.out.println(ncfile); ncfile.close(); ncfile = NetcdfFile.open(filename); //System.out.println(ncfile); 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(); }
@Test public void testOpenNetcdfFile() throws IOException { try (NetcdfFile ncfile = NetcdfFile.open(url)) { test(ncfile); logger.debug("***************** Test testOpenNetcdfFile over HTTP done"); } }
@Test public void testEnums() throws IOException { //H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header")); String filename = testDir+"tst/tst_enums.nc"; try (NetcdfFile ncfile = NetcdfFile.open(filename)) { logger.debug("**** testReadNetcdf4 done\n{}", ncfile); List<Variable> vars = ncfile.getVariables(); Collections.sort(vars); for (Variable v : vars) logger.debug(" {}", v.getFullName()); logger.debug("nvars = {}", ncfile.getVariables().size()); } }
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 pdsScaleOverflow() throws Exception { String filename = TestDir.cdmUnitTestDir + "formats/grib2/pdsScale.grib2"; logger.debug("{}", filename); try (NetcdfFile ncfile = NetcdfFile.open(filename, null)) { Variable v = ncfile.findVariable("isobaric"); float val = v.readScalarFloat(); Assert2.assertNearlyEquals(val, 92500.0); } }
@Test public void testUamiv() throws IOException { try (NetcdfFile ncfile = NetcdfFile.open(TestDir.cdmUnitTestDir + "formats/uamiv/uamiv.grid", null)) { logger.debug("open {}", ncfile.getLocation()); ucar.nc2.Variable v = ncfile.findVariable("UP"); assert v != null; assert v.getDataType() == DataType.FLOAT; Array data = v.read(); assert Arrays.equals(data.getShape(), new int[]{12, 5, 7, 6}); } }
@Test public void testMultiDimscale() throws IOException { // Global Heap 1t 13059 runs out with no heap id = 0 String filename = testDir+"multiDimscale.nc4"; try (NetcdfFile ncfile = NetcdfFile.open(filename)) { Variable v = ncfile.findVariable("siglev"); v.read(); v = ncfile.findVariable("siglay"); v.read(); logger.debug("**** testMultiDimScale read ok\n{}", ncfile); } }
@Test public void code6_assume_spherical() throws IOException { String filename = dir + "berkes.grb2"; try (NetcdfFile ncfile = NetcdfFile.open(filename, null)) { Group grp = ncfile.getRootGroup().getGroups().get(0); Variable v = grp.findVariable("LatLon_Projection"); Attribute axis = v.findAttribute("earth_radius"); Assert.assertEquals(6371229., axis.getNumericValue().doubleValue(), 0.1); } }
@Test public void testEcmwfExtendedComplexData() throws IOException { final String testfile = "../grib/src/test/data/complex_packing.grib1"; try (NetcdfFile nc = NetcdfFile.open(testfile)) { Variable var = nc.findVariable("Minimum_temperature_at_2_metres_in_the_last_6_hours_surface_6_Hour"); Array data = var.read(); float first = data.getFloat(0); Assert.assertEquals(264.135559, first, 1e-6); } }
@Test public void testPng() throws IOException { final String testfile = "../grib/src/test/data/MRMS_LowLevelCompositeReflectivity_00.50_20141207-072038.grib2.gz"; try (NetcdfFile nc = NetcdfFile.open(testfile)) { Variable var = nc.findVariable("LowLevelCompositeReflectivity_altitude_above_msl"); float[] data = (float[]) var.read().get1DJavaArray(float.class); Assert.assertEquals(-99., data[15], 1e-6); Assert.assertEquals(18.5, data[5602228], 1e-6); } }