Class CoordinateAxis1D
- java.lang.Object
-
- ucar.nc2.CDMNode
-
- ucar.nc2.Variable
-
- ucar.nc2.dataset.VariableDS
-
- ucar.nc2.dataset.CoordinateAxis
-
- ucar.nc2.dataset.CoordinateAxis1D
-
- All Implemented Interfaces:
Comparable<VariableSimpleIF>,Iterable<Attribute>,IsMissingEvaluator,AttributeContainer,Enhancements,EnhanceScaleMissingUnsigned,VariableEnhanced,ProxyReader,VariableSimpleIF
- Direct Known Subclasses:
CoordinateAxis1DTime
public class CoordinateAxis1D extends CoordinateAxis
A 1-dimensional Coordinate Axis. Its values must be monotonic.If this is char valued, it will have rank 2, otherwise it will have rank 1.
If string or char valued, only getCoordName() can be called.
If the coordinates are regularly spaced, isRegular() is true, and the values are equal to getStart() + i * getIncrement().
This will also set "cell bounds" for this axis. By default, the cell bounds are midway between the coordinates values, and are therefore contiguous, and can be accessed though getCoordEdge(i). The only way the bounds can be set is if the coordinate variable has an attribute "bounds" that points to another variable bounds(ncoords,2). These contain the cell bounds, and must be ascending or descending as the coordinate values are. In this case isContiguous() is true when bounds1(i+1) == bounds2(i) for all i.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCoordinateAxis1D.Builder<T extends CoordinateAxis1D.Builder<T>>-
Nested classes/interfaces inherited from class ucar.nc2.dataset.CoordinateAxis
CoordinateAxis.AxisComparator
-
Nested classes/interfaces inherited from class ucar.nc2.Variable
Variable.Cache
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]coordsprotected booleanwasRead-
Fields inherited from class ucar.nc2.dataset.CoordinateAxis
axisType, boundaryRef, isContiguous, ncd, 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 protectedCoordinateAxis1D(CoordinateAxis1D.Builder<?> builder, Group parentGroup)CoordinateAxis1D(NetcdfDataset ncd, VariableDS vds)Deprecated.Use CoordinateAxis1D.builder()CoordinateAxis1D(NetcdfDataset ds, Group group, String shortName, DataType dataType, String dims, String units, String desc)Deprecated.Use CoordinateAxis1D.builder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected CoordinateAxis1D.Builder<?>addLocalFieldsToBuilder(CoordinateAxis1D.Builder<? extends CoordinateAxis1D.Builder<?>> b)static CoordinateAxis1D.Builder<?>builder()Get Builder for this class that allows subclassing.protected CoordinateAxis1Dcopy()Deprecated.UsetoBuilder()CoordinateAxiscopyNoCache()Make a copy, with an independent cache.voidcorrectLongitudeWrap()Deprecated.do not use.intfindCoordElement(double coordVal)Given a coordinate value, find what grid element contains it.intfindCoordElement(double coordVal, int lastIndex)Deprecated.use findCoordElement(coordVal)intfindCoordElementBounded(double coordVal)Given a coordinate position, find what grid element contains it, or is closest to it.double[]getBound1()Get the coordinate bound1 as a double array.double[]getBound2()Get the coordinate bound1 as a double array.double[]getCoordBounds(int i)Get the coordinate bounds for the ith coordinate.doublegetCoordBoundsMidpoint(int i)doublegetCoordEdge(int index)Get the ith coordinate edge.double[]getCoordEdges()Get the coordinate edges as a double array.StringgetCoordName(int index)The "name" of the ith coordinate.doublegetCoordValue(int index)Get the ith coordinate value.double[]getCoordValues()Get the coordinate values as a double array.doublegetIncrement()Get increment value if isRegular()doublegetMaxEdgeValue()doublegetMaxValue()The largest coordinate value.doublegetMinEdgeValue()doublegetMinValue()The smallest coordinate value.List<NamedObject>getNames()Deprecated.will move in ver 6doublegetStart()Get starting value if isRegular()booleanisContiguous()If the edges are contiguous or disjoint Caution: many datasets do not explicitly specify this info, this is often a guess; default is true.booleanisInterval()If this coordinate has interval values.booleanisRegular()If true, then value(i) = getStart() + i * getIncrement().protected voidreadValues()CoordinateAxis1Dsection(Range r)Create a new CoordinateAxis1D as a section of this CoordinateAxis1D.CoordinateAxis1D.Builder<?>toBuilder()Turn into a mutable Builder.-
Methods inherited from class ucar.nc2.dataset.CoordinateAxis
addLocalFieldsToBuilder, equals, factory, fromVariableDS, getAxisType, getBoundaryRef, getCalendarFromAttribute, getInfo, getPositive, getUnitsString, hashCode, isIndependentCoordinate, isNumeric, setAxisType, setBoundaryRef, setPositive
-
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
-
-
-
-
Constructor Detail
-
CoordinateAxis1D
@Deprecated public CoordinateAxis1D(NetcdfDataset ncd, VariableDS vds)
Deprecated.Use CoordinateAxis1D.builder()Create a 1D coordinate axis from an existing Variable- Parameters:
ncd- the containing datasetvds- wrap this VariableDS, which is not changed.
-
CoordinateAxis1D
@Deprecated public CoordinateAxis1D(NetcdfDataset ds, Group group, String shortName, DataType dataType, String dims, String units, String desc)
Deprecated.Use CoordinateAxis1D.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.
-
CoordinateAxis1D
protected CoordinateAxis1D(CoordinateAxis1D.Builder<?> builder, Group parentGroup)
-
-
Method Detail
-
section
public CoordinateAxis1D section(Range r) throws InvalidRangeException
Create a new CoordinateAxis1D as a section of this CoordinateAxis1D.- Parameters:
r- the section range- Returns:
- a new CoordinateAxis1D as a section of this CoordinateAxis1D
- Throws:
InvalidRangeException- if IllegalRange
-
copy
@Deprecated protected CoordinateAxis1D copy()
Deprecated.UsetoBuilder()- Overrides:
copyin classCoordinateAxis
-
copyNoCache
public CoordinateAxis copyNoCache()
Description copied from class:CoordinateAxisMake a copy, with an independent cache.- Overrides:
copyNoCachein classCoordinateAxis- Returns:
- copy of this CoordinateAxis
-
getNames
@Deprecated public List<NamedObject> getNames()
Deprecated.will move in ver 6Get the list of names, to be used for user selection. The ith one refers to the ith coordinate.- Returns:
- List of ucar.nc2.util.NamedObject, or empty list.
-
getCoordName
public String getCoordName(int index)
The "name" of the ith coordinate. If nominal, this is all there is to a coordinate. If numeric, this will return a String representation of the coordinate.- Parameters:
index- which one ?- Returns:
- the ith coordinate value as a String
-
getCoordValue
public double getCoordValue(int index)
Get the ith coordinate value. This is the value of the coordinate axis at which the data value is associated. These must be strictly monotonic.- Parameters:
index- which coordinate. Between 0 and getNumElements()-1 inclusive.- Returns:
- coordinate value.
- Throws:
UnsupportedOperationException- if !isNumeric()
-
getMinValue
public double getMinValue()
Description copied from class:CoordinateAxisThe smallest coordinate value. Only call if isNumeric.- Overrides:
getMinValuein classCoordinateAxis- Returns:
- the minimum coordinate value
-
getMaxValue
public double getMaxValue()
Description copied from class:CoordinateAxisThe largest coordinate value. Only call if isNumeric.- Overrides:
getMaxValuein classCoordinateAxis- Returns:
- the maximum coordinate value
-
getMinEdgeValue
public double getMinEdgeValue()
-
getMaxEdgeValue
public double getMaxEdgeValue()
-
getCoordEdge
public double getCoordEdge(int index)
Get the ith coordinate edge. Exact only if isContiguous() is true, otherwise use getBound1() and getBound2(). This is the value where the underlying grid element switches from "belonging to" coordinate value i-1 to "belonging to" coordinate value i. In some grids, this may not be well defined, and so should be considered an approximation or a visualization hint.Coordinate edges must be strictly monotonic: coordEdge(0) < coordValue(0) < coordEdge(1) < coordValue(1) ... ... coordEdge(i) < coordValue(i) < coordEdge(i+1) < coordValue(i+1) ... ... coordEdge(n-1) < coordValue(n-1) < coordEdge(n)- Parameters:
index- which coordinate. Between 0 and getNumElements() inclusive.- Returns:
- coordinate edge.
- Throws:
UnsupportedOperationException- if !isNumeric()
-
getCoordValues
public double[] getCoordValues()
Get the coordinate values as a double array.- Returns:
- coordinate value.
- Throws:
UnsupportedOperationException- if !isNumeric()
-
getCoordEdges
public double[] getCoordEdges()
Get the coordinate edges as a double array. Exact only if isContiguous() is true, otherwise use getBound1() and getBound2().- Returns:
- coordinate edges.
- Throws:
UnsupportedOperationException- if !isNumeric()
-
isContiguous
public boolean isContiguous()
Description copied from class:CoordinateAxisIf the edges are contiguous or disjoint Caution: many datasets do not explicitly specify this info, this is often a guess; default is true.- Overrides:
isContiguousin classCoordinateAxis- Returns:
- true if the edges are contiguous or false if disjoint. Assumed true unless set otherwise.
-
isInterval
public boolean isInterval()
If this coordinate has interval values. If so, then one should use getBound1, getBound2, and not getCoordEdges()- Overrides:
isIntervalin classCoordinateAxis- Returns:
- true if coordinate has interval values
-
getBound1
public double[] getBound1()
Get the coordinate bound1 as a double array. bound1[i] # coordValue[i] # bound2[i], where # is < if increasing (bound1[i] < bound1[i+1]) else < if decreasing.- Returns:
- coordinate bound1.
- Throws:
UnsupportedOperationException- if !isNumeric()
-
getBound2
public double[] getBound2()
Get the coordinate bound1 as a double array. bound1[i] # coordValue[i] # bound2[i], where # is < if increasing (bound1[i] < bound1[i+1]) else < if decreasing.- Returns:
- coordinate bound2.
- Throws:
UnsupportedOperationException- if !isNumeric()
-
getCoordBounds
public double[] getCoordBounds(int i)
Get the coordinate bounds for the ith coordinate. Can use this for isContiguous() true or false.- Parameters:
i- coordinate index- Returns:
- double[2] edges for ith coordinate
-
getCoordBoundsMidpoint
public double getCoordBoundsMidpoint(int i)
-
findCoordElement
public int findCoordElement(double coordVal)
Given a coordinate value, find what grid element contains it. This means thatedge[i] <= value < edge[i+1] (if values are ascending) edge[i] > value >= edge[i+1] (if values are descending)
- Parameters:
coordVal- position in this coordinate system- Returns:
- index of grid point containing it, or -1 if outside grid area
-
findCoordElementBounded
public int findCoordElementBounded(double coordVal)
Given a coordinate position, find what grid element contains it, or is closest to it.- Parameters:
coordVal- position in this coordinate system- Returns:
- index of grid point containing it, or best estimate of closest grid interval.
-
findCoordElement
public int findCoordElement(double coordVal, int lastIndex)Deprecated.use findCoordElement(coordVal)
-
getStart
public double getStart()
Get starting value if isRegular()- Returns:
- starting value if isRegular()
-
getIncrement
public double getIncrement()
Get increment value if isRegular()- Returns:
- increment value if isRegular()
-
isRegular
public boolean isRegular()
If true, then value(i) = getStart() + i * getIncrement().- Returns:
- if evenly spaced.
-
correctLongitudeWrap
@Deprecated public void correctLongitudeWrap()
Deprecated.do not use.
-
readValues
protected void readValues()
-
toBuilder
public CoordinateAxis1D.Builder<?> toBuilder()
Description copied from class:VariableTurn into a mutable Builder. Can use toBuilder().build() to copy.- Overrides:
toBuilderin classCoordinateAxis
-
addLocalFieldsToBuilder
protected CoordinateAxis1D.Builder<?> addLocalFieldsToBuilder(CoordinateAxis1D.Builder<? extends CoordinateAxis1D.Builder<?>> b)
-
builder
public static CoordinateAxis1D.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"
-
-