org.das2.datum.UnitsUtil
Useful operations for units, and tests for Steven's Levels of Measurement.
divide
divide( Datum aDatum, Datum bDatum ) → Datum
attempt to perform the division of two Datums by looking for
convertible units or dimensionless.
Parameters
aDatum - the numerator
bDatum - the denominator
Returns:
the result
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
divideToString
divideToString( Datum aDatum, Datum bDatum ) → String
Special division operation that either does the Datum division if
possible, or returns the division of the magnitude parts of the
Datums plus the unit names "A/B", suitable for human consumption.
Parameters
aDatum - the numerator
bDatum - the denominator
Returns:
String for the result, or "A/B"
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getInverseUnit
getInverseUnit( Units unit ) → Units
returns the unit whose product with the parameter unit is unity.
(Presently this is only supports time units like Hz→seconds).
Parameters
unit - the unit
Returns:
the inverse unit, or throws exception if one is not known.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isIntervalMeasurement
isIntervalMeasurement( Units unit ) → boolean
returns true if the unit is a interval measurement, meaning the choice of
zero is arbitrary. Subtraction and comparison are allowed, but addition,
multiplication and division are invalid operators.
Examples include "2008-04-09T14:27:00Z" and 15 deg W Longitude.
Parameters
unit - an Units
Returns:
a boolean
See Also:
http://en.wikipedia.org/wiki/Level_of_measurement
http://www.statisticssolutions.com/data-levels-of-measurement/
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isIntervalOrRatioMeasurement
isIntervalOrRatioMeasurement( Units unit ) → boolean
returns true if the unit is a interval measurement or is a ratio measurement,
and not a nominal or ordinal measurement. These are things that are plotted
by showing a location on an axis.
See http://en.wikipedia.org/wiki/Level_of_measurement
Examples include "2008-04-09T14:27:00Z" and "5 km"
Parameters
unit - an Units
Returns:
a boolean
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isNominalMeasurement
isNominalMeasurement( Units unit ) → boolean
returns true if the unit is nominal, meaning that Datums with this unit
can only be equal or not equal. Currently all nominal data is stored
as ordinal data, so this always returns false.
Examples include "Iowa City", and "Voyager 1".
See http://en.wikipedia.org/wiki/Level_of_measurement
Parameters
unit - the unit
Returns:
true if the unit is nominal.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isOrdinalMeasurement
isOrdinalMeasurement( Units unit ) → boolean
returns true if the unit is ordinal, meaning that Datums with this unit
can only be equal or not equal, or compared. subtract, add, multiply,
divide are invalid.
Examples include energy bin labels and quality measures.
See http://en.wikipedia.org/wiki/Level_of_measurement
Parameters
unit - an Units
Returns:
true if the unit is ordinal.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isRatioMeasurement
isRatioMeasurement( Units unit ) → boolean
returns true if the unit is a ratio measurement, meaning there is a physical zero
and you can make meaningful ratios between arbitrary numbers. All operations
like add, multiply and divide are allowed.
Examples include "5 km" or "0.2/cc" and "15 counts"
Parameters
unit - an Units
Returns:
a boolean
See Also:
http://en.wikipedia.org/wiki/Level_of_measurement
http://www.statisticssolutions.com/data-levels-of-measurement/
https://www.questionpro.com/blog/nominal-ordinal-interval-ratio/
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isRatiometric
isRatiometric( Units unit ) → boolean
returns true if the unit is used to measure distance in a logarithmic
space, such as decibels or percent increase. Note Units.dimensionless
are not considered ratiometric. (Of course, all ratiometic
units are dimensionless...)
Do not confuse this with isRatioMeasurement. "5kg" is ratio measurement.
"105%" is ratiometric.
Parameters
unit - the unit
Returns:
true if the unit is used to measure distance in a logarithmic space
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isTimeLocation
isTimeLocation( Units unit ) → boolean
returns true if the unit describes a location in time, as in us2000 or
Units.lookupTimeUnits('seconds since 1989-12-13T00:00Z')
Parameters
unit - the unit to test
Returns:
true if the unit describes a location in time
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]