|
static void | putCache (const String &s, const UnitVal &val) |
| Save a definition of a full unit name in the cache (the cache will be cleared if getting too large (200 entries) More...
|
|
static void | removeUser (const String &name) |
| Remove a user unit. More...
|
|
static void | removeUser (const UnitName &name) |
|
static void | clearCache () |
| Clear out the cache. More...
|
|
static void | addFITS () |
| Define FITS related unit names. More...
|
|
static void | clearFITS () |
| Clear FITS related units from user list. More...
|
|
static Unit | fromFITS (const Unit &un) |
| Translate a FITS unit to the proper units. More...
|
|
static Unit | toFITS (const Unit &un) |
| Translate to a FITS unit. More...
|
|
|
static Bool | getPref (const String &s, UnitName &name, UMaps *maps=0) |
| Check if a unit name is known, and return its value if True. More...
|
|
static Bool | getUnit (const String &s, UnitName &name, UMaps *maps=0) |
| Get a standard unit definition (search order: User, Customary, SI) More...
|
|
static Bool | getCache (const String &s, UnitVal &val) |
| Get a cached definition. More...
|
|
|
static void | putUser (const String &s, const UnitVal &val) |
| Define a user defined standard unit. More...
|
|
static void | putUser (const String &s, const UnitVal &val, const String &name) |
|
static void | putUser (const UnitName &name) |
|
contains all simple known physical units
Intended use:
Public interface
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
- Test programs:
- tUnit
Prerequisite
Etymology
Based on Units and the Casacore container classes called 'Map'
Synopsis
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 UnitMap class contains the known standard basic units, and any other basic unit defined by the user of the Unit related classes. The known units are divided into 5 different groups:
-
Defining units: m, kg, s, A, K, cd, mol, rad, sr, _
-
SI units: including a.o. Jy, AU etc)
-
Customary units: e.g. lb, hp, ly etc
-
User defined units: defined by user (e.g. Beam, KPH, KM)
-
Cached units: cached unit strings for speed in operations
The full list of known units can be viewed by running the tUnit test program.
Caution: There is a difference between units without a dimension (non-dimensioned I will call them), and undimensioned units; Non-dimensioned examples are "", "%"; undimensioned examples: "beam", "pixel";
Information about the contents of the unit maps can be obtained by the Bool functions (False if not present):
The standard units can be viewed by the following commands, which output to cout:
Units can be defined in the user list by:
Tip: The cache will be cleared if a user defined unit is overwritten, to make sure no old value will be used;
Caution: If using an explicit Unit variable (e;g; Unit a("5Bolton/beam")
), the check on the legality of the given string, and the conversion to the cached canonical value in the variable 'a', is only done at creation time; This means that if the user changes the value of a unit involved by the putUser() method, the unit using it should be re-created ( a = Unit("5Bolton/beam");
);
A special set of 'units' used in FITS datasets can be added by the command
This set can be cleared from the user table by:
Note that Unitmap keeps track of the inclusion of the FITS inclusion, making multiple calls inexpensive. The list of current FITS units can be viewed by running the tUnit program, or looking at the FITSunit table.
Once the UnitMap::addFITS() has been run, the FITS units can be used as any other unit. In addition, a FITS unit can be translated to standard SI units by a call to Unit UnitMap::fromFITS(const Unit). Any unit that is defined as a standard FITS unit will be translated. Unknown ones will not be translated, making the way clear for having standard units in a FITS units string. A comparable toFITS() translates in the same way in the reversed direction.
The cache can be cleared by:
Example
Check for legal prefix:
Define a value for the unit 'beam':
List current cache:
Motivation
Standard list available to try to enhance use of SI and related units
To Do
-
Some inlining (did not work first go)
Definition at line 212 of file UnitMap.h.