Package ucar.nc2

Examples of ucar.nc2.VariableSimpleIF


    assert dataClass == StationObsDatatype.class;

    List dataVars =  sod.getDataVariables();
    assert dataVars != null;
    for (int i = 0; i < dataVars.size(); i++) {
      VariableSimpleIF v = (VariableSimpleIF) dataVars.get(i);
      assert null != sod.getDataVariable( v.getShortName());
    }

    List stations = sod.getStations();
    assert null != stations;
    assert 0 < stations.size();
View Full Code Here


      List dataMembers = sdata.getMembers();
      assert dataMembers.size() >= dataVars.size();
      System.out.println(" dataMembers ="+dataMembers.size()+" dataVars= "+dataVars.size());

      for (int i = 0; i < dataVars.size(); i++) {
        VariableSimpleIF tdv = (VariableSimpleIF) dataVars.get(0);
        StructureMembers.Member member = members.findMember( tdv.getShortName());
        assert null != member : "cant find "+tdv.getShortName();

        member.getDataType().equals( tdv.getDataType());
        Array adata = sdata.getArray(member);
        adata.getShape().equals( member.getShape());
      }
    }
  }
View Full Code Here

    assert dataClass == PointObsDatatype.class;

    List dataVars =  pod.getDataVariables();
    assert dataVars != null;
    for (int i = 0; i < dataVars.size(); i++) {
      VariableSimpleIF v = (VariableSimpleIF) dataVars.get(i);
      assert null != pod.getDataVariable( v.getShortName());
    }

    // make a new bb
    LatLonRect bb = pod.getBoundingBox();
    assert null != bb;
View Full Code Here

    Range range = trajDt.getFullRange();
    startDate = System.currentTimeMillis();
    for ( Iterator it = trajDt.getDataVariables().iterator(); it.hasNext(); )
    {
      VariableSimpleIF var = (VariableSimpleIF) it.next();
      Array a = trajDt.getData( range, var.getShortName() );
    }
    endDate = System.currentTimeMillis();
    System.out.println( "Variable-oriented read of record written data: " + ( (endDate - startDate) / 1000.0 ) + " seconds" );

    // Read all data in point oriented manner.
    startDate = System.currentTimeMillis();
    for ( int i = 0; i < trajDt.getNumberPoints(); i++ )
    {
      StructureData structData = trajDt.getData( i );
    }
    endDate = System.currentTimeMillis();
    System.out.println( "Point-oriented read of record written data: " + ( ( endDate - startDate ) / 1000.0 ) + " seconds" );

    // Read all data in point oriented manner with iterator.
    startDate = System.currentTimeMillis();
    for ( DataIterator it = trajDt.getDataIterator( 0); it.hasNext(); )
    {
      PointObsDatatype pointOb = (PointObsDatatype) it.nextData();
    }
    endDate = System.currentTimeMillis();
    System.out.println( "Point-oriented iterator read of record written data: " + ( ( endDate - startDate ) / 1000.0 ) + " seconds" );

    //================ non-record written data ====================
    location = testFilePath + "/" + test_Raf_1_3_NoRecvar_FileName;
    assertTrue( "Test file <" + location + "> does not exist.",
                new File( location ).exists() );
    try
    {
      StringBuilder errlog = new StringBuilder();
      me = (TrajectoryObsDataset) TypedDatasetFactory.open(FeatureType.TRAJECTORY, location, null, errlog);
    }
    catch ( IOException e )
    {
      String tmpMsg = "Couldn't create TrajectoryObsDataset from RAF aircraft file <" + location + ">: " + e.getMessage();
      assertTrue( tmpMsg,
                  false );
    }
    assertTrue( "Null TrajectoryObsDataset after open <" + location + "> ",
                me != null );
    assertTrue( "Dataset <" + location + "> not a RafTrajectoryObsDataset.",
                me instanceof RafTrajectoryObsDataset );

    // Read all data in variable oriented manner.
    trajDt = me.getTrajectory( "1Hz data" );

    range = trajDt.getFullRange();
    startDate = System.currentTimeMillis();
    for ( Iterator it = trajDt.getDataVariables().iterator(); it.hasNext(); )
    {
      VariableSimpleIF var = (VariableSimpleIF) it.next();
      Array a = trajDt.getData( range, var.getShortName() );
    }
    endDate = System.currentTimeMillis();
    System.out.println( "Variable-oriented read of non-record written data: " + ( ( endDate - startDate ) / 1000.0 ) + " seconds" );

    // Read all data in point oriented manner.
View Full Code Here

    super.findCoordinateAxes(ds);
  }

  protected AxisType getAxisType( NetcdfDataset ncd, VariableEnhanced v) {

    AxisType atype = super.getAxisType(ncd, v);
    if (atype != null) return atype;

    String unit = v.getUnitsString();
    if (unit == null)
      return null;
View Full Code Here

    int count = 0;
    while (stoker.hasMoreTokens()) {
      String vname = stoker.nextToken();
      Variable v = ds.findVariable(vname);
      if (v != null) {
        AxisType atype = count == 0 ? AxisType.Lat : count == 1 ? AxisType.Lon : AxisType.Height;
        v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString()));
      } else {
        parseInfo.format(" cant find time variable %s\n",vname);
      }
      count++;
    }
View Full Code Here

    if (positive != null) {
      v.addAttribute(new Attribute("positive", positive));
    }

    if (units != null) {
      AxisType axisType;
      if (SimpleUnit.isCompatible("millibar", units)) {
        axisType = AxisType.Pressure;
      } else if (SimpleUnit.isCompatible("m", units)) {
        axisType = AxisType.Height;
      } else {
        axisType = AxisType.GeoZ;
      }

      if (lookup instanceof Grib2GridTableLookup || lookup instanceof Grib1GridTableLookup) {
        v.addAttribute(new Attribute("GRIB_level_type", Integer.toString(typicalRecord.getLevelType1())));
      } else {
        v.addAttribute(new Attribute("level_type", Integer.toString(typicalRecord.getLevelType1())));
      }
      v.addAttribute(new Attribute(_Coordinate.AxisType, axisType.toString()));
    }

    if (coordValues == null) {
      coordValues = new double[levels.size()];
      for (int i = 0; i < levels.size(); i++) {
View Full Code Here

      HashMap<AxisType, VarProcess> map = new HashMap<AxisType, VarProcess>();

      // find existing axes, so we dont duplicate
      for (VarProcess vp : varList) {
        if (vp.isCoordinateAxis) {
          AxisType atype = getAxisType(ds, (VariableEnhanced) vp.v);
          if (atype != null)
            map.put(atype, vp);
        }
      }

      // look for time axes based on units
      if (map.get(AxisType.Time) == null) {
        for (VarProcess vp : varList) {
          Variable ncvar = vp.v;
          if (!(ncvar instanceof VariableDS)) continue; // cant be a structure
          String unit = ncvar.getUnitsString();

          if (SimpleUnit.isDateUnit(unit)) {
            vp.isCoordinateAxis = true;
            map.put(AxisType.Time, vp);
            parseInfo.format(" Time Coordinate Axis added (unit) = %s from unit %s\n", vp.v.getFullName(), unit);
            //break; // allow multiple time coords
          }
        }
      }

      // look for missing axes by using name hueristics
      for (VarProcess vp : varList) {
        if (vp.isCoordinateVariable) continue;
        Variable ncvar = vp.v;
        if (!(ncvar instanceof VariableDS)) continue; // cant be a structure

        AxisType atype = getAxisType(ds, (VariableEnhanced) vp.v);
        if (atype != null) {
          if (map.get(atype) == null) {
            vp.isCoordinateAxis = true;
            parseInfo.format(" Coordinate Axis added (Default forced) = %s for axis %s\n", vp.v.getFullName(), atype);
            map.put(atype, vp);
View Full Code Here

      }
      super.makeCoordinateTransforms(ds);
    }

    protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) {
      AxisType result = getAxisTypeCoards(ds, ve);
      if (result != null) return result;

      Variable v = (Variable) ve;
      String vname = v.getShortName();
      String unit = v.getUnitsString();
View Full Code Here

    if (positive != null) {
      v.addAttribute(new Attribute("positive", positive));
    }

    if (units != null) {
      AxisType axisType;
      if (SimpleUnit.isCompatible("millibar", units)) {
        axisType = AxisType.Pressure;
      } else if (SimpleUnit.isCompatible("m", units)) {
        axisType = AxisType.Height;
      } else {
        axisType = AxisType.GeoZ;
      }

      v.addAttribute(
              new Attribute(
                      "grid_level_type",
                      Integer.toString(record.getLevelType1())));

      v.addAttribute(new Attribute(_Coordinate.AxisType,
              axisType.toString()));
      v.addAttribute(new Attribute(_Coordinate.Axes, dims));
      if (!hcs.isLatLon()) {
        v.addAttribute(new Attribute(_Coordinate.Transforms,
                hcs.getGridName()));
      }
View Full Code Here

TOP

Related Classes of ucar.nc2.VariableSimpleIF

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.