Java Code Examples for ucar.nc2.constants.AxisType#Lon

The following examples show how to use ucar.nc2.constants.AxisType#Lon . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jason2Convention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * _more_
 *
 * @param ncDataset _more_
 * @param v _more_
 *
 * @return _more_
 */
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) {
  String name = v.getShortName();
  if (name.equals("time")) {
    return AxisType.Time;
  }
  if (name.equals("lat")) {
    return AxisType.Lat;
  }
  if (name.equals("lon")) {
    return AxisType.Lon;
  }
  // if (name.equals("xLeo") ) return AxisType.GeoX;
  // if (name.equals("yLeo") ) return AxisType.GeoY;
  if (name.equals("alt")) {
    return AxisType.Height;
  }
  return null;
}
 
Example 2
Source File: Cosmic1Convention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) {
  String name = v.getShortName();
  if (name.equals("time")) {
    return AxisType.Time;
  }
  if (name.equals("Lat") || name.equals("GEO_lat")) {
    return AxisType.Lat;
  }
  if (name.equals("Lon") || name.equals("GEO_lon")) {
    return AxisType.Lon;
  }
  // if (name.equals("xLeo") ) return AxisType.GeoX;
  // if (name.equals("yLeo") ) return AxisType.GeoY;
  if (name.equals("MSL_alt")) {
    return AxisType.Height;
  }
  return null;
}
 
Example 3
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) {
  Variable v = (Variable) ve;
  String vname = v.getShortName();

  if (vname.equalsIgnoreCase("x"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("record"))
    return AxisType.Time;
  Dimension dim = v.getDimension(0);
  if ((dim != null) && dim.getShortName().equalsIgnoreCase("record"))
    return AxisType.Time;

  String unit = ve.getUnitsString();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;
  }


  return AxisType.GeoZ;
}
 
Example 4
Source File: NUWGConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) {
  Variable v = (Variable) ve;
  String vname = v.getShortName();

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase(xaxisName))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase(yaxisName))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("record"))
    return AxisType.Time;
  Dimension dim = v.getDimension(0);
  if ((dim != null) && dim.getShortName().equalsIgnoreCase("record")) { // wow thats bad!
    return AxisType.Time;
  }

  String unit = ve.getUnitsString();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;

    if (SimpleUnit.isCompatible("sec", unit))
      return null;
  }

  return AxisType.GeoZ; // AxisType.GeoZ;
}
 
Example 5
Source File: ADASConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) {
  Variable v = (Variable) ve;
  String vname = v.getShortName();

  if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag"))
    return AxisType.GeoZ;

  if (vname.equalsIgnoreCase("Z"))
    return AxisType.Height;

  if (vname.equalsIgnoreCase("time"))
    return AxisType.Time;

  String unit = ve.getUnitsString();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;
  }


  return null;
}
 
Example 6
Source File: AWIPSSatConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected AxisType getAxisType(VariableDS.Builder v) {
  String units = v.getUnits();

  if (units.equalsIgnoreCase(CDM.LON_UNITS))
    return AxisType.Lon;

  if (units.equalsIgnoreCase(CDM.LAT_UNITS))
    return AxisType.Lat;

  return super.getAxisType(v);
}
 
Example 7
Source File: NUWGConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected AxisType getAxisType(VariableDS.Builder v) {
  String vname = v.shortName;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase(xaxisName))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase(yaxisName))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("record"))
    return AxisType.Time;

  String dimName = v.getFirstDimensionName();
  if ((dimName != null) && dimName.equalsIgnoreCase("record")) { // wow thats bad!
    return AxisType.Time;
  }

  String unit = v.getUnits();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;

    if (SimpleUnit.isCompatible("sec", unit))
      return null;
  }

  return AxisType.GeoZ; // AxisType.GeoZ;
}
 
