mcsas.utils.units module¶
Defines methods for using and manipulating units of variables. Some default magnitude-name dictionaries are provided, but the user can supply their own dictionary if required. Default unit to translate to must be set. Required keyword arguments:
- magnitudedict: a dictionary of magnitude - name pairs. Names must be
- unicode strings.
- simagnitudename: the si magnitude name.
Example usage:
>>> rUnit = Length("nm")
>>> rUnit.siMagnitudeName
u'm'
>>> rUnit.displayMagnitudeName
u'nm'
>>> rUnit.magnitudeConversion
1e-09
or:
>>> rUnit.toSi(32)
3.2e-08
Selecting a default:
>>> qUnit = ScatteringVector(u"cm⁻¹")
>>> qUnit.magnitudeConversion
100.0
-
class
Angle(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
Area(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
DynamicViscosity(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
Fraction(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
Length(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
NoUnit(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
SLD(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
ScatteringIntensity(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
ScatteringVector(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
Temperature(magnitudeName=None)[source]¶ Bases:
utils.units.Unittest case for special conversions. Done by redefining toSI and toDisplay. Implemented units are given in _magnitudeMap.
Set up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
magnitudeConversion¶
-
-
class
Time(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
class
Unit(magnitudeName=None)[source]¶ Bases:
objectSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.
-
availableMagnitudeNames¶
-
displayMagnitude¶
-
displayMagnitudeName¶
-
magnitudeConversion¶ Scaling factor to move from display magnitude to si units. Required display argument:
displaymagnitudename : The name of the magnitude to convert fromOptional display argument:
- simagnitudename : The name of the magnitude to convert to.
- Defaults to self.siMagnitudeName
- Returns:
- float : A scaling factor for display unit to scale to si unit.
-
magnitudeMapping= {}¶
-
siMagnitude= ''¶
-
siMagnitudeName= ''¶
-
-
class
Volume(magnitudeName=None)[source]¶ Bases:
utils.units.UnitSet up a unit of measurement. The provided magnitude name is used by default in the UI. Using SI units if unspecified.