Examples of NetcdfFile


Examples of ucar.nc2.NetcdfFile

}

  public void problemV() throws IOException {
    H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    String filename = testDir + "ssec-h5/MYD04_L2.A2006188.1830.005.2006194121515.hdf";
    NetcdfFile ncfile = NetcdfFile.open(filename);
    Variable v = ncfile.findVariable("/U-MARF/EPS/IASI_xxx_1C/DATA/SPECT_LAT_ARRAY");
    Array data = v.read();
    System.out.println("\n**** testReadNetcdf4 done\n\n" + ncfile);
    NCdump.printArray(data, "primary_cloud", System.out, null);
    ncfile.close();
  }
View Full Code Here

Examples of ucar.nc2.NetcdfFile

  }

  static public void readAllData( String filename) {
    System.out.println("\n------Reading filename "+filename);
    try {
      NetcdfFile ncfile = TestH5.open(filename);
      //System.out.println("\n"+ncfile);

      for (Variable v : ncfile.getVariables()) {
        if (v.getSize() > max_size) {
          Section s = makeSubset(v);
          System.out.println("  Try to read variable " + v.getNameAndDimensions() + " size= " + v.getSize() + " section= " + s);
          v.read(s);
        } else {
          System.out.println("  Try to read variable " + v.getNameAndDimensions() + " size= " + v.getSize());
          v.read();
        }
      }
      ncfile.close();
    } catch (Exception e) {
      e.printStackTrace();
      //assert false;
    }
  }
View Full Code Here

Examples of ucar.nc2.NetcdfFile

  public void testFilterNoneApplied() throws IOException {
    // H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));

    // actually bogus - apparently all filters arre turned off
    // but its a test of filtered data with no filter actually applied
    NetcdfFile ncfile = TestH5.openH5("support/zip.h5");
    Variable v = ncfile.findVariable("Data/Compressed_Data");
    assert v != null;
    Array data = v.read();
    int[] shape = data.getShape();
    assert shape[0] == 1000;
    assert shape[1] == 20;
View Full Code Here

Examples of ucar.nc2.NetcdfFile

  public void test2() throws IOException {
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));

    // probably bogus also, cant find any non-zero filtered variables
    NetcdfFile ncfile = TestH5.openH5("wrf/wrf_input_seq.h5");
    Variable v = ncfile.findVariable("DATASET=INPUT/GSW");
    assert v != null;
    Array data = v.read();
    int[] shape = data.getShape();
    assert shape[0] == 1;
    assert shape[1] == 20;
View Full Code Here

Examples of ucar.nc2.NetcdfFile

    assert shape[2] == 10;
  }

  public void testDeflate() throws IOException {
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfFile ncfile = TestH5.openH5("msg/MSG1_8bit_HRV.H5");

    // picture looks ok in ToolsUI
    Variable v = ncfile.findVariable("image1/image_data");
    assert v != null;
    Array data = v.read();
    int[] shape = data.getShape();
    assert shape[0] == 1000;
    assert shape[1] == 1500;
View Full Code Here

Examples of ucar.nc2.NetcdfFile

    assert shape[1] == 1500;
  }

  public void testMissing() throws IOException {
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfFile ncfile = TestH5.openH5("HIRDLS/HIRDLS2-AFGL_b027_na.he5");

    // picture looks ok in ToolsUI
    Variable v = ncfile.findVariable("HDFEOS/SWATHS/HIRDLS/Data Fields/Altitude");
    assert v != null;
    Array data = v.read();
    int[] shape = data.getShape();
    assert shape[0] == 6;
    assert shape[1] == 145;
View Full Code Here

Examples of ucar.nc2.NetcdfFile

    } catch (IllegalAccessException e) {
      throw new IOException("IOServiceProvider " + c.getName() + " IllegalAccessException: " + e.getMessage());
    }
    ucar.unidata.io.RandomAccessFile rafB = new ucar.unidata.io.RandomAccessFile(fileBinary, "r");
    rafB.order(ucar.unidata.io.RandomAccessFile.BIG_ENDIAN);
    NetcdfFile ncfileBinary = new MyNetcdfFile(spiB, rafB, fileBinary, null);
    System.out.println("Binary Netcdf object created");

    try {
      spiB = (IOServiceProvider) c.newInstance();
    } catch (InstantiationException e) {
      throw new IOException("IOServiceProvider " + c.getName() + "must have no-arg constructor.");
    } catch (IllegalAccessException e) {
      throw new IOException("IOServiceProvider " + c.getName() + " IllegalAccessException: " + e.getMessage());
    }
    ucar.unidata.io.RandomAccessFile rafT = new ucar.unidata.io.RandomAccessFile(fileText, "r");
    rafT.order(ucar.unidata.io.RandomAccessFile.BIG_ENDIAN);
    NetcdfFile ncfileText = new MyNetcdfFile(spiB, rafT, fileText, null);

    System.out.println("Text Index Netcdf object created");

    // org,  copy,  _compareData,  _showCompare,  _showEach
    //ucar.nc2.TestCompare.compareFiles(ncfileBinary, ncfileText, true, true, true);
    TestCompareGrib.compareFiles(ncfileBinary, ncfileText, false, true, false);
    ncfileBinary.close();
    ncfileText.close();
  }
View Full Code Here