Example 8
Source File: GDVConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected AxisType getAxisType(VariableDS.Builder v) {
  String vname = v.shortName;

  if (vname.equalsIgnoreCase("x") || findAlias(v).equalsIgnoreCase("x"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon") || vname.equalsIgnoreCase("longitude") || findAlias(v).equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y") || findAlias(v).equalsIgnoreCase("y"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat") || vname.equalsIgnoreCase("latitude") || findAlias(v).equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("lev") || findAlias(v).equalsIgnoreCase("lev")
      || (vname.equalsIgnoreCase("level") || findAlias(v).equalsIgnoreCase("level")))
    return AxisType.GeoZ;

  if (vname.equalsIgnoreCase("z") || findAlias(v).equalsIgnoreCase("z")
      || (vname.equalsIgnoreCase("altitude") || vname.equalsIgnoreCase("depth")))
    return AxisType.Height;

  if (vname.equalsIgnoreCase("time") || findAlias(v).equalsIgnoreCase("time"))
    return AxisType.Time;

  return super.getAxisType(v);
}
 
Example 9
Source File: CoverageCoordAxis1D.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Optional<CoverageCoordAxis> subsetByIntervals(List<MAMath.MinMax> lonIntvs, int stride) {
  if (axisType != AxisType.Lon)
    return Optional.empty("subsetByIntervals only for longitude");
  if (!isRegular())
    return Optional.empty("subsetByIntervals only for regular longitude");

  // adjust the resolution of the subset based on stride
  double subsetResolution = stride > 1 ? stride * resolution : resolution;

  CoordAxisHelper helper = new CoordAxisHelper(this);

  double start = Double.NaN;
  boolean first = true;
  List<RangeIterator> ranges = new ArrayList<>();
  for (MAMath.MinMax lonIntv : lonIntvs) {
    if (first)
      start = lonIntv.min;
    first = false;

    Optional<RangeIterator> opt = helper.makeRange(lonIntv.min, lonIntv.max, stride);
    if (!opt.isPresent())
      return Optional.empty(opt.getErrorMessage());
    ranges.add(opt.get());
  }

  RangeComposite compositeRange = new RangeComposite(AxisType.Lon.toString(), ranges);
  // number of points in the subset
  int npts = compositeRange.length();
  // need to use the subset resolution to figure out the end
  double end = start + npts * subsetResolution;

  CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(this); // copy
  builder.subset(npts, start, end, subsetResolution, null);
  builder.setRange(null);
  builder.setCompositeRange(compositeRange);

  return Optional.of(new CoverageCoordAxis1D(builder));
}
 
Example 10
Source File: WRFConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) {
  Variable v = (Variable) ve;
  String vname = v.getShortName();

  if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag"))
    return AxisType.GeoZ;

  if (vname.equalsIgnoreCase("Z"))
    return AxisType.Height;

  if (vname.equalsIgnoreCase("time") || vname.equalsIgnoreCase("times"))
    return AxisType.Time;

  String unit = ve.getUnitsString();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;
  }


  return null;
}
 
Example 11
Source File: CSBuilderFallback.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Identifies what kind of axis the given variable is.
 */
@Override
protected AxisType getAxisType(final NetcdfDataset ds, final VariableEnhanced variable) {
    final String name = variable.getShortName();
    if (CharSequences.startsWith(name, "Longitude", true)) return AxisType.Lon;
    if (CharSequences.startsWith(name, "Latitude",  true)) return AxisType.Lat;
    return super.getAxisType(ds, variable);
}
 
Example 12
Source File: WRFConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
@Nullable
protected AxisType getAxisType(VariableDS.Builder v) {
  String vname = v.shortName;

  if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag"))
    return AxisType.GeoZ;

  if (vname.equalsIgnoreCase("Z"))
    return AxisType.Height;

  if (vname.equalsIgnoreCase("time") || vname.equalsIgnoreCase("times"))
    return AxisType.Time;

  String unit = v.getUnits();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;
  }


  return null;
}
 
Example 13
Source File: ADASConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected AxisType getAxisType(VariableDS.Builder vb) {
  String vname = vb.shortName;

  if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag"))
    return AxisType.GeoZ;

  if (vname.equalsIgnoreCase("Z"))
    return AxisType.Height;

  if (vname.equalsIgnoreCase("time"))
    return AxisType.Time;

  String unit = vb.getUnits();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;
  }


  return null;
}
 
