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:
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:
The cache will be cleared if a user defined unit is overwritten, to make sure no old value will be used.
UnitMap::putUser("tag", UnitVal(factor,"unit"), "full name (optional)"); or: UnitMap::putUser(UnitName);
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
UnitMap::addFITS();This set can be cleared from the user table by:
UnitMap::clearFITS();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:
UnitMap::clearCache();
UnitName myUnit; if (UnitMap::getPref("k", myUnit)) { cout << "k has value " << myUnit;}Define a value for the unit 'beam':
UnitMap::putUser("beam",UnitVal(C::pi * 0.1, "\"_2"),"telescope beam");List current cache:
UnitMap::listCache();
Destructor
Check if a unit name is known, and return its value if True
Get a prefix definition from key
Check if a unit name is known, and return its value if True
Get a cached definition
Check if a unit name is known, and return its value if True
Get a standard unit definition (search order: User, Customary, SI)
Define a user defined standard unit. If the unit is being redefined, and it
has already been used in a user's Unit variable, the value
cached in that variable will not change.
Clear out the cache
Define FITS related unit names
Clear FITS related units from user list
Translate a FITS unit to the proper units. Note that this is a translation
of the string only, no conversion. Unknown FITS units are not translated.
Hence any new definition of the FITS units will work ok
Translate to a FITS unit
List some part of the standard unit lists on cout or stream
List all known unit symbols
List some part of the standard unit lists on cout or stream
List all units in cache
List some part of the standard unit lists on cout or stream
List all prefixes
List some part of the standard unit lists on cout or stream
List all defining units
List some part of the standard unit lists on cout or stream
List all SI units
List some part of the standard unit lists on cout or stream
List all customary units
List some part of the standard unit lists on cout or stream
Return the different maps
Copy assignment (not implemented)
Get the name of a FITS unit
static Bool getPref(const String &s, UnitName &name)
static Bool getCache(const String &s, UnitVal &val)
static Bool getUnit(const String &s, UnitName &name)
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)
static void putUser(const String &s, const UnitVal &val)
static void putUser(const String &s, const UnitVal &val, const String &name)
static void putUser(const UnitName &name)
static void removeUser(const String &name)
Remove a user unit
static void removeUser(const UnitName &name)
static void clearCache()
static void addFITS()
static void clearFITS()
static Unit fromFITS(const Unit &un)
static Unit toFITS(const Unit &un)
static void list(ostream &os)
static void list()
static void listCache(ostream &os)
static void listCache()
static void listPref(ostream &os)
static void listPref()
static void listDef(ostream &os)
static void listDef()
static void listSI(ostream &os)
static void listSI()
static void listCust(ostream &os)
static void listCust()
static void listUser(ostream &os)
static void listUser()
static const map<String, String> &givePref()
static const map<String, String> &giveDef()
static const map<String, String> &giveSI()
static const map<String, String> &giveCust()
static const map<String, String> &giveUser()
static const map<String, String> &giveCache()
UnitMap(const UnitMap &other)
Copy constructor (not implemented)
UnitMap &operator=(const UnitMap &other)
static Bool getNameFITS(UnitName *&name, uInt which)
static const String &getStringFITS(uInt which)
Get the belonging unit to a FITS unit
static void initUM()
Initialise the static map
static void initUMPrefix()
Bits and pieces of initUM() to get compilation speed improved
static void initUMSI1()
static void initUMSI2()
static void initUMCust1()
static void initUMCust2()
static void initUMCust3()