ucar.nc2.dataset
Class CoordinateAxis

java.lang.Object
  extended by ucar.nc2.Variable
      extended by ucar.nc2.dataset.VariableDS
          extended by ucar.nc2.dataset.CoordinateAxis
All Implemented Interfaces:
java.lang.Comparable<VariableSimpleIF>, Enhancements, EnhanceScaleMissing, VariableEnhanced, VariableIF, VariableSimpleIF
Direct Known Subclasses:
CoordinateAxis1D, CoordinateAxis2D

public class CoordinateAxis
extends VariableDS

A Coordinate Axis is a Variable that specifies one of the coordinates of a CoordinateSystem. Mathematically it is a scalar function F from index space to S:

  F:D -> S
  where D is a product set of dimensions (aka index space), and S is the set of reals (R) or Strings.
 

If its element type is char, it is considered a string-valued Coordinate Axis and rank is reduced by one, since the outermost dimension is considered the string length: v(i, j, .., strlen). If its element type is String, it is a string-valued Coordinate Axis. Otherwise it is numeric-valued, and isNumeric() is true.

The one-dimensional case F(i) -> R is the common case which affords important optimizations. In that case, use the subtype CoordinateAxis1D. The factory methods will return either a CoordinateAxis1D if the variable is one-dimensional, a CoordinateAxis2D if its 2D, or a CoordinateAxis for the general case.

A CoordinateAxis is optionally marked as georeferencing with an AxisType. It should have a units string and optionally a description string.

A Structure cannot be a CoordinateAxis, although members of Structures can.

Author:
john caron

Nested Class Summary
static class CoordinateAxis.AxisComparator
          Standard sort on Coordinate Axes
 
Field Summary
 
Fields inherited from class ucar.nc2.Variable
defaultSizeToCache
 
Constructor Summary
CoordinateAxis(NetcdfDataset ds, Group group, java.lang.String shortName, DataType dataType, java.lang.String dims, java.lang.String units, java.lang.String desc)
          Constructor when theres no underlying variable.
 
Method Summary
 CoordinateAxis copyNoCache()
          Make a copy, with an independent cache.
 boolean equals(java.lang.Object oo)
          Instances which have same content are equal.
static CoordinateAxis factory(NetcdfDataset ncd, VariableDS vds)
          Create a coordinate axis from an existing Variable.
 AxisType getAxisType()
          Get type of axis
 java.lang.String getBoundaryRef()
          The name of this coordinate axis' boundary variable
 void getInfo(java.lang.StringBuilder buf)
          Get a string representation
 double getMaxValue()
          The largest coordinate value.
 double getMinValue()
          The smallest coordinate value.
 java.lang.String getPositive()
          Get the direction of increasing values, used only for vertical Axes.
 java.lang.String getUnitsString()
          Get the Unit String for the Variable.
 int hashCode()
          Override Object.hashCode() to implement equals.
 boolean isContiguous()
          If the edges are contiguous or disjoint Caution: many datasets do not explicitly specify this info, this is often a guess; default is true.
 boolean isNumeric()
          Does the axis have numeric values.
 void setAxisType(AxisType axisType)
          Set type of axis, or null if none.
 void setBoundaryRef(java.lang.String boundaryRef)
          Set a reference to a boundary variable.
 void setContiguous(boolean isContiguous)
          Set if the edges are contiguous or disjoint.
 void setPositive(java.lang.String positive)
          Set the direction of increasing values, used only for vertical Axes.
 
Methods inherited from class ucar.nc2.dataset.VariableDS
addCoordinateSystem, clearCoordinateSystems, convertScaleOffsetMissing, convertScaleOffsetMissing, convertScaleOffsetMissing, convertScaleOffsetMissing, convertScaleOffsetMissing, convertScaleOffsetMissing, enhance, getCoordinateSystems, getDescription, getOriginalDataType, getOriginalName, getOriginalVariable, getProxyReader, getUseNaNs, getValidMax, getValidMin, hasFillValue, hasInvalidData, hasMissing, hasMissingValue, hasScaleOffset, isFillValue, isInvalidData, isMissing, isMissingFast, isMissingValue, lookupEnumString, removeCoordinateSystem, setFillValueIsMissing, setInvalidDataIsMissing, setMissingDataIsMissing, setName, setOriginalVariable, setProxyReader, setUnitsString, setUseNaNs, toStringDebug
 
