Package ucar.nc2

Examples of ucar.nc2.Variable$Cache


    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

     * _more_
     */
    protected void setEarthLocation() {

        try {
            Variable ga = ds.findVariable("latitude");
            if (ga != null) {
                latv = ga.readScalarDouble();
            } else {
                latv = 0.0;
            }

            ga = ds.findVariable("longitude");

            if (ga != null) {
                lonv = ga.readScalarDouble();
            } else {
                lonv = 0.0;
            }

            ga = ds.findVariable("altitude");
            if (ga != null) {
                elev = ga.readScalarDouble();
            } else {
                elev = 0.0;
            }
        } catch (IOException e) {}

View Full Code Here

     * _more_
     *
     * @throws Exception _more_
     */
    protected void setTimeUnits() throws Exception {
        Variable t  = ds.findVariable("time");
        String   ut = t.getUnitsString();
        dateUnits = new DateUnit(ut);
    }
View Full Code Here

         */
        public float[] readAllData() throws IOException {
            Array    allData;
            Array    hrData    = null;
            Sweep    spn       = (Sweep) sweeps.get(0);
            Variable v         = spn.getsweepVar();

            int minRadial = getMinRadialNumber();
            int minRadials = minRadial * nsweeps;
            int radials = getNumRadials();
            int gates = range.length;
            try {
                allData = v.read();
            } catch (IOException e) {
                throw new IOException(e.getMessage());
            }
            if(minRadials == radials) {
                return (float []) allData.get1DJavaArray(float.class);
View Full Code Here

      lonVarName = "LON";
      elevVarName = "ALT";

      // Determine and set the units (base time) for the time variable.
      String baseTimeVarName = "base_time";
      Variable baseTimeVar = ncfile.findVariable( baseTimeVarName );
      int baseTime = baseTimeVar.readScalarInt();
      Date baseTimeDate;
      if ( baseTime != 0 )
      {
        String baseTimeString = baseTime + " seconds since 1970-01-01T00:00:00";
        baseTimeDate = DateUnit.getStandardDate( baseTimeString );
View Full Code Here

  }

  private boolean timeVarAllZeros() throws IOException
  {
    Variable curTimeVar = this.ncfile.getRootGroup().findVariable( timeVarName);
    List section = new ArrayList(1);
    Array a = null;
    try
    {
      section.add ( new Range( 0, 2));
      a = curTimeVar.read( section);
    }
    catch ( InvalidRangeException e )
    {
      throw new IOException( "Invalid range (0,2): " + e.getMessage());
    }
View Full Code Here

    return key;
  }

  static public String getVariableName(NetcdfDataset ds, String key, Formatter errlog) {
    Variable v = null;
    String vs = getLiteral(ds, key, errlog);
    if (vs != null) {
      v = ds.findVariable(vs);
      if ((v == null) && (errlog != null))
        errlog.format(" Cant find Variable %s from %s\n", vs, key);
    }
    return v == null ? null : v.getShortName();
  }
View Full Code Here

      if ((haveValue != null) && haveValue.equals(attValue))
        return v;
    }
    for (Variable v : ds.getVariables()) {
      if (v instanceof Structure) {
        Variable vn = getVariableWithAttribute((Structure)v, attName, attValue);
        if (null != vn) return vn;
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.Variable$Cache

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.