Example 14
Source File: CdmrfReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static AxisType convertAxisType(CdmrFeatureProto.AxisType dtype) {
  switch (dtype) {
    case RunTime:
      return AxisType.RunTime;
    case Ensemble:
      return AxisType.Ensemble;
    case Time:
      return AxisType.Time;
    case GeoX:
      return AxisType.GeoX;
    case GeoY:
      return AxisType.GeoY;
    case GeoZ:
      return AxisType.GeoZ;
    case Lat:
      return AxisType.Lat;
    case Lon:
      return AxisType.Lon;
    case Height:
      return AxisType.Height;
    case Pressure:
      return AxisType.Pressure;
    case RadialAzimuth:
      return AxisType.RadialAzimuth;
    case RadialDistance:
      return AxisType.RadialDistance;
    case RadialElevation:
      return AxisType.RadialElevation;
    case Spectral:
      return AxisType.Spectral;
    case TimeOffset:
      return AxisType.TimeOffset;
  }
  throw new IllegalStateException("illegal data type " + dtype);
}
 
Example 15
Source File: COARDSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) {

    String unit = v.getUnitsString();
    if (unit == null)
      return null;
    unit = unit.trim();

    if (unit.equalsIgnoreCase("degrees_east") || unit.equalsIgnoreCase("degrees_E") || unit.equalsIgnoreCase("degreesE")
        || unit.equalsIgnoreCase("degree_east") || unit.equalsIgnoreCase("degree_E")
        || unit.equalsIgnoreCase("degreeE"))
      return AxisType.Lon;

    if (unit.equalsIgnoreCase("degrees_north") || unit.equalsIgnoreCase("degrees_N")
        || unit.equalsIgnoreCase("degreesN") || unit.equalsIgnoreCase("degree_north")
        || unit.equalsIgnoreCase("degree_N") || unit.equalsIgnoreCase("degreeN"))
      return AxisType.Lat;

    if (SimpleUnit.isDateUnit(unit)) {
      return AxisType.Time;
    }
    // look for other z coordinate
    if (SimpleUnit.isCompatible("mbar", unit))
      return AxisType.Pressure;
    if (unit.equalsIgnoreCase("level") || unit.equalsIgnoreCase("layer") || unit.equalsIgnoreCase("sigma_level"))
      return AxisType.GeoZ;

    String positive = ncDataset.findAttValueIgnoreCase((Variable) v, CF.POSITIVE, null);
    if (positive != null) {
      if (SimpleUnit.isCompatible("m", unit))
        return AxisType.Height;
      else
        return AxisType.GeoZ;
    }

    // a bad idea, but CDC SST relies on it :
    // :Source = "NOAA/National Climatic Data Center";
    // :Contact = "Dick Reynolds, email: [email protected] & Chunying Liu, email: [email protected]";
    // :netcdf_Convention = "COARDS";
    // if (checkForMeter && SimpleUnit.isCompatible("m", unit))
    // return AxisType.Height;

    return null;
  }
 
Example 16
Source File: DefaultConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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();
  if (vname == null)
    return null;
  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;

  if (vname.equalsIgnoreCase("lon") || vname.equalsIgnoreCase("longitude")
      || findAlias(ds, v).equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y") || findAlias(ds, v).equalsIgnoreCase("y"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat") || vname.equalsIgnoreCase("latitude") || findAlias(ds, v).equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("lev") || findAlias(ds, v).equalsIgnoreCase("lev")
      || (vname.equalsIgnoreCase("level") || findAlias(ds, v).equalsIgnoreCase("level")))
    return AxisType.GeoZ;

  if (vname.equalsIgnoreCase("z") || findAlias(ds, v).equalsIgnoreCase("z") || vname.equalsIgnoreCase("altitude")
      || desc.contains("altitude") || vname.equalsIgnoreCase("depth") || vname.equalsIgnoreCase("elev")
      || vname.equalsIgnoreCase("elevation")) {
    if (SimpleUnit.isCompatible("m", unit)) // units of meters
      return AxisType.Height;
  }

  if (vname.equalsIgnoreCase("time") || findAlias(ds, v).equalsIgnoreCase("time")) {
    if (SimpleUnit.isDateUnit(unit))
      return AxisType.Time;
  }

  if (vname.equalsIgnoreCase("time") && v.getDataType() == DataType.STRING) {
    try {
      Array firstValue = v.read("0");
      if (firstValue instanceof ArrayObject.D1) {
        ArrayObject.D1 sarry = (ArrayObject.D1) firstValue;
        String firstStringValue = (String) sarry.get(0);
        if (CalendarDate.parseISOformat(null, firstStringValue) != null) // valid iso date string
          return AxisType.Time;
      }
    } catch (IOException | InvalidRangeException e) {
      logger.warn("time string error", e);
    }
  }

  return null;
}
 
