Package com.cloudera.lib.service

Examples of com.cloudera.lib.service.Instrumentation$Variable


  public void testReadCompressedByte() throws IOException {
    // actually doesnt seem to be compressed ??

    NetcdfFile ncfile = TestH5.openH5("msg/MSG1_8bit_HRV.H5");
    Variable dset = ncfile.findVariable("image1/image_preview");
    assert dset != null;
    assert(dset.getDataType() == DataType.BYTE);

    assert(dset.getRank() == 2);
    assert(dset.getShape()[0] == 64);
    assert(dset.getShape()[1] == 96);

    // read entire array
    Array A = dset.read();
    assert(A.getRank() == 2);
    assert(A.getShape()[0] == 64);
    assert(A.getShape()[1] == 96);

    byte[] firstRow = new byte[] {
View Full Code Here


  }

  public void testEndian() throws IOException {
    String testDir = TestN4.testDir;
    NetcdfFile ncfile = TestNC2.open(testDir+"endianTest.nc4");
    Variable v = ncfile.findVariable("TMP");
    assert v != null;
    assert v.getDataType() == DataType.FLOAT;

    Array data = v.read();
    assert data.getElementType() == float.class;

    //large values indicate incorrect inflate or byte swapping
    while (data.hasNext()) {
      float val = data.nextFloat();
View Full Code Here

  }

  public void testReadArrayType() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/SDS_array_type.h5");

    Variable dset = null;
    assert(null != (dset = ncfile.findVariable("IntArray")));
    assert(dset.getDataType() == DataType.INT);

    assert(dset.getRank() == 3);
    assert(dset.getShape()[0] == 10);
    assert(dset.getShape()[1] == 5);
    assert(dset.getShape()[2] == 4);

    // read entire array
    Array A;
    try {
      A = dset.read();
    }
    catch (IOException e) {
      System.err.println("ERROR reading file");
      assert(false);
      return;
    }
    assert(A.getRank() == 3);

    Index ima = A.getIndex();
    int[] shape = A.getShape();

    for (int i = 0; i < shape[0]; i++)
      for (int j = 0; j < shape[1]; j++)
        for (int k = 0; k < shape[2]; k++)
          if (A.getInt(ima.set(i, j, k)) != i) {
            assert false;
          }


          // read part of array
    dset.setCachedData(null, false); // turn off caching to test read subset
    dset.setCaching(false);
    int[] origin2 = new int[3];
    int[] shape2 = new int[] {
        10, 1, 1};
    try {
      A = dset.read(origin2, shape2);
    }
    catch (InvalidRangeException e) {
      System.err.println("ERROR reading file " + e);
      assert(false);
      return;
View Full Code Here

  }

  public void testVlengthVariableChunked() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/uvlstr.h5");

    Variable v = ncfile.findVariable("Space1");
    assert (null != v);
    assert (v.getDataType() == DataType.STRING);
    assert (v.getRank() == 1);
    assert (v.getShape()[0] == 9);

    try {
      Array data = v.read();
      assert (data.getElementType() == String.class);
      assert (data instanceof ArrayObject);
      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        out.println(iter.next());
      }

    } catch (IOException e) {
      e.printStackTrace();
      assert false;
    }

    int[] origin = new int[]{3};
    int[] shape = new int[]{3};
    try {
      Array data2 = v.read(origin, shape);
      Index ima = data2.getIndex();
      assert (data2.getElementType() == String.class);
      assert (data2 instanceof ArrayObject);
      assert ((String) data2.getObject(ima.set(0))).startsWith("testing whether that nation");
      assert ((String) data2.getObject(ima.set(1))).startsWith("O Gloria inmarcesible!");
View Full Code Here

  } // */

  public void testVlengthVariable() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/vlslab.h5");

    Variable v = ncfile.findVariable("Space1");
    assert (null != v);
    assert (v.getDataType() == DataType.STRING);
    assert (v.getRank() == 1);
    assert (v.getShape()[0] == 12);

    try {
      Array data = v.read();
      assert (data.getElementType() == String.class);
      assert (data instanceof ArrayObject);
      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        out.println(iter.next());
      }

    } catch (IOException e) {
      assert false;
    }

    int[] origin = new int[]{4};
    int[] shape = new int[]{1};
    try {
      Array data2 = v.read(origin, shape);
      Index ima = data2.getIndex();
      assert (data2.getElementType() == String.class);
      assert (data2 instanceof ArrayObject);
      assert ((String) data2.getObject(ima.set(0))).equals("Five score and seven years ago our forefathers brought forth on this continent a new nation,");
    }