Methods inherited from class ucar.nc2.Variable
addAttribute, compareTo, createNewCache, findAttribute, findAttributeIgnoreCase, findDimensionIndex, getAttributes, getDataType, getDimension, getDimensions, getDimensionsAll, getDimensionsString, getElementSize, getName, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameEscaped, getParentGroup, getParentStructure, getRanges, getRank, getShape, getShape, getShapeAsSection, getShortName, getSize, getSizeToCache, getSPobject, hasCachedData, invalidateCache, isCaching, isCoordinateVariable, isImmutable, isMemberOfStructure, isMetadata, isScalar, isUnknownLength, isUnlimited, isUnsigned, isVariableLength, read, read, read, read, read, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, readToByteChannel, remove, removeAttribute, removeAttributeIgnoreCase, resetDimensions, resetShape, section, section, setCachedData, setCaching, setDataType, setDimension, setDimensions, setDimensions, setDimensionsAnonymous, setElementSize, setEnumTypedef, setImmutable, setIsScalar, setParentGroup, setParentStructure, setSizeToCache, setSPobject, slice, toString, writeCDL
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucar.nc2.VariableIF
findAttribute, findAttributeIgnoreCase, findDimensionIndex, getAttributes, getDataType, getDimension, getDimensions, getDimensionsAll, getElementSize, getName, getNameAndDimensions, getNameEscaped, getParentGroup, getParentStructure, getRanges, getRank, getShape, getShapeAsSection, getShortName, getSize, isCoordinateVariable, isMemberOfStructure, isMetadata, isScalar, isUnlimited, isUnsigned, isVariableLength, read, read, read, read, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, section
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

CoordinateAxis

public CoordinateAxis(NetcdfDataset ds,
                      Group group,
                      java.lang.String shortName,
                      DataType dataType,
                      java.lang.String dims,
                      java.lang.String units,
                      java.lang.String desc)
Constructor when theres no underlying variable. You better set the values too!

Parameters:
ds - the containing dataset.
group - the containing group; if null, use rootGroup
shortName - axis name.
dataType - data type
dims - list of dimension names
units - units of coordinates, preferably udunit compatible.
desc - long name.
Method Detail

factory

public static CoordinateAxis factory(NetcdfDataset ncd,
                                     VariableDS vds)
Create a coordinate axis from an existing Variable.

Parameters:
ncd - the containing dataset
vds - an existing Variable in dataset.
Returns:
CoordinateAxis or one of its subclasses (CoordinateAxis1D, CoordinateAxis2D, or CoordinateAxis1DTime).

copyNoCache

public CoordinateAxis copyNoCache()
Make a copy, with an independent cache.

Returns:
copy of this CoordinateAxis

getAxisType

public AxisType getAxisType()
Get type of axis

Returns:
type of axis, or null if none.

setAxisType

public void setAxisType(AxisType axisType)
Set type of axis, or null if none. Default is none.

Parameters:
axisType - set to this value

getUnitsString

public java.lang.String getUnitsString()
Description copied from class: Variable
Get the Unit String for the Variable. Looks for the "units" attribute value

Specified by:
getUnitsString in interface Enhancements
Specified by:
getUnitsString in interface VariableIF
Specified by:
getUnitsString in interface VariableSimpleIF
Overrides:
getUnitsString in class VariableDS
Returns:
unit string, or null if not found.

isNumeric

public boolean isNumeric()
Does the axis have numeric values.

Returns:
true if the CoordAxis is numeric, false if its string valued ("nominal").

isContiguous

public boolean isContiguous()
If the edges are contiguous or disjoint Caution: many datasets do not explicitly specify this info, this is often a guess; default is true.

Returns:
true if the edges are contiguous or false if disjoint. Assumed true unless set otherwise.

setContiguous

public void setContiguous(boolean isContiguous)
Set if the edges are contiguous or disjoint.

Parameters:
isContiguous - true if the adjacent edges touch

getPositive

public java.lang.String getPositive()
Get the direction of increasing values, used only for vertical Axes.

Returns:
POSITIVE_UP, POSITIVE_DOWN, or null if unknown.

setPositive

public void setPositive(java.lang.String positive)
Set the direction of increasing values, used only for vertical Axes.

Parameters:
positive - POSITIVE_UP, POSITIVE_DOWN, or null if you dont know..

getBoundaryRef

public java.lang.String getBoundaryRef()
The name of this coordinate axis' boundary variable

Returns:
the name of this coordinate axis' boundary variable, or null if none.

setBoundaryRef

public void setBoundaryRef(java.lang.String boundaryRef)
Set a reference to a boundary variable.

Parameters:
boundaryRef - the name of a boundary coordinate variable in the same dataset.

getMinValue

public double getMinValue()
The smallest coordinate value. Only call if isNumeric.

Returns:
the minimum coordinate value

getMaxValue

public double getMaxValue()
The largest coordinate value. Only call if isNumeric.

Returns:
the maximum coordinate value

getInfo

public void getInfo(java.lang.StringBuilder buf)
Get a string representation

Parameters:
buf - place info here

equals

public boolean equals(java.lang.Object oo)
Instances which have same content are equal.

Overrides:
equals in class Variable

hashCode

public int hashCode()
Override Object.hashCode() to implement equals.

Overrides:
hashCode in class Variable