Examples of ucar.nc2.NetcdfFile

     char a_string(10);
     char b_string(13);
   } Compound String(10);
   */
  public void testStructureArray() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/cstr.h5");

    Variable v = ncfile.findVariable("Compound String");
    assert( null != v);
    assert( v.getDataType() == DataType.STRUCTURE);
    assert( v instanceof Structure);
    assert( v.getRank() == 1);
    assert( v.getShape()[0] == 10);

      Array data = v.read();
      assert(data.getElementType() == StructureData.class);
      assert (data instanceof ArrayStructure);
      assert (data.getSize() == 10);
      assert (data.getRank() == 1);

      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        Object o = iter.next();
        assert (o instanceof StructureData);
        StructureData d = (StructureData) o;
        Array arr = d.getArray("a_string");
        assert (arr != null);
        assert (arr.getElementType() == char.class);
        assert (arr instanceof ArrayChar);
        ArrayChar arrc = (ArrayChar) arr;
        out.println(arrc.getString());
        assert arrc.getString().equals("Astronomy") : arrc.getString();

        arr = d.getArray("b_string");
        assert (arr != null);
        assert (arr.getElementType() == char.class);
        assert (arr instanceof ArrayChar);
        arrc = (ArrayChar) arr;
        out.println(arrc.getString());
        assert arrc.getString().equals("Biochemistry") : arrc.getString();
      }

      ncfile.close();
  } // */
 
View Full Code Here

Examples of ucar.nc2.NetcdfFile

     float b_name;
   } ArrayOfStructures(30);
   type = Layout(8);  type= 2 (chunked) storageSize = (3,16) dataSize=0 dataAddress=1576
   */
  public void testStructureArrayChunked() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/cuslab.h5");

    Variable v = ncfile.findVariable("ArrayOfStructures");
    assert( null != v);
    assert( v.getDataType() == DataType.STRUCTURE);
    assert( v instanceof Structure);
    assert( v.getRank() == 1);
    assert( v.getShape()[0] == 30);

    Array data = null;
    try {
      data = v.read();
    } catch (IOException e) { assert false; } // */

    assert(data.getElementType() == StructureData.class);
    assert (data instanceof ArrayStructure);
    assert (data.getSize() == 30);
    assert (data.getRank() == 1);

    IndexIterator iter = data.getIndexIterator();
    while (iter.hasNext()) {
      Object o = iter.next();
      assert (o instanceof StructureData) : o;
      StructureData d = (StructureData) o;
      Array arr = d.getArray("a_name");
      assert (arr != null);
      assert (arr.getElementType() == int.class);
      assert (arr instanceof ArrayInt);
      NCdump.printArray( arr, "a_name", out, null);

      arr = d.getArray("b_name");
      assert (arr != null);
      assert (arr.getElementType() == float.class);
      assert (arr instanceof ArrayFloat);
      NCdump.printArray( arr, "b_name", out, null);

      arr = d.getArray("c_name");
      assert (arr != null);
      assert (arr.getElementType() == double.class);
      assert (arr instanceof ArrayDouble);
      NCdump.printArray( arr, "c_name", out, null);
    }

    // this tests that we are using the btree ok
    Index ima = data.getIndex();
    StructureData sd = (StructureData) data.getObject( ima.set0(29));
    assert (sd.getScalarDouble("c_name") == 9.0) : sd.getScalarDouble("c_name");

    ncfile.close();
  } // */
 
View Full Code Here

Examples of ucar.nc2.NetcdfFile

    } catch (IllegalAccessException e) {
      throw new IOException("IOServiceProvider " + c.getName() + " IllegalAccessException: " + e.getMessage());
    }
    ucar.unidata.io.RandomAccessFile rafB = new ucar.unidata.io.RandomAccessFile(fileBinary, "r");
    rafB.order(ucar.unidata.io.RandomAccessFile.BIG_ENDIAN);
    NetcdfFile ncfileBinary = new NetcdfFileSPI(spiB, rafB, fileBinary, null);
    //System.out.println( "Time to create Netcdf object using GridGrib Iosp "+
    //  (System.currentTimeMillis() - start) );
    System.out.println("Binary Netcdf created");

    start = System.currentTimeMillis();

    IOServiceProvider spiT = null;
    try {
      spiT = (IOServiceProvider) c.newInstance();
    } catch (InstantiationException e) {
      throw new IOException("IOServiceProvider " + c.getName() + "must have no-arg constructor.");
    } catch (IllegalAccessException e) {
      throw new IOException("IOServiceProvider " + c.getName() + " IllegalAccessException: " + e.getMessage());
    }
    ucar.unidata.io.RandomAccessFile rafT = new ucar.unidata.io.RandomAccessFile(fileText, "r");
    rafT.order(ucar.unidata.io.RandomAccessFile.BIG_ENDIAN);
    NetcdfFile ncfileText = new NetcdfFileSPI(spiT, rafT, fileText, null);

    System.out.println("Text Netcdf created");

    //System.out.println( "Time to create Netcdf object using Grid1 Grib2 Iosp "+
    //  (System.currentTimeMillis() - start) );
    // org,  copy,  _compareData,  _showCompare,  _showEach
    //ucar.nc2.TestCompare.compareFiles(ncfileBinary, ncfileText, true, true, true);
    CompareNetcdf.compareFiles(ncfileBinary, ncfileText, false, true, false);
    ncfileBinary.close();
    ncfileText.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.