View Full Code Here

  }

  private void testVlenEndian(String filename, int n) throws IOException {
    NetcdfFile ncfile = NetcdfDataset.openFile(filename, null);

    Variable v = ncfile.findVariable("levels");
    assert (null != v);
    assert (v.getDataType() == DataType.INT);
    assert (v.getRank() == 2);
    assert (v.getShape()[0] == n) : v.getShape()[0];

    try {
      Array data = v.read();
      // assert(data.getElementType() instanceof ucar.ma2.ArrayInt.class) : data.getElementType();
      assert (data instanceof ArrayObject);
      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        Array inner = (Array) iter.next();
View Full Code Here

  }

  public void test1() throws IOException {
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfFile ncfile = TestH5.open(testDir +"HIRDLS1_v4.0.2a-aIrix-c2_2003d106.he5");
    Variable dset = ncfile.findVariable("HDFEOS/SWATHS/HIRDLS_L1_Swath/Data Fields/Scaled Ch01 Radiance");
    dset.read();
  }
View Full Code Here

    dset.read();
  }

  public void test2() throws IOException {
    NetcdfFile ncfile = TestH5.open(testDir +"HIRDLS2-AFGL_b027_na.he5");
    Variable dset = ncfile.findVariable("HDFEOS/SWATHS/HIRDLS/Data Fields/Altitude");
   
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/dataBtree"));
    Array data = dset.read();
    assert data.getElementType() == float.class;
  }
View Full Code Here

    //NetcdfFile ncfile = TestH5.open("c:/data/hdf5/HIRDLS/HIRDLS2_v0.3.1-aIrix-c3_2003d106.h5");
    NetcdfFile ncfile = TestH5.open(testDir +"HIRDLS2-Aura73p_b029_2000d275.he5");

    Group root = ncfile.getRootGroup();
    Group g = root.findGroup("HDFEOS INFORMATION");
    Variable dset = g.findVariable("StructMetadata.0");
    assert(null != dset );
    assert(dset.getDataType() == DataType.CHAR);

    // read entire array
    Array A;
    try {
      A = dset.read();
    }
    catch (IOException e) {
      System.err.println("ERROR reading file");
      assert(false);
      return;
    }
    assert(A.getRank() == 1);
    assert (A instanceof ArrayChar);

    ArrayChar ca = (ArrayChar) A;
    String sval = ca.getString();
    System.out.println(dset.getFullName());
    System.out.println(" Length = "+sval.length());
    System.out.println(" Value = "+sval);

    ////////////////
    dset = g.findVariable("coremetadata.0");
    assert(null != dset );
    assert(dset.getDataType() == DataType.CHAR);

    // read entire array
    try {
      A = dset.read();
    }
    catch (IOException e) {
      System.err.println("ERROR reading file");
      assert(false);
      return;
    }
    assert(A.getRank() == 1);
    assert (A instanceof ArrayChar);

    ca = (ArrayChar) A;
    sval = ca.getString();
    System.out.println(dset.getFullName());
    System.out.println(" Length = "+sval.length());
    System.out.println(" Value = "+sval);
  }
View Full Code Here

    /**
     * _more_
     */
    public void init() {
        Variable t       = ds.findVariable("time");
        Variable ele     = ds.findVariable("elevation");
        Variable azi     = ds.findVariable("azimuth");
        Variable rng     = ds.findVariable("range");
        Variable sidx0   = ds.findVariable("sweep_start_ray_index");
        Variable sidx1   = ds.findVariable("sweep_end_ray_index");
        Variable snumber = ds.findVariable("sweep_number");

        setEarthLocation();
        try {
            Array tArray = t.read();
            time = (double[]) tArray.copyTo1DJavaArray();
            Array eArray = ele.read();
            elevation = (float[]) eArray.copyTo1DJavaArray();
            Array aArray = azi.read();
            azimuth = (float[]) aArray.copyTo1DJavaArray();
            Array rArray = rng.read();
            range       = (float[]) rArray.copyTo1DJavaArray();
            rayStartIdx = (int[]) sidx0.read().copyTo1DJavaArray();
            rayEndIdx   = (int[]) sidx1.read().copyTo1DJavaArray();
            Array sn = snumber.read();
            nsweeps = ((int[]) sn.copyTo1DJavaArray()).length;

            setTimeUnits();
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of com.cloudera.lib.service.Instrumentation$Variable

Copyright © 2018 www.massapicom. 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.