public class VariableDS extends Variable implements VariableEnhanced, EnhanceScaleMissingUnsigned
NetcdfDatasetVariable.Cache| Modifier and Type | Field and Description |
|---|---|
protected DataType |
orgDataType |
protected String |
orgName |
protected Variable |
orgVar |
attributes, cache, dataType, debugCaching, defaultCoordsSizeToCache, defaultSizeToCache, dimensions, elementSize, hashCode, isMetadata, isVariableLength, ncfile, permitCaching, proxyReader, shape, shapeAsSection, sizeToCache, spiObjectannotations, dodsname, group, immutable, parentstruct, shortName, sort| Modifier | Constructor and Description |
|---|---|
|
VariableDS(Group group,
Structure parent,
String shortName,
Variable orgVar)
Make a new VariableDS, delegate data reading to the original variable, but otherwise
dont take any info from it.
|
|
VariableDS(Group g,
Variable orgVar,
boolean enhance)
Wrap the given Variable, making it into a VariableDS.
|
|
VariableDS(NetcdfDataset ds,
Group group,
Structure parentStructure,
String shortName,
DataType dataType,
String dims,
String units,
String desc)
Constructor when there's no underlying variable.
|
protected |
VariableDS(VariableDS vds,
boolean isCopy)
Copy constructor, for subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
protected Array |
_read() |
protected Array |
_read(Section section) |
void |
addCoordinateSystem(CoordinateSystem cs)
Add a CoordinateSystem to the dataset.
|
boolean |
addEnhancement(NetcdfDataset.Enhance enhancement)
Add
enhancement to this variable. |
Array |
applyScaleOffset(Array data)
Apply scale and offset to each element of
in and return the result as a new Array, but only if
EnhanceScaleMissingUnsigned.hasScaleOffset(). |
double |
applyScaleOffset(Number value)
Apply scale and offset to the specified value if
EnhanceScaleMissingUnsigned.hasScaleOffset(). |
void |
clearCoordinateSystems()
Remove coordinate system info.
|
Array |
convert(Array in,
boolean convertUnsigned,
boolean applyScaleOffset,
boolean convertMissing)
Perform the specified conversions on each element of
in and return the result as a new Array. |
Array |
convertMissing(Array in)
|
Number |
convertMissing(Number value)
|
Array |
convertUnsigned(Array in)
Performs an
unsigned conversion of each element of in and returns the
result as a new Array. |
Number |
convertUnsigned(Number value)
Convert
value to the next largest integral data type by an unsigned conversion. |
protected Variable |
copy() |
void |
enhance(Set<NetcdfDataset.Enhance> enhancements)
Calculate scale/offset/missing/enum/unsigned value info.
|
List<CoordinateSystem> |
getCoordinateSystems()
Get the list of Coordinate Systems for this Variable.
|
String |
getDatasetLocation() |
String |
getDescription()
Get the description of the Variable.
|
Set<NetcdfDataset.Enhance> |
getEnhanceMode()
Returns the enhancements applied to this variable.
|
double |
getFillValue()
return value of _FillValue attribute
|
Array |
getMissingDataArray(int[] shape)
Return Array with missing data
|
double[] |
getMissingValues()
return values of missing_value attributes
|
NetcdfFile |
getNetcdfFile() |
double |
getOffset()
The number to be added to the data after it is read.
|
DataType |
getOriginalDataType()
When this wraps another Variable, get the original Variable's DataType.
|
String |
getOriginalName()
When this wraps another Variable, get the original Variable's name.
|
Variable |
getOriginalVariable()
A VariableDS usually wraps another Variable.
|
DataType |
getScaledOffsetType()
Return the data type for values that have undergone scale/offset conversion.
|
double |
getScaleFactor()
The data are to be multiplied by this value after the data are read.
|
DataType.Signedness |
getSignedness()
Returns the signedness of the decorated variable.
|
String |
getUnitsString()
Get the Unit String for the Variable.
|
DataType |
getUnsignedConversionType()
Return the data type for values that have undergone unsigned conversion.
|
double |
getValidMax()
return the maximum value in the valid range
|
double |
getValidMin()
return the minimum value in the valid range
|
boolean |
hasCachedDataRecurse() |
boolean |
hasFillValue()
true if Variable has _FillValue attribute
|
boolean |
hasMissing()
true if Variable has missing data values
|
boolean |
hasMissingValue()
true if Variable has missing_value attribute
|
boolean |
hasScaleOffset()
true if Variable data will be converted using scale and offset
|
boolean |
hasValidData()
true if Variable has valid_range, valid_min or valid_max attributes
|
boolean |
isFillValue(double val)
return true if val equals the _FillValue
|
boolean |
isInvalidData(double val)
return true if val is outside the valid range
|
boolean |
isMissing(double val)
Returns
true if the argument is a missing value. |
boolean |
isMissingValue(double val)
return true if val equals a missing_value (low-level)
|
String |
lookupEnumString(int val)
Lookup the enum string for this value.
|
long |
readToStream(Section section,
OutputStream out) |
Array |
reallyRead(Variable client,
CancelTask cancelTask)
public by accident, do not call directly.
|
Array |
reallyRead(Variable client,
Section section,
CancelTask cancelTask)
public by accident, do not call directly.
|
void |
removeCoordinateSystem(CoordinateSystem cs)
Remove a CoordinateSystem from the dataset.
|
boolean |
removeEnhancement(NetcdfDataset.Enhance enhancement)
Remove
enhancement from this variable. |
void |
setCaching(boolean caching)
Set whether to cache or not.
|
void |
setFillValueIsMissing(boolean b)
set if _FillValue is considered isMissing(); better set in constructor if possible
|
void |
setInvalidDataIsMissing(boolean b)
set if valid_range is considered isMissing(); better set in constructor if possible
|
void |
setMissingDataIsMissing(boolean b)
set if missing_data is considered isMissing(); better set in constructor if possible
|
String |
setName(String newName)
Set the short name, converting to valid CDM object name if needed.
|
void |
setOriginalVariable(Variable orgVar)
Set the Variable to wrap.
|
void |
setUnitsString(String units)
Set the Unit String for this Variable.
|
void |
showScaleMissingProxy(Formatter f)
public for debugging
|
String |
toStringDebug()
String representation of Variable and its attributes.
|
addAll, addAttribute, compareTo, createNewCache, equals, extraInfo, findAttribute, findAttributeIgnoreCase, findAttValueIgnoreCase, findDimensionIndex, getAttributeContainer, getAttributes, getDAPName, getDAPName, getDataType, getDimension, getDimensions, getDimensionsAll, getDimensionsString, getElementSize, getEnumTypedef, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getNameAndDimensions, getParentGroup, getProxyReader, getRanges, getRank, getScalarData, getShape, getShape, getShapeAll, getShapeAsSection, getShapeNotScalar, getSize, getSizeToCache, getSPobject, hasCachedData, hashCode, hashCodeShow, invalidateCache, isCaching, isCoordinateVariable, isImmutable, 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, writeCDLannotate, annotation, getDODSName, getFullName, getFullNameEscaped, getGroup, getImmutable, getName, getParentStructure, getShortName, getSort, isMemberOfStructure, localhash, setDODSName, setParentStructure, setShortName, setSort, unwrapclone, finalize, getClass, notify, notifyAll, wait, wait, waitfindAttribute, findAttributeIgnoreCase, findDimensionIndex, getAttributes, getDataType, getDimension, getDimensions, getDimensionsAll, getElementSize, getEnumTypedef, getFullName, getFullNameEscaped, getNameAndDimensions, getParentGroup, getParentStructure, getRanges, getRank, getShape, getShapeAsSection, getShortName, getSize, isCoordinateVariable, isMemberOfStructure, isMetadata, isScalar, isUnlimited, isVariableLength, read, read, read, read, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, sectiongetNamecompareTogetNameprotected Variable orgVar
protected DataType orgDataType
protected String orgName
public VariableDS(NetcdfDataset ds, Group group, Structure parentStructure, String shortName, DataType dataType, String dims, String units, String desc)
ds - the containing datasetgroup - the containing groupparentStructure - the containing Structure (may be null)shortName - the (short) namedataType - the data typedims - list of dimension names, these must already exist in the Group; empty String = scalarunits - String value of units, may be nulldesc - String value of description, may be nullpublic VariableDS(Group group, Structure parent, String shortName, Variable orgVar)
group - the containing group; may not be nullparent - parent Structure, may be nullshortName - variable shortName, must be unique within the GrouporgVar - the original Variable to wrap. The original Variable is not modified.
Must not be a Structure, use StructureDS instead.public VariableDS(Group g, Variable orgVar, boolean enhance)
g - logical container, if null use orgVar's grouporgVar - the original Variable to wrap. The original Variable is not modified.
Must not be a Structure, use StructureDS instead.enhance - if true, use NetcdfDataset.defaultEnhanceMode to define what enhancements are made.
Note that this can change DataType and data values.
You can also call enhance() later. If orgVar is VariableDS, then enhance is inherited from there,
and this parameter is ignored.protected VariableDS(VariableDS vds, boolean isCopy)
vds - copy from here.isCopy - called from copy()public NetcdfFile getNetcdfFile()
getNetcdfFile in class Variablepublic void clearCoordinateSystems()
clearCoordinateSystems in interface VariableEnhancedpublic void enhance(Set<NetcdfDataset.Enhance> enhancements)
enhance in interface VariableEnhanced@Nonnull public Set<NetcdfDataset.Enhance> getEnhanceMode()
public boolean addEnhancement(NetcdfDataset.Enhance enhancement)
enhancement to this variable. It may result in a change of data type.enhancement - the enhancement to add.true if the set of enhancements changed as a result of the call.public boolean removeEnhancement(NetcdfDataset.Enhance enhancement)
enhancement from this variable. It may result in a change of data type.enhancement - the enhancement to remove.true if the set of enhancements changed as a result of the call.public Variable getOriginalVariable()
getOriginalVariable in interface VariableEnhancedpublic void setOriginalVariable(Variable orgVar)
setOriginalVariable in interface VariableEnhancedorgVar - original Variable, must not be a Structurepublic DataType getOriginalDataType()
public String getOriginalName()
getOriginalName in interface VariableEnhancedpublic String lookupEnumString(int val)
VariablelookupEnumString in class Variableval - the integer value of this enumpublic String setName(String newName)
Variablepublic String toStringDebug()
VariabletoStringDebug in interface VariableIFtoStringDebug in class Variablepublic String getDatasetLocation()
getDatasetLocation in class Variablepublic boolean hasCachedDataRecurse()
public void setCaching(boolean caching)
VariablesetCaching in class Variablecaching - set if caching.protected Array _read() throws IOException
_read in class VariableIOExceptionpublic Array reallyRead(Variable client, CancelTask cancelTask) throws IOException
VariablereallyRead in interface ProxyReaderreallyRead in class Variableclient - the client VariablecancelTask - user may cancelIOException - on errorprotected Array _read(Section section) throws IOException, InvalidRangeException
_read in class VariableIOExceptionInvalidRangeExceptionpublic Array reallyRead(Variable client, Section section, CancelTask cancelTask) throws IOException, InvalidRangeException
VariablereallyRead in interface ProxyReaderreallyRead in class Variableclient - the client Variablesection - the section of data to read.cancelTask - user may cancelIOException - on errorInvalidRangeException - if section has incorrect rank or illegal shape.public long readToStream(Section section, OutputStream out) throws IOException, InvalidRangeException
readToStream in class VariableIOExceptionInvalidRangeExceptionpublic Array getMissingDataArray(int[] shape)
shape - of this shapepublic void showScaleMissingProxy(Formatter f)
f - put info herepublic String getDescription()
VariablegetDescription in interface EnhancementsgetDescription in interface VariableIFgetDescription in interface VariableSimpleIFgetDescription in class Variablepublic String getUnitsString()
VariablegetUnitsString in interface EnhancementsgetUnitsString in interface VariableIFgetUnitsString in interface VariableSimpleIFgetUnitsString in class Variablepublic void setUnitsString(String units)
VariableEnhancedsetUnitsString in interface VariableEnhancedunits - unit stringpublic List<CoordinateSystem> getCoordinateSystems()
EnhancementsgetCoordinateSystems in interface Enhancementspublic void addCoordinateSystem(CoordinateSystem cs)
EnhancementsaddCoordinateSystem in interface Enhancementscs - add this Coordinate Systempublic void removeCoordinateSystem(CoordinateSystem cs)
EnhancementsremoveCoordinateSystem in interface Enhancementscs - remove this coordinate systempublic boolean hasScaleOffset()
EnhanceScaleMissingUnsignedhasScaleOffset in interface EnhanceScaleMissingUnsignedpublic double getScaleFactor()
EnhanceScaleMissingUnsigned1.0, i.e. no
scaling. It will remain that value if the variable defines no CDM.SCALE_FACTOR
attribute.getScaleFactor in interface EnhanceScaleMissingUnsignedpublic double getOffset()
EnhanceScaleMissingUnsignedCDM.SCALE_FACTOR and
CDM.ADD_OFFSET attributes are present, the data are first scaled before the offset is
added. By default it is 0.0, i.e. no offset. It will remain that value if the variable defines no
CDM.SCALE_FACTOR attribute.getOffset in interface EnhanceScaleMissingUnsignedpublic boolean hasMissing()
EnhanceScaleMissingUnsignedhasMissing in interface IsMissingEvaluatorhasMissing in interface EnhanceScaleMissingUnsignedpublic boolean isMissing(double val)
EnhanceScaleMissingUnsignedtrue if the argument is a missing value.
Note that Float.NaN and Double.NaN are considered missing data.isMissing in interface IsMissingEvaluatorisMissing in interface EnhanceScaleMissingUnsignedval - an unpacked value.true if the argument is a missing value.public boolean hasValidData()
EnhanceScaleMissingUnsignedhasValidData in interface EnhanceScaleMissingUnsignedpublic double getValidMin()
EnhanceScaleMissingUnsignedgetValidMin in interface EnhanceScaleMissingUnsignedpublic double getValidMax()
EnhanceScaleMissingUnsignedgetValidMax in interface EnhanceScaleMissingUnsignedpublic boolean isInvalidData(double val)
EnhanceScaleMissingUnsignedisInvalidData in interface EnhanceScaleMissingUnsignedpublic boolean hasFillValue()
EnhanceScaleMissingUnsignedhasFillValue in interface EnhanceScaleMissingUnsignedpublic double getFillValue()
EnhanceScaleMissingUnsignedgetFillValue in interface EnhanceScaleMissingUnsignedpublic boolean isFillValue(double val)
EnhanceScaleMissingUnsignedisFillValue in interface EnhanceScaleMissingUnsignedpublic boolean hasMissingValue()
EnhanceScaleMissingUnsignedhasMissingValue in interface EnhanceScaleMissingUnsignedpublic double[] getMissingValues()
EnhanceScaleMissingUnsignedgetMissingValues in interface EnhanceScaleMissingUnsignedpublic boolean isMissingValue(double val)
EnhanceScaleMissingUnsignedisMissingValue in interface EnhanceScaleMissingUnsignedpublic void setFillValueIsMissing(boolean b)
EnhanceScaleMissingUnsignedsetFillValueIsMissing in interface EnhanceScaleMissingUnsignedpublic void setInvalidDataIsMissing(boolean b)
EnhanceScaleMissingUnsignedsetInvalidDataIsMissing in interface EnhanceScaleMissingUnsignedpublic void setMissingDataIsMissing(boolean b)
EnhanceScaleMissingUnsignedsetMissingDataIsMissing in interface EnhanceScaleMissingUnsigned@Nullable public DataType getScaledOffsetType()
EnhanceScaleMissingUnsignednull if the
decorated variable lacks scale_factor or add_offset attributes. You can check with
EnhanceScaleMissingUnsigned.hasScaleOffset().getScaledOffsetType in interface EnhanceScaleMissingUnsigned@Nonnull public DataType getUnsignedConversionType()
EnhanceScaleMissingUnsignednull, 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.getUnsignedConversionType in interface EnhanceScaleMissingUnsignedpublic DataType.Signedness getSignedness()
EnhanceScaleMissingUnsignedgetSignedness in interface EnhanceScaleMissingUnsignedpublic double applyScaleOffset(Number value)
EnhanceScaleMissingUnsignedEnhanceScaleMissingUnsigned.hasScaleOffset(). Otherwise, just return value.applyScaleOffset in interface EnhanceScaleMissingUnsignedpublic Array applyScaleOffset(Array data)
EnhanceScaleMissingUnsignedin and return the result as a new Array, but only if
EnhanceScaleMissingUnsigned.hasScaleOffset(). Otherwise, just return value. Otherwise, just return data.applyScaleOffset in interface EnhanceScaleMissingUnsigneddata - convert thispublic Number convertUnsigned(Number value)
EnhanceScaleMissingUnsignedvalue to the next largest integral data type by an unsigned conversion. The conversion only happens if the decorated variable is unsigned
and value is a negative integer. Otherwise, simply return value.convertUnsigned in interface EnhanceScaleMissingUnsignedvalue - an integral number to convert.value.public Array convertUnsigned(Array in)
EnhanceScaleMissingUnsignedunsigned conversion of each element of in and returns the
result as a new Array. The data type of the returned array will be EnhanceScaleMissingUnsigned.getUnsignedConversionType().convertUnsigned in interface EnhanceScaleMissingUnsignedin - an Array containing integral Numbers to convert.in.public Number convertMissing(Number value)
EnhanceScaleMissingUnsignedconvertMissing in interface EnhanceScaleMissingUnsignedpublic Array convertMissing(Array in)
EnhanceScaleMissingUnsignedconvertMissing in interface EnhanceScaleMissingUnsignedin - an array containing floating-point numbers to convert.in.public Array convert(Array in, boolean convertUnsigned, boolean applyScaleOffset, boolean convertMissing)
EnhanceScaleMissingUnsignedin and return the result as a new Array.
Note that this method is more efficient than calling EnhanceScaleMissingUnsigned.convertUnsigned(Array), followed by
EnhanceScaleMissingUnsigned.applyScaleOffset(Array), followed by EnhanceScaleMissingUnsigned.convertMissing(Array), as only one copy of in is
made.convert in interface EnhanceScaleMissingUnsignedin - a numeric array.convertUnsigned - true if we should convert unsigned.applyScaleOffset - true if we should apply scale/offset.convertMissing - true if we should convert missing.