@Deprecated public class VariableEnhancer extends Object implements EnhanceScaleMissingUnsigned
Modifier and Type | Method and Description |
---|---|
Array |
applyScaleOffset(Array in)
Deprecated.
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)
Deprecated.
Apply scale and offset to the specified value if
EnhanceScaleMissingUnsigned.hasScaleOffset() . |
Array |
convert(Array in,
boolean convertUnsigned,
boolean applyScaleOffset,
boolean convertMissing)
Deprecated.
Perform the specified conversions on each element of
in and return the result as a new Array. |
Array |
convertMissing(Array in)
Deprecated.
|
Number |
convertMissing(Number value)
Deprecated.
|
Array |
convertUnsigned(Array in)
Deprecated.
Performs an
unsigned conversion of each element of in and returns the
result as a new Array. |
Number |
convertUnsigned(Number value)
Deprecated.
Convert
value to the next largest integral data type by an unsigned conversion . |
double |
getFillValue()
Deprecated.
return value of _FillValue attribute
|
double[] |
getMissingValues()
Deprecated.
return values of missing_value attributes
|
double |
getOffset()
Deprecated.
The number to be added to the data after it is read.
|
DataType |
getScaledOffsetType()
Deprecated.
Return the data type for values that have undergone scale/offset conversion.
|
double |
getScaleFactor()
Deprecated.
The data are to be multiplied by this value after the data are read.
|
DataType.Signedness |
getSignedness()
Deprecated.
Returns the signedness of the decorated variable.
|
DataType |
getUnsignedConversionType()
Deprecated.
Return the data type for values that have undergone unsigned conversion.
|
double |
getValidMax()
Deprecated.
return the maximum value in the valid range
|
double |
getValidMin()
Deprecated.
return the minimum value in the valid range
|
boolean |
hasFillValue()
Deprecated.
true if Variable has _FillValue attribute
|
boolean |
hasMissing()
Deprecated.
true if Variable has missing data values
|
boolean |
hasMissingValue()
Deprecated.
true if Variable has missing_value attribute
|
boolean |
hasScaleOffset()
Deprecated.
true if Variable data will be converted using scale and offset
|
boolean |
hasValidData()
Deprecated.
true if Variable has valid_range, valid_min or valid_max attributes
|
boolean |
isFillValue(double val)
Deprecated.
return true if val equals the _FillValue
|
boolean |
isInvalidData(double val)
Deprecated.
return true if val is outside the valid range
|
boolean |
isMissing(double val)
Deprecated.
Returns
true if the argument is a missing value. |
boolean |
isMissingValue(double val)
Deprecated.
return true if val equals a missing_value (low-level)
|
static DataType |
largestOf(DataType... dataTypes)
Deprecated.
Returns the data type that is the largest among the arguments.
|
static DataType |
nextLarger(DataType dataType)
Deprecated.
Returns the smallest numeric data type that:
can hold a larger integer than
dataType can
if integral, has the same signedness as dataType
The relative sizes of data types are determined in a manner consistent with rank(DataType) . |
static int |
rank(DataType dataType)
Deprecated.
Returns a distinct integer for each of the
numeric data types that can be used to
(roughly) order them by the range of the DataType. |
void |
setFillValueIsMissing(boolean b)
Deprecated.
Set if _FillValue is considered isMissing().
|
void |
setInvalidDataIsMissing(boolean b)
Deprecated.
set if valid_range is considered isMissing(); better set in constructor if possible
|
void |
setMissingDataIsMissing(boolean b)
Deprecated.
set if missing_data is considered isMissing(); better set in constructor if possible
|
public static int rank(DataType dataType)
numeric
data types that can be used to
(roughly) order them by the range of the DataType. BYTE < UBYTE < SHORT < USHORT < INT < UINT <
LONG < ULONG < FLOAT < DOUBLE
. -1
will be returned for all non-numeric data types.dataType
- a numeric data type.public static DataType largestOf(DataType... dataTypes)
rank(DataType)
.dataTypes
- an array of numeric data types.public static DataType nextLarger(DataType dataType)
dataType
candataType
rank(DataType)
.
Argument | Result |
---|---|
BYTE | SHORT |
UBYTE | USHORT |
SHORT | INT |
USHORT | UINT |
INT | LONG |
UINT | ULONG |
LONG | DOUBLE |
ULONG | DOUBLE |
Any other data type | Just return argument |
byte
value -106
equals 150
when interpreted
as unsigned. That won't fit in a (signed) byte
, but it will fit in a short
.dataType
- an integral data type.public double getScaleFactor()
EnhanceScaleMissingUnsigned
1.0
, i.e. no
scaling. It will remain that value if the variable defines no CDM.SCALE_FACTOR
attribute.getScaleFactor
in interface EnhanceScaleMissingUnsigned
public double getOffset()
EnhanceScaleMissingUnsigned
CDM.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 EnhanceScaleMissingUnsigned
public DataType.Signedness getSignedness()
EnhanceScaleMissingUnsigned
getSignedness
in interface EnhanceScaleMissingUnsigned
public DataType getScaledOffsetType()
EnhanceScaleMissingUnsigned
null
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()
EnhanceScaleMissingUnsigned
null
, 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 EnhanceScaleMissingUnsigned
public boolean hasValidData()
EnhanceScaleMissingUnsigned
hasValidData
in interface EnhanceScaleMissingUnsigned
public double getValidMin()
EnhanceScaleMissingUnsigned
getValidMin
in interface EnhanceScaleMissingUnsigned
public double getValidMax()
EnhanceScaleMissingUnsigned
getValidMax
in interface EnhanceScaleMissingUnsigned
public boolean isInvalidData(double val)
EnhanceScaleMissingUnsigned
isInvalidData
in interface EnhanceScaleMissingUnsigned
public boolean hasFillValue()
EnhanceScaleMissingUnsigned
hasFillValue
in interface EnhanceScaleMissingUnsigned
public boolean isFillValue(double val)
EnhanceScaleMissingUnsigned
isFillValue
in interface EnhanceScaleMissingUnsigned
public double getFillValue()
EnhanceScaleMissingUnsigned
getFillValue
in interface EnhanceScaleMissingUnsigned
public boolean hasScaleOffset()
EnhanceScaleMissingUnsigned
hasScaleOffset
in interface EnhanceScaleMissingUnsigned
public boolean hasMissingValue()
EnhanceScaleMissingUnsigned
hasMissingValue
in interface EnhanceScaleMissingUnsigned
public boolean isMissingValue(double val)
EnhanceScaleMissingUnsigned
isMissingValue
in interface EnhanceScaleMissingUnsigned
public double[] getMissingValues()
EnhanceScaleMissingUnsigned
getMissingValues
in interface EnhanceScaleMissingUnsigned
public void setFillValueIsMissing(boolean b)
EnhanceScaleMissingUnsigned
setFillValueIsMissing
in interface EnhanceScaleMissingUnsigned
public void setInvalidDataIsMissing(boolean b)
EnhanceScaleMissingUnsigned
setInvalidDataIsMissing
in interface EnhanceScaleMissingUnsigned
public void setMissingDataIsMissing(boolean b)
EnhanceScaleMissingUnsigned
setMissingDataIsMissing
in interface EnhanceScaleMissingUnsigned
public boolean hasMissing()
EnhanceScaleMissingUnsigned
hasMissing
in interface IsMissingEvaluator
hasMissing
in interface EnhanceScaleMissingUnsigned
public boolean isMissing(double val)
EnhanceScaleMissingUnsigned
true
if the argument is a missing value.
Note that Float.NaN
and Double.NaN
are considered missing data.isMissing
in interface IsMissingEvaluator
isMissing
in interface EnhanceScaleMissingUnsigned
val
- an unpacked value.true
if the argument is a missing value.public Number convertUnsigned(Number value)
EnhanceScaleMissingUnsigned
value
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 EnhanceScaleMissingUnsigned
value
- an integral number to convert.value
.public Array convertUnsigned(Array in)
EnhanceScaleMissingUnsigned
unsigned 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 EnhanceScaleMissingUnsigned
in
- an Array containing integral Numbers to convert.in
.public double applyScaleOffset(Number value)
EnhanceScaleMissingUnsigned
EnhanceScaleMissingUnsigned.hasScaleOffset()
. Otherwise, just return value
.applyScaleOffset
in interface EnhanceScaleMissingUnsigned
public Array applyScaleOffset(Array in)
EnhanceScaleMissingUnsigned
in
and return the result as a new Array, but only if
EnhanceScaleMissingUnsigned.hasScaleOffset()
. Otherwise, just return value
. Otherwise, just return data
.applyScaleOffset
in interface EnhanceScaleMissingUnsigned
in
- convert thispublic Number convertMissing(Number value)
EnhanceScaleMissingUnsigned
convertMissing
in interface EnhanceScaleMissingUnsigned
public Array convertMissing(Array in)
EnhanceScaleMissingUnsigned
convertMissing
in interface EnhanceScaleMissingUnsigned
in
- an array containing floating-point numbers to convert.in
.public Array convert(Array in, boolean convertUnsigned, boolean applyScaleOffset, boolean convertMissing)
EnhanceScaleMissingUnsigned
in
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 EnhanceScaleMissingUnsigned
in
- 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
.