Example 17
Source File: CoordinateSystem.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected CoordinateSystem(Builder<?> builder, NetcdfDataset ncd, List<CoordinateAxis> axes,
    List<CoordinateTransform> allTransforms) {
  this.ds = ncd;
  this.isImplicit = builder.isImplicit;

  // find referenced coordinate axes
  List<CoordinateAxis> axesList = new ArrayList<>();
  StringTokenizer stoker = new StringTokenizer(builder.coordAxesNames);
  while (stoker.hasMoreTokens()) {
    String vname = stoker.nextToken();
    for (CoordinateAxis a : axes) {
      String aname = a.getFullName();
      if (aname.equals(vname)) {
        axesList.add(a);
      }
    }
  }
  this.coordAxes = axesList;

  // calculated
  this.name = makeName(coordAxes);

  for (CoordinateAxis axis : this.coordAxes) {
    // look for AxisType
    AxisType axisType = axis.getAxisType();
    if (axisType != null) {
      if (axisType == AxisType.GeoX)
        xAxis = lesserRank(xAxis, axis);
      if (axisType == AxisType.GeoY)
        yAxis = lesserRank(yAxis, axis);
      if (axisType == AxisType.GeoZ)
        zAxis = lesserRank(zAxis, axis);
      if (axisType == AxisType.Time)
        tAxis = lesserRank(tAxis, axis);
      if (axisType == AxisType.Lat)
        latAxis = lesserRank(latAxis, axis);
      if (axisType == AxisType.Lon)
        lonAxis = lesserRank(lonAxis, axis);
      if (axisType == AxisType.Height)
        hAxis = lesserRank(hAxis, axis);
      if (axisType == AxisType.Pressure)
        pAxis = lesserRank(pAxis, axis);
      if (axisType == AxisType.Ensemble)
        ensAxis = lesserRank(ensAxis, axis);

      if (axisType == AxisType.RadialAzimuth)
        aziAxis = lesserRank(aziAxis, axis);
      if (axisType == AxisType.RadialDistance)
        radialAxis = lesserRank(radialAxis, axis);
      if (axisType == AxisType.RadialElevation)
        elevAxis = lesserRank(elevAxis, axis);
    }
    // collect dimensions
    List<Dimension> dims = axis.getDimensionsAll();
    domain.addAll(dims);
  }

  // Find the named coordinate transforms in allTransforms.
  for (String wantTransName : builder.transNames) {
    CoordinateTransform got = allTransforms.stream()
        .filter(ct -> (wantTransName.equals(ct.getName())
            || ct.getAttributeContainer() != null && wantTransName.equals(ct.getAttributeContainer().getName())))
        .findFirst().orElse(null);
    if (got != null) {
      coordTrans.add(got);
    }

  }
}
 
Example 18
Source File: CoardsConventions.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
@Nullable
protected AxisType getAxisType(VariableDS.Builder vb) {
  String unit = vb.getUnits();
  if (unit == null) {
    return null;
  }
  unit = unit.trim();

  if (unit.equalsIgnoreCase("degrees_east") || unit.equalsIgnoreCase("degrees_E") || unit.equalsIgnoreCase("degreesE")
      || unit.equalsIgnoreCase("degree_east") || unit.equalsIgnoreCase("degree_E")
      || unit.equalsIgnoreCase("degreeE")) {
    return AxisType.Lon;
  }

  if (unit.equalsIgnoreCase("degrees_north") || unit.equalsIgnoreCase("degrees_N")
      || unit.equalsIgnoreCase("degreesN") || unit.equalsIgnoreCase("degree_north")
      || unit.equalsIgnoreCase("degree_N") || unit.equalsIgnoreCase("degreeN")) {
    return AxisType.Lat;
  }

  if (SimpleUnit.isDateUnit(unit)) {
    return AxisType.Time;
  }
  // look for other z coordinate
  if (SimpleUnit.isCompatible("mbar", unit)) {
    return AxisType.Pressure;
  }
  if (unit.equalsIgnoreCase("level") || unit.equalsIgnoreCase("layer") || unit.equalsIgnoreCase("sigma_level")) {
    return AxisType.GeoZ;
  }

  String positive = vb.getAttributeContainer().findAttributeString(CF.POSITIVE, null);
  if (positive != null) {
    if (SimpleUnit.isCompatible("m", unit)) {
      return AxisType.Height;
    } else {
      return AxisType.GeoZ;
    }
  }

  // a bad idea, but CDC SST relies on it :
  // :Source = "NOAA/National Climatic Data Center";
  // :Contact = "Dick Reynolds, email: [email protected] & Chunying Liu, email: [email protected]";
  // :netcdf_Convention = "COARDS";
  // if (checkForMeter && SimpleUnit.isCompatible("m", unit))
  // return AxisType.Height;

  return null;
}
 
