Units

This module provides basic support for calculations with units.

class xconf.misc.units.Angle(magnitude, dimension)[source]

Define an angle with unit. Allowed units are ‘mdeg’, ‘deg’, ‘urad’, ‘mrad’ and ‘rad’.

class xconf.misc.units.Energy(magnitude, dimension)[source]

Define an energy with unit. Allowed units are ‘meV’, ‘eV’, ‘KeV’, ‘MeV’, ‘GeV’, ‘mJ’, ‘J’, ‘KJ’, ‘MJ’ and ‘GJ’.

class xconf.misc.units.Length(magnitude, dimension)[source]

Define a length with unit. Allowed units are ‘pm’, ‘angstrom’, ‘nm’, ‘um’, ‘mm’, ‘m’ and ‘km’.

class xconf.misc.units.Quantity(magnitude, dimension)[source]

Quantity base class. A quantity is made up of magnitude and dimension.

compare(other, op)[source]

Common method to check on the nature of operands.

convert(new_dimension)[source]

Convert this quantity to a another dimension new_dimension (e.g. to do a common mathematical operation on them). Will raise an error if the new dimension is not allowd.

free()[source]

Drop all unit support and just return the quantities magnitude.

operate(other, op)[source]

Common method to check on the nature of operands.

class xconf.misc.units.SolidAngle(magnitude, dimension)[source]

Define an solid angle with unit. Allowed units are ‘sr’ and ‘msr’.