Skip to content

Units

Particula Index / Particula / Util / Converting / Units

Auto-generated documentation for particula.util.converting.units module.

convert_units

Show source in units.py:16

Generic wrapper for pint to convert units

Arguments

  • old : old units defined by pint, e.g., "m", "ft", "Km", "kg/m^3"
  • new : new units defined by pint, e.g., "m", "ft", "Km", "kg/m^3"
  • value : value to convert, needed for units with and offset e.g., "degC"

Returns

  • float : conversion multiplier from old to new units. If value is provided, it returns the converted value in the new units.

Raises

  • ImportError - if pint is not installed

Examples

Example Usage
conversion_multipliter = convert_units("ug/m^3", "kg/m^3")
# 1e-9

Signature

def convert_units(old: str, new: str, value: Optional[float] = None) -> float: ...