Example 19
Source File: AWIPSsatConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) {
  Variable v = (Variable) ve;
  String vname = v.getShortName();
  String units = v.getUnitsString();

  if (units.equalsIgnoreCase(CDM.LON_UNITS))
    return AxisType.Lon;

  if (units.equalsIgnoreCase(CDM.LAT_UNITS))
    return AxisType.Lat;


  if (vname.equalsIgnoreCase("x"))
    return AxisType.GeoX;

  if (vname.equalsIgnoreCase("lon"))
    return AxisType.Lon;

  if (vname.equalsIgnoreCase("y"))
    return AxisType.GeoY;

  if (vname.equalsIgnoreCase("lat"))
    return AxisType.Lat;

  if (vname.equalsIgnoreCase("record"))
    return AxisType.Time;
  Dimension dim = v.getDimension(0);
  if ((dim != null) && dim.getShortName().equalsIgnoreCase("record"))
    return AxisType.Time;

  String unit = ve.getUnitsString();
  if (unit != null) {
    if (SimpleUnit.isCompatible("millibar", unit))
      return AxisType.Pressure;

    if (SimpleUnit.isCompatible("m", unit))
      return AxisType.Height;
  }

  return AxisType.GeoZ;
}
 
Example 20
Source File: PointDatasetStandardFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Check if this is a POINT datatype. If so, a TableAnalyser is used to analyze its structure.
 * The TableAnalyser is reused when the dataset is opened.
 * <ol>
 * <li>Can handle ANY_POINT FeatureType.
 * <li>Must have time, lat, lon axis (from CoordSysBuilder)
 * <li>Call TableAnalyzer.factory() to create a TableAnalyzer
 * <li>TableAnalyzer must agree it can handle the requested FeatureType
 * </ol>
 *
 * @param wantFeatureType desired feature type, null means FeatureType.ANY_POINT
 * @param ds analyse this dataset
 * @param errlog log error messages here (may not be null)
 * @return if successful, return non-null. This object is then passed back into open(), so analysis can be reused.
 */
@Override
public Object isMine(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
  if (wantFeatureType == null)
    wantFeatureType = FeatureType.ANY_POINT;
  if (wantFeatureType != FeatureType.ANY_POINT) {
    if (!wantFeatureType.isPointFeatureType())
      return null;
  }

  TableConfigurer tc = TableAnalyzer.getTableConfigurer(wantFeatureType, ds);

  // if no explicit tc, then check whatever we can before expensive analysis)
  if (tc == null) {
    boolean hasTime = false;
    boolean hasLat = false;
    boolean hasLon = false;
    for (CoordinateAxis axis : ds.getCoordinateAxes()) {
      if (axis.getAxisType() == AxisType.Time) // && (axis.getRank() == 1))
        hasTime = true;
      if (axis.getAxisType() == AxisType.Lat) // && (axis.getRank() == 1))
        hasLat = true;
      if (axis.getAxisType() == AxisType.Lon) // && (axis.getRank() == 1))
        hasLon = true;
    }

    // minimum we need
    if (!(hasTime && hasLon && hasLat)) {
      errlog.format("PointDataset must have lat,lon,time");
      return null;
    }
  } else if (showTables) {
    System.out.printf("TableConfigurer = %s%n", tc.getClass().getName());
  }

  try {
    // gotta do some work
    TableAnalyzer analyser = TableAnalyzer.factory(tc, wantFeatureType, ds);
    if (analyser == null)
      return null;

    if (!analyser.featureTypeOk(wantFeatureType, errlog)) {
      return null;
    }
    return analyser;

  } catch (Throwable t) {
    return null;
  }
}