casacore
|
#include <UnitVal.h>
Public Member Functions | |
UnitVal () | |
Construct an non-dimensioned value of 1. More... | |
UnitVal (const UnitVal &other) | |
Copy constructor. More... | |
UnitVal (Double factor) | |
Construct an non-dimensioned value. More... | |
UnitVal (Double factor, const String &s, UMaps *=0) | |
Construct a fully dimensioned value. More... | |
UnitVal (Double factor, Int pos) | |
Construct a value with a single unit at position specified. More... | |
~UnitVal () | |
Destructor. More... | |
UnitVal & | operator= (const UnitVal &other) |
Assignment (copy semantics) More... | |
UnitVal & | operator*= (const UnitVal &other) |
Manipulate units More... | |
UnitVal & | operator/= (const UnitVal &other) |
Divide different units. More... | |
Bool | operator== (const UnitVal &other) const |
Compare the dimensionality of different units. More... | |
Bool | operator!= (const UnitVal &other) const |
UnitVal | pow (Int p) |
Raise a unit to an integer power. More... | |
UnitVal | root (Int p) const |
Take integer root. More... | |
UnitVal | sqrt () const |
const UnitDim & | getDim () const |
Get the data parts of the unit value definition More... | |
Double | getFac () const |
Get the factor of the unit (as compared to pure SI units) More... | |
Static Public Member Functions | |
static Bool | check (const String &s) |
Convert a unit string to a proper unit value and cache the result. More... | |
static Bool | check (const String &s, UnitVal &loc) |
Convert a unit string to a proper unit value, cache the result and compare the dimension with the specified unit value. More... | |
Static Public Attributes | |
static UnitVal | NODIM |
Some constants to check type of units More... | |
static UnitVal | UNDIM |
static UnitVal | LENGTH |
static UnitVal | MASS |
static UnitVal | TIME |
static UnitVal | CURRENT |
static UnitVal | TEMPERATURE |
static UnitVal | INTENSITY |
static UnitVal | MOLAR |
static UnitVal | ANGLE |
static UnitVal | SOLIDANGLE |
Protected Member Functions | |
void | init (Double factor) |
alternate initialization More... | |
void | init (Double factor, Int pos) |
Static Private Member Functions | |
static Bool | create (const String &s, UnitVal &res, UMaps *=0) |
Convert (and check) a unit string to an SI value representation. More... | |
static Bool | create (MUString &str, UnitVal &res, UMaps *=0) |
static Int | psign (MUString &str) |
Determine sign of unit power (i.e. More... | |
static Int | power (MUString &str) |
Determine exponent of unit symbol. More... | |
static Bool | field (MUString &str, UnitVal &res, UMaps *) |
Determine symbol name in unit string. More... | |
Private Attributes | |
Double | kindFactor |
The factor necessary to express the specified unit in the defining SI units. More... | |
UnitDim | kindDim |
The dimensions of the unit in the defining SI units. More... | |
Friends | |
class | UnitVal_static_initializer |
ensure that statics are initialized More... | |
UnitVal | operator* (const UnitVal &in, const UnitVal &other) |
Multiply. More... | |
UnitVal | operator/ (const UnitVal &in, const UnitVal &other) |
Divide. More... | |
ostream & | operator<< (ostream &os, const UnitVal &ku) |
Output a unit as a value and a string of SI defining units. More... | |
describes any valid unit as a factor and a dimenion of SI units
Public interface
The class name derives from Units and gives a Value for a unit string
Physical units are strings consisting of one or more names of known basic units, separated by '.' or ' ' (for multiplication) or '/' (for division). Each name can optionally be preceded by a standard decimal prefix, and/or followed by an (optionally signed) exponent. Example: km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2
See the Unit class for more details.
The UnitVal class maps a Unit string to a factor and a dimension of SI defining units. E.g 'km/s' will be 1000 m.s-1. This class is only of interest if the manipulation of units is of direct interest. Normally units will be used as Quantities and Quantums (see the Quantum class) only, i.e. as a physical quantity having a value and unit. The class can also be used to check the validity of a unit string.
UnitVal has the following constructors:
The UnitVal can be manipulated by the following operators and functions:
To aid in checking the dimensionality of units, the following constants are available:
Tip: Any other dimension can be checked by a combination; To check e;g; if a unit is an acceleration, use: UnitVal::LENGTH/UnitVal::TIME/UnitVal::TIME
The validity of a unit string can be checked by:
An observation contains values in Janskys and in Westerbork Units. The data can be combined by the following code:
To separate the actual manipulation of unit values from the related quantity
casacore::UnitVal::UnitVal | ( | ) |
Construct an non-dimensioned value of 1.
casacore::UnitVal::UnitVal | ( | const UnitVal & | other | ) |
Copy constructor.
|
inline |
casacore::UnitVal::~UnitVal | ( | ) |
Destructor.
Convert a unit string to a proper unit value and cache the result.
The function will return False if invalid string specified
Convert a unit string to a proper unit value, cache the result and compare the dimension with the specified unit value.
False if any of the steps fails
|
staticprivate |
Convert (and check) a unit string to an SI value representation.
Determine symbol name in unit string.
const UnitDim& casacore::UnitVal::getDim | ( | ) | const |
Double casacore::UnitVal::getFac | ( | ) | const |
Get the factor of the unit (as compared to pure SI units)
|
protected |
alternate initialization
Referenced by UnitVal(), and casacore::UnitVal_static_initializer::UnitVal_static_initializer().
Compare the dimensionality of different units.
Determine exponent of unit symbol.
Determine sign of unit power (i.e.
if '.' or '/')
UnitVal casacore::UnitVal::sqrt | ( | ) | const |
|
friend |
Output a unit as a value and a string of SI defining units.
|
friend |
|
static |
Definition at line 264 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 260 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 262 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
private |
|
private |
|
static |
Definition at line 257 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 258 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 263 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Some constants to check type of units
Definition at line 255 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 265 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 261 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 259 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().
|
static |
Definition at line 256 of file UnitVal.h.
Referenced by casacore::UnitVal_static_initializer::UnitVal_static_initializer().