Package ucar.nc2.dataset
Class CoordinateAxis
- java.lang.Object
-
- ucar.nc2.CDMNode
-
- ucar.nc2.Variable
-
- ucar.nc2.dataset.VariableDS
-
- ucar.nc2.dataset.CoordinateAxis
-
- All Implemented Interfaces:
Comparable<VariableSimpleIF>
,Iterable<Attribute>
,IsMissingEvaluator
,AttributeContainer
,Enhancements
,EnhanceScaleMissingUnsigned
,VariableEnhanced
,ProxyReader
,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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CoordinateAxis.AxisComparator
Standard sort on Coordinate Axesstatic class
CoordinateAxis.Builder<T extends CoordinateAxis.Builder<T>>
-
Nested classes/interfaces inherited from class ucar.nc2.Variable
Variable.Cache
-
-
Field Summary
Fields Modifier and Type Field Description protected AxisType
axisType
protected String
boundaryRef
protected boolean
isContiguous
protected NetcdfDataset
ncd
protected String
positive
-
Fields inherited from class ucar.nc2.dataset.VariableDS
orgDataType, orgName, orgVar
-
Fields inherited from class ucar.nc2.Variable
attributes, cache, dataType, debugCaching, defaultCoordsSizeToCache, defaultSizeToCache, dimensions, elementSize, hashCode, isVariableLength, ncfile, permitCaching, proxyReader, shape, sizeToCache, spiObject
-
Fields inherited from class ucar.nc2.CDMNode
annotations, dodsname, group, immutable, parentstruct, shortName, sort
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CoordinateAxis(CoordinateAxis.Builder<?> builder, Group parentGroup)
protected
CoordinateAxis(NetcdfDataset ncd, VariableDS vds)
Deprecated.Use CoordinateAxis.builder()CoordinateAxis(NetcdfDataset ds, Group group, String shortName, DataType dataType, String dims, String units, String desc)
Deprecated.Use CoordinateAxis.builder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected CoordinateAxis.Builder<?>
addLocalFieldsToBuilder(CoordinateAxis.Builder<? extends CoordinateAxis.Builder<?>> b)
static CoordinateAxis.Builder<?>
builder()
Get Builder for this class that allows subclassing.protected CoordinateAxis
copy()
Deprecated.UsetoBuilder()
CoordinateAxis
copyNoCache()
Make a copy, with an independent cache.boolean
equals(Object oo)
Instances which have same content are equal.static CoordinateAxis
factory(NetcdfDataset ncd, VariableDS vds)
Deprecated.Use CoordinateAxis.fromVariableDS()static CoordinateAxis.Builder
fromVariableDS(VariableDS.Builder<?> vdsBuilder)
Create a coordinate axis from an existing Variable.Builder.AxisType
getAxisType()
Get type of axisString
getBoundaryRef()
The name of this coordinate axis' boundary variableCalendar
getCalendarFromAttribute()
void
getInfo(Formatter buf)
Get a string representationdouble
getMaxValue()
The largest coordinate value.double
getMinValue()
The smallest coordinate value.String
getPositive()
Get the direction of increasing values, used only for vertical Axes.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
isIndependentCoordinate()
boolean
isInterval()
An interval coordinate consists of two numbers, bound1 and bound2.boolean
isNumeric()
Does the axis have numeric values.void
setAxisType(AxisType axisType)
Deprecated.Use CoordinateAxis.builder()void
setBoundaryRef(String boundaryRef)
Deprecated.Use CoordinateAxis.builder()void
setPositive(String positive)
Deprecated.Use CoordinateAxis.builder()CoordinateAxis.Builder<?>
toBuilder()
Turn into a mutable Builder.-
Methods inherited from class ucar.nc2.dataset.VariableDS
_read, _read, addCoordinateSystem, addEnhancement, addLocalFieldsToBuilder, applyScaleOffset, applyScaleOffset, clearCoordinateSystems, convert, convertMissing, convertMissing, convertUnsigned, convertUnsigned, convertUnsigned, enhance, fillValueIsMissing, getCoordinateSystems, getDatasetLocation, getDescription, getEnhanceMode, getFillValue, getMissingDataArray, getMissingValues, getNetcdfFile, getOffset, getOriginalDataType, getOriginalName, getOriginalVariable, getScaledOffsetType, getScaleFactor, getSignedness, getUnsignedConversionType, getValidMax, getValidMin, hasCachedDataRecurse, hasFillValue, hasMissing, hasMissingValue, hasScaleOffset, hasValidData, invalidDataIsMissing, isFillValue, isInvalidData, isMissing, isMissingValue, lookupEnumString, missingDataIsMissing, readToStream, reallyRead, reallyRead, removeCoordinateSystem, removeEnhancement, setCaching, setFillValueIsMissing, setInvalidDataIsMissing, setMissingDataIsMissing, setName, setOriginalVariable, setUnitsString, showScaleMissingProxy, toStringDebug
-
Methods inherited from class ucar.nc2.Variable
_readScalarData, addAll, addAttribute, addLocalFieldsToBuilder, attributes, compareTo, createNewCache, extraInfo, findAttribute, findAttributeDouble, findAttributeIgnoreCase, findAttributeInteger, findAttributeString, findDimensionIndex, getAttributes, getDAPName, getDAPName, getDataType, getDimension, getDimensions, getDimensionsAll, getDimensionsString, getElementSize, getEnumTypedef, getFileTypeId, getFullName, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getParentGroup, getParentGroupOrRoot, getParentStructure, getProxyReader, getRanges, getRank, getScalarData, getShape, getShape, getShapeAll, getShapeAsSection, getSize, getSizeToCache, getSPobject, hasCachedData, invalidateCache, isCaching, isCoordinateVariable, isEmpty, isImmutable, isMemberOfStructure, isMetadata, isScalar, isUnknownLength, isUnlimited, isVariableLength, read, read, read, read, read, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, readToByteChannel, reduce, remove, removeAttribute, removeAttributeIgnoreCase, resetDimensions, resetShape, section, section, setCachedData, setCachedData, setDataType, setDimension, setDimensions, setDimensions, setDimensionsAnonymous, setElementSize, setEnumTypedef, setImmutable, setIsScalar, setParentGroup, setProxyReader, setSizeToCache, setSPobject, setValues, setValues, slice, toString, writeCDL, writeCDL
-
Methods inherited from class ucar.nc2.CDMNode
annotate, annotation, getDODSName, getFullNameEscaped, getGroup, getImmutable, getName, getShortName, getSort, localhash, setDODSName, setParentStructure, setShortName, setSort, unwrap
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ucar.nc2.AttributeContainer
findAttValueIgnoreCase, getName, hasAttribute, hasAttributeIgnoreCase, iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface ucar.nc2.dataset.VariableEnhanced
getFullName, getShortName
-
Methods inherited from interface ucar.nc2.VariableSimpleIF
getName, getShortName
-
-
-
-
Field Detail
-
ncd
protected NetcdfDataset ncd
-
axisType
protected AxisType axisType
-
positive
protected String positive
-
boundaryRef
protected String boundaryRef
-
isContiguous
protected boolean isContiguous
-
-
Constructor Detail
-
CoordinateAxis
@Deprecated protected CoordinateAxis(NetcdfDataset ncd, VariableDS vds)
Deprecated.Use CoordinateAxis.builder()Create a coordinate axis from an existing Variable. General case.- Parameters:
ncd
- the containing datasetvds
- an existing Variable
-
CoordinateAxis
@Deprecated public CoordinateAxis(NetcdfDataset ds, Group group, String shortName, DataType dataType, String dims, String units, String desc)
Deprecated.Use CoordinateAxis.builder()Constructor when theres no underlying variable. You better set the values too!- Parameters:
ds
- the containing dataset.group
- the containing group; if null, use rootGroupshortName
- axis name.dataType
- data typedims
- list of dimension namesunits
- units of coordinates, preferably udunit compatible.desc
- long name.
-
CoordinateAxis
protected CoordinateAxis(CoordinateAxis.Builder<?> builder, Group parentGroup)
-
-
Method Detail
-
factory
@Deprecated public static CoordinateAxis factory(NetcdfDataset ncd, VariableDS vds)
Deprecated.Use CoordinateAxis.fromVariableDS()Create a coordinate axis from an existing Variable.- Parameters:
ncd
- the containing datasetvds
- an existing Variable in dataset.- Returns:
- CoordinateAxis or one of its subclasses (CoordinateAxis1D, CoordinateAxis2D, or CoordinateAxis1DTime).
-
fromVariableDS
public static CoordinateAxis.Builder fromVariableDS(VariableDS.Builder<?> vdsBuilder)
Create a coordinate axis from an existing Variable.Builder.- Parameters:
vdsBuilder
- 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
-
copy
@Deprecated protected CoordinateAxis copy()
Deprecated.UsetoBuilder()
- Overrides:
copy
in classVariableDS
-
getAxisType
public AxisType getAxisType()
Get type of axis- Returns:
- type of axis, or null if none.
-
setAxisType
@Deprecated public void setAxisType(AxisType axisType)
Deprecated.Use CoordinateAxis.builder()Set type of axis, or null if none. Default is none.- Parameters:
axisType
- set to this value
-
getUnitsString
public String getUnitsString()
Description copied from class:Variable
Get the Unit String for the Variable. Looks for the CDM.UNITS attribute value- Specified by:
getUnitsString
in interfaceEnhancements
- Specified by:
getUnitsString
in interfaceVariableSimpleIF
- Overrides:
getUnitsString
in classVariableDS
- 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.
-
isInterval
public boolean isInterval()
An interval coordinate consists of two numbers, bound1 and bound2. The coordinate value must lie between them, but otherwise is somewhat arbitrary. If not interval, then it has one number, the coordinate value.- Returns:
- true if its an interval coordinate.
-
isIndependentCoordinate
public boolean isIndependentCoordinate()
-
getPositive
public String getPositive()
Get the direction of increasing values, used only for vertical Axes.- Returns:
- POSITIVE_UP, POSITIVE_DOWN, or null if unknown.
-
setPositive
@Deprecated public void setPositive(String positive)
Deprecated.Use CoordinateAxis.builder()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 String getBoundaryRef()
The name of this coordinate axis' boundary variable- Returns:
- the name of this coordinate axis' boundary variable, or null if none.
-
setBoundaryRef
@Deprecated public void setBoundaryRef(String boundaryRef)
Deprecated.Use CoordinateAxis.builder()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(Formatter buf)
Get a string representation- Parameters:
buf
- place info here
-
equals
public boolean equals(Object oo)
Instances which have same content are equal.
-
hashCode
public int hashCode()
Override Object.hashCode() to implement equals.
-
getCalendarFromAttribute
public Calendar getCalendarFromAttribute()
-
toBuilder
public CoordinateAxis.Builder<?> toBuilder()
Description copied from class:Variable
Turn into a mutable Builder. Can use toBuilder().build() to copy.- Overrides:
toBuilder
in classVariableDS
-
addLocalFieldsToBuilder
protected CoordinateAxis.Builder<?> addLocalFieldsToBuilder(CoordinateAxis.Builder<? extends CoordinateAxis.Builder<?>> b)
-
builder
public static CoordinateAxis.Builder<?> builder()
Get Builder for this class that allows subclassing.- See Also:
- "https://community.oracle.com/blogs/emcmanus/2010/10/24/using-builder-pattern-subclasses"
-
-