Package ucar.nc2.constants

Examples of ucar.nc2.constants.AxisType


   */
  public AtmosLnPressure(NetcdfFile ds, Dimension timeDim, List<Parameter> params) {
    super(timeDim);

    String p0name = getParameterStringValue(params, P0);
    Variable p0var = ds.findVariable(p0name);
    double p0;
    try {
      p0 = p0var.readScalarDouble();
    } catch (IOException e) {
      throw new IllegalArgumentException("AtmosLnPressure failed to read "
          + p0name + " err= " + e.getMessage());
    }

    String levName = getParameterStringValue(params, LEV);
    Variable levVar = ds.findVariable(levName);

    try {
      Array lev = levVar.read();
      assert lev.getRank() == 1;
      pressure = new ArrayDouble.D1( (int) lev.getSize());
      IndexIterator ii = pressure.getIndexIterator();
      while (lev.hasNext()) {
        double result = p0 * Math.exp(-lev.nextDouble());
 
View Full Code Here


    if (flatten) {
      ArrayStructure as = (ArrayStructure) data;

      // make list of names
      List<String> names = new ArrayList<String>();
      Variable nested = v;
      while (nested.isMemberOfStructure()) {
        names.add( 0, nested.getShortName());
        nested = nested.getParentStructure();
      }

      StructureMembers.Member m = findNested(as, names, v.getShortName());
      Array mdata = (Array) m.getDataArray();
      if (mdata instanceof ArraySequenceNested) {
View Full Code Here

    protected void findCoordinateAxes(NetcdfDataset ds) {

      for (VarProcess vp : varList) {
        if (vp.isCoordinateVariable) continue;

        Variable ncvar = vp.v;
        if (!(ncvar instanceof VariableDS)) continue; // cant be a structure

        String dimName = findAlias(ds, ncvar);
        if (dimName.length() == 0) // none
          continue;
        Dimension dim = ds.findDimension(dimName);
        if (null != dim) {
          vp.isCoordinateAxis = true;
          parseInfo.format(" Coordinate Axis added (alias) = %s for dimension %s\n", vp.v.getFullName(), dimName);
        }
      }

      // coordinates is an alias for _CoordinateAxes
      for (VarProcess vp : varList) {
        if (vp.coordAxes == null) { // dont override if already set
          String coordsString = ds.findAttValueIgnoreCase(vp.v, "coordinates", null);
          if (coordsString != null) {
            vp.coordinates = coordsString;
          }
        }
      }

      super.findCoordinateAxes(ds);

      /////////////////////////
      // now we start forcing
      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) {
View Full Code Here

    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();
      if (unit == null) unit = "";
      String desc = v.getDescription();
      if (desc == null) desc = "";

      if (vname.equalsIgnoreCase("x") || findAlias(ds, v).equalsIgnoreCase("x"))
        return AxisType.GeoX;
View Full Code Here

   * @return true if we think this is a ATDRadarConvention file.
   */
  public static boolean isMine(NetcdfFile ncfile) {
    // not really sure until we can examine more files
    Dimension s = ncfile.findDimension("cedric_general_scaling_factor");
    Variable v = ncfile.findVariable("cedric_run_date");
    if(v != null && s != null)
        return true;
    else
        return false;
  }
View Full Code Here

    ct.addAttribute( new Attribute(_Coordinate.TransformType, "Projection"));
    ct.addAttribute( new Attribute(_Coordinate.Axes, "GeoX GeoY"));
    ncDataset.addVariable(null, ct);
  */
        NcMLReader.wrapNcMLresource(ncDataset, CoordSysBuilder.resourcesDir + "CEDRICRadar.ncml", cancelTask);
        Variable lat = ncDataset.findVariable("radar_latitude");
        Variable lon = ncDataset.findVariable("radar_longitude");
        float    latv = (float)lat.readScalarDouble();
        float    lonv = (float)lon.readScalarDouble();
        Variable pv = ncDataset.findVariable("Projection");
        pv.addAttribute(new Attribute("longitude_of_projection_origin", lonv) );
        pv.addAttribute(new Attribute("latitude_of_projection_origin", latv) );

        Variable sdate = ncDataset.findVariable("start_date");
        Variable stime = ncDataset.findVariable("start_time");
        Variable tvar = ncDataset.findVariable("time");
        String dateStr = sdate.readScalarString();
        String timeStr = stime.readScalarString();
        Date dt = null;
        try {
          dt = DateUtil.parse(dateStr + " " + timeStr);
        } catch (Exception e) {}

        int nt = 1;

        ArrayDouble.D1 data = new ArrayDouble.D1(nt);

        data.setDouble(0, dt.getTime()/1000);

        tvar.setCachedData(data, false);

        super.augmentDataset(ncDataset, cancelTask);

   //     System.out.println("here\n");

View Full Code Here

    // do we need to version this ?
    // String version =  ds.findAttValueIgnoreCase(null, "version", null);

    if (!hasTime) {
      Variable time = ds.findVariable("time_offset");
      if (time != null) {
        Variable base = ds.findVariable("base_time");
        int base_time = base.readScalarInt();
        try {
          DateUnit dunit = new DateUnit("seconds since 1970-01-01 00:00");
          String time_units = "seconds since " + dunit.makeStandardDateString(base_time);
          time.addAttribute(new Attribute("units", time_units));
          time.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.name()));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    // look for coordinates
    String coordinates = ds.findAttValueIgnoreCase(null, "coordinates", null);
    if (coordinates != null) {
      String[] vars = coordinates.split(" ");
      for (String vname : vars) {
        Variable v = ds.findVariable(vname);
        if (v != null) {
          AxisType atype = getAxisType(ds, (VariableEnhanced) v);
          if (atype != null)
            v.addAttribute(new Attribute(_Coordinate.AxisType, atype.name()));
        }
      }
    }

  }
View Full Code Here

    }

  }

  private boolean setAxisType(NetcdfDataset ds, String varName, AxisType atype) {
    Variable v = ds.findVariable(varName);
    if (v == null) return false;

    v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString()));
    return true;
  }
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

TOP

Related Classes of ucar.nc2.constants.AxisType

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.