Package ucar.nc2.dataset
Class VariableDS
java.lang.Object
ucar.nc2.CDMNode
ucar.nc2.Variable
ucar.nc2.dataset.VariableDS
- All Implemented Interfaces:
Comparable<VariableSimpleIF>,Iterable<Attribute>,IsMissingEvaluator,AttributeContainer,ucar.nc2.dataset.Enhancements,ucar.nc2.dataset.EnhanceScaleMissingUnsigned,VariableEnhanced,ProxyReader,VariableSimpleIF
- Direct Known Subclasses:
CoordinateAxis
public class VariableDS
extends Variable
implements VariableEnhanced, ucar.nc2.dataset.EnhanceScaleMissingUnsigned
A wrapper around a Variable, creating an "enhanced" Variable. The original Variable is used for the I/O.
There are several distinct uses:
- Handle scale/offset/missing/enum/unsigned conversion; this can change DataType and data values
- Container for coordinate system information
- NcML modifications to underlying Variable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classVariableDS.Builder<T extends VariableDS.Builder<T>> -
Field Summary
Fields inherited from class ucar.nc2.Variable
defaultCoordsSizeToCache, defaultSizeToCache, permitCaching -
Method Summary
Modifier and TypeMethodDescriptiondoubleapplyScaleOffset(Number value) Apply scale and offset to the specified value ifEnhanceScaleMissingUnsigned.hasScaleOffset().applyScaleOffset(Array data) Apply scale and offset to each element ofinand return the result as a new Array, but only ifEnhanceScaleMissingUnsigned.hasScaleOffset().static VariableDS.Builder<?>builder()Get Builder for this class that allows subclassing.convertMissing(Number value) convertMissing(Array in) convertUnsigned(Number value) Convertvalueto the next largest integral data type by anunsigned conversion.convertUnsigned(Number value, DataType dataType) convertUnsigned(Array in) Performs anunsigned conversionof each element ofinand returns the result as a new Array.booleancom.google.common.collect.ImmutableList<CoordinateSystem>Get the list of Coordinate Systems for this Variable.The location of the dataset this belongs to.Get the description of the Variable.Returns the enhancements applied to this variable.doublereturn value of _FillValue attributegetMissingDataArray(int[] shape) Return Array with missing datadouble[]return values of missing_value attributesGet the NetcdfFile that this variable is contained in.doubleThe number to be added to the data after it is read.When this wraps another Variable, get the original Variable's DataType.When this wraps another Variable, get the original Variable's name.A VariableDS usually wraps another Variable.Return the data type for values that have undergone scale/offset conversion.doubleThe data are to be multiplied by this value after the data are read.Returns the signedness of the decorated variable.Get the Unit String for the Variable.Return the data type for values that have undergone unsigned conversion.doublereturn the maximum value in the valid rangedoublereturn the minimum value in the valid rangebooleantrue if Variable has _FillValue attributebooleantrue if Variable has missing data valuesbooleantrue if Variable has missing_value attributebooleantrue if Variable data will be converted using scale and offsetbooleantrue if Variable has valid_range, valid_min or valid_max attributesbooleanbooleanisFillValue(double val) return true if val equals the _FillValuebooleanisInvalidData(double val) return true if val is outside the valid rangebooleanisMissing(double val) Returnstrueif the argument is a missing value.booleanisMissingValue(double val) return true if val equals a missing_value (low-level)lookupEnumString(int val) Lookup the enum string for this value.booleanlongreadToStream(Section section, OutputStream out) Read variable data to a stream.reallyRead(Variable client, Section section, CancelTask cancelTask) public by accident, do not call directly.reallyRead(Variable client, CancelTask cancelTask) public by accident, do not call directly.voidpublic for debuggingTurn into a mutable Builder.String representation of Variable and its attributes.Methods inherited from class ucar.nc2.Variable
attributes, compareTo, createNewCache, equals, findAttribute, findAttributeString, findDimensionIndex, getDataType, getDimension, getDimensions, getDimensionsString, getElementSize, getEnumTypedef, getFileTypeId, getFullName, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getParentGroup, getParentStructure, getRanges, getRank, getShape, getShape, getShapeAsSection, getSize, getSizeToCache, getSPobject, hasCachedData, hashCode, isCaching, isCoordinateVariable, isMemberOfStructure, isMetadata, isScalar, isUnlimited, isVariableLength, read, read, read, read, read, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, reduce, section, section, slice, toStringMethods inherited from class ucar.nc2.CDMNode
getShortNameMethods inherited from interface ucar.nc2.AttributeContainer
findAttributeDouble, findAttributeIgnoreCase, findAttributeInteger, getName, hasAttribute, hasAttributeIgnoreCase, isEmpty, iteratorMethods inherited from interface ucar.nc2.dataset.Enhancements
addCoordinateSystem, removeCoordinateSystemMethods inherited from interface ucar.nc2.dataset.EnhanceScaleMissingUnsigned
convertMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface ucar.nc2.dataset.VariableEnhanced
getFullName, getShortNameMethods inherited from interface ucar.nc2.VariableSimpleIF
getShortName
-
Method Details
-
getNetcdfFile
Description copied from class:VariableGet the NetcdfFile that this variable is contained in. May be null.- Overrides:
getNetcdfFilein classVariable
-
getEnhanceMode
Returns the enhancements applied to this variable. If this variable wraps another variable, the returned set will also contain the enhancements applied to the nested variable, recursively.- Returns:
- the enhancements applied to this variable.
-
getOriginalVariable
A VariableDS usually wraps another Variable.- Specified by:
getOriginalVariablein interfaceVariableEnhanced- Returns:
- original Variable or null
-
getOriginalDataType
When this wraps another Variable, get the original Variable's DataType.- Returns:
- original Variable's DataType, or current data type if it doesnt wrap another variable
-
getOriginalName
When this wraps another Variable, get the original Variable's name.- Specified by:
getOriginalNamein interfaceVariableEnhanced- Returns:
- original Variable's name
-
lookupEnumString
Description copied from class:VariableLookup the enum string for this value. Can only be called on enum types, where dataType.isEnum() is true.- Overrides:
lookupEnumStringin classVariable- Parameters:
val- the integer value of this enum- Returns:
- the String value
-
toStringDebug
Description copied from class:VariableString representation of Variable and its attributes.- Overrides:
toStringDebugin classVariable
-
getDatasetLocation
Description copied from class:VariableThe location of the dataset this belongs to. Labeling purposes only.- Overrides:
getDatasetLocationin classVariable
-
reallyRead
Description copied from class:Variablepublic by accident, do not call directly.- Specified by:
reallyReadin interfaceProxyReader- Overrides:
reallyReadin classVariable- Parameters:
client- the client VariablecancelTask- user may cancel- Returns:
- Array
- Throws:
IOException- on error
-
reallyRead
public Array reallyRead(Variable client, Section section, CancelTask cancelTask) throws IOException, InvalidRangeException Description copied from class:Variablepublic by accident, do not call directly.- Specified by:
reallyReadin interfaceProxyReader- Overrides:
reallyReadin classVariable- Parameters:
client- the client Variablesection- the section of data to read.cancelTask- user may cancel- Returns:
- Array
- Throws:
IOException- on errorInvalidRangeException- if section has incorrect rank or illegal shape.
-
readToStream
public long readToStream(Section section, OutputStream out) throws IOException, InvalidRangeException Description copied from class:VariableRead variable data to a stream. Support for NcStreamWriter.- Overrides:
readToStreamin classVariable- Throws:
IOExceptionInvalidRangeException
-
getMissingDataArray
Return Array with missing data- Parameters:
shape- of this shape- Returns:
- Array with given shape
-
showScaleMissingProxy
public for debugging- Parameters:
f- put info here
-
getDescription
Description copied from class:VariableGet the description of the Variable. Default is to use CDM.LONG_NAME attribute value. If not exist, look for "description", "title", or "standard_name" attribute value (in that order).- Specified by:
getDescriptionin interfaceucar.nc2.dataset.Enhancements- Specified by:
getDescriptionin interfaceVariableSimpleIF- Overrides:
getDescriptionin classVariable- Returns:
- description, or null if not found.
-
getUnitsString
Description copied from class:VariableGet the Unit String for the Variable. Looks for the CDM.UNITS attribute value- Specified by:
getUnitsStringin interfaceucar.nc2.dataset.Enhancements- Specified by:
getUnitsStringin interfaceVariableSimpleIF- Overrides:
getUnitsStringin classVariable- Returns:
- unit string, or null if not found.
-
getCoordinateSystems
Description copied from interface:EnhancementsGet the list of Coordinate Systems for this Variable.- Specified by:
getCoordinateSystemsin interfaceucar.nc2.dataset.Enhancements- Returns:
- list of type CoordinateSystem; may be empty but not null.
-
hasScaleOffset
public boolean hasScaleOffset()Description copied from interface:EnhanceScaleMissingUnsignedtrue if Variable data will be converted using scale and offset- Specified by:
hasScaleOffsetin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
getScaleFactor
public double getScaleFactor()Description copied from interface:EnhanceScaleMissingUnsignedThe data are to be multiplied by this value after the data are read. By default it is1.0, i.e. no scaling. It will remain that value if the variable defines noCDM.SCALE_FACTORattribute.- Specified by:
getScaleFactorin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Returns:
- the multiplier to apply to the data.
-
getOffset
public double getOffset()Description copied from interface:EnhanceScaleMissingUnsignedThe number to be added to the data after it is read. If bothCDM.SCALE_FACTORandCDM.ADD_OFFSETattributes are present, the data are first scaled before the offset is added. By default it is0.0, i.e. no offset. It will remain that value if the variable defines noCDM.SCALE_FACTORattribute.- Specified by:
getOffsetin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Returns:
- the number to add to the data.
-
hasMissing
public boolean hasMissing()Description copied from interface:EnhanceScaleMissingUnsignedtrue if Variable has missing data values- Specified by:
hasMissingin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Specified by:
hasMissingin interfaceIsMissingEvaluator- Returns:
- true if Variable has missing data values
-
isMissing
public boolean isMissing(double val) Description copied from interface:EnhanceScaleMissingUnsignedReturnstrueif the argument is a missing value. Note thatFloat.NaNandDouble.NaNare considered missing data.- Specified by:
isMissingin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Specified by:
isMissingin interfaceIsMissingEvaluator- Parameters:
val- an unpacked value.- Returns:
trueif the argument is a missing value.
-
hasValidData
public boolean hasValidData()Description copied from interface:EnhanceScaleMissingUnsignedtrue if Variable has valid_range, valid_min or valid_max attributes- Specified by:
hasValidDatain interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
getValidMin
public double getValidMin()Description copied from interface:EnhanceScaleMissingUnsignedreturn the minimum value in the valid range- Specified by:
getValidMinin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
getValidMax
public double getValidMax()Description copied from interface:EnhanceScaleMissingUnsignedreturn the maximum value in the valid range- Specified by:
getValidMaxin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
isInvalidData
public boolean isInvalidData(double val) Description copied from interface:EnhanceScaleMissingUnsignedreturn true if val is outside the valid range- Specified by:
isInvalidDatain interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
hasFillValue
public boolean hasFillValue()Description copied from interface:EnhanceScaleMissingUnsignedtrue if Variable has _FillValue attribute- Specified by:
hasFillValuein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
getFillValue
public double getFillValue()Description copied from interface:EnhanceScaleMissingUnsignedreturn value of _FillValue attribute- Specified by:
getFillValuein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
isFillValue
public boolean isFillValue(double val) Description copied from interface:EnhanceScaleMissingUnsignedreturn true if val equals the _FillValue- Specified by:
isFillValuein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
hasMissingValue
public boolean hasMissingValue()Description copied from interface:EnhanceScaleMissingUnsignedtrue if Variable has missing_value attribute- Specified by:
hasMissingValuein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
getMissingValues
public double[] getMissingValues()Description copied from interface:EnhanceScaleMissingUnsignedreturn values of missing_value attributes- Specified by:
getMissingValuesin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
isMissingValue
public boolean isMissingValue(double val) Description copied from interface:EnhanceScaleMissingUnsignedreturn true if val equals a missing_value (low-level)- Specified by:
isMissingValuein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
missingDataIsMissing
public boolean missingDataIsMissing() -
fillValueIsMissing
public boolean fillValueIsMissing() -
invalidDataIsMissing
public boolean invalidDataIsMissing() -
getScaledOffsetType
Description copied from interface:EnhanceScaleMissingUnsignedReturn the data type for values that have undergone scale/offset conversion. This will benullif the decorated variable lacksscale_factororadd_offsetattributes. You can check withEnhanceScaleMissingUnsigned.hasScaleOffset().- Specified by:
getScaledOffsetTypein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Returns:
- the data type for values that have undergone scale/offset conversion.
-
getUnsignedConversionType
Description copied from interface:EnhanceScaleMissingUnsignedReturn the data type for values that have undergone unsigned conversion. This will never benull, even when no unsigned conversion is necessary (because the underlying variable isn't unsigned). In such cases, this data type will be the same as that of the underlying variable.- Specified by:
getUnsignedConversionTypein interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Returns:
- the data type for values that have undergone unsigned conversion.
-
getSignedness
Description copied from interface:EnhanceScaleMissingUnsignedReturns the signedness of the decorated variable.- Specified by:
getSignednessin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Returns:
- the signedness of the decorated variable.
-
applyScaleOffset
Description copied from interface:EnhanceScaleMissingUnsignedApply scale and offset to the specified value ifEnhanceScaleMissingUnsigned.hasScaleOffset(). Otherwise, just returnvalue.- Specified by:
applyScaleOffsetin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
applyScaleOffset
Description copied from interface:EnhanceScaleMissingUnsignedApply scale and offset to each element ofinand return the result as a new Array, but only ifEnhanceScaleMissingUnsigned.hasScaleOffset(). Otherwise, just returnvalue. Otherwise, just returndata.- Specified by:
applyScaleOffsetin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Parameters:
data- convert this- Returns:
- converted data.
-
convertUnsigned
Description copied from interface:EnhanceScaleMissingUnsignedConvertvalueto the next largest integral data type by anunsigned conversion. The conversion only happens if the decorated variableis unsignedandvalueis a negative integer. Otherwise, simply returnvalue.- Specified by:
convertUnsignedin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Parameters:
value- an integral number to convert.- Returns:
- the result of an unsigned conversion of
value.
-
convertUnsigned
-
convertUnsigned
Description copied from interface:EnhanceScaleMissingUnsignedPerforms anunsigned conversionof each element ofinand returns the result as a new Array. The data type of the returned array will beEnhanceScaleMissingUnsigned.getUnsignedConversionType().- Specified by:
convertUnsignedin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Parameters:
in- an Array containing integral Numbers to convert.- Returns:
- the result of an unsigned conversion of each element of
in.
-
convertMissing
Description copied from interface:EnhanceScaleMissingUnsigned- Specified by:
convertMissingin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned
-
convertMissing
Description copied from interface:EnhanceScaleMissingUnsigned- Specified by:
convertMissingin interfaceucar.nc2.dataset.EnhanceScaleMissingUnsigned- Parameters:
in- an array containing floating-point numbers to convert.- Returns:
- the result of a missing conversion of each element of
in.
-
toBuilder
Description copied from class:VariableTurn into a mutable Builder. Can use toBuilder().build() to copy. -
builder
Get Builder for this class that allows subclassing.- See Also:
-
- "https://community.oracle.com/blogs/emcmanus/2010/10/24/using-builder-pattern-subclasses"
-