value2standard_units#
- pyxem.utils.calibration.value2standard_units(value: str | Quantity | int | float, standard_unit: str | Unit = None) Quantity [source]#
Convert a string representation of units to a standard unit.
This takes a string like “40 mm” and will convert it to SI units 4E-3 m. If the string is not recognized, it will raise a ValueError.
- Parameters:
value (str) – The string representation of the units, e.g. “40 mm”, “1 cm”, “100 um”.
standard_unit (str,) – The standard unit to convert to. If not provided, it will use the unit from the value if it is a pint.Quantity, or raise an error if the value is a number.
- Returns:
The value converted to the standard unit.
- Return type:
pint.Quantity