Module: valunits¶
Module for associating units with scalar quantities
This module has been modified from its original form by removing the call to the “units” executable and restricting the units to only those used by the heXRD package.
2 Classes¶
- class hexrd.valunits.valWUnit(name, unitType, value, unit)[source]¶
Value with units
- __init__(name, unitType, value, unit)[source]¶
Initialization
INPUTS name
(str) name of the item- unitType
- (str) class of units, e.g. ‘length’, ‘angle’
- value
- (float) numerical value
- unit
- (str) name of unit
2 Functions¶
- hexrd.valunits.toFloat(val, unitName)[source]¶
Return the raw value of the object
INPUTS
- val
- (float|valWUnit) object with value
- unitName
- (str) name of unit
This function returns the raw value of the object, ignoring the unit, if it is numeric or converts it to the requested units and returns the magnitude if it is a valWUnit instance.
For example:
>>> print toFloat(1.1, 'radians') 1.1 >>> v = valWUnit('vee', 'angle', 1.1, 'radians') >>> print toFloat(v, 'degrees') 63.0253574644