lair.units#
- lair.units#
The pint unit registry lair uses, which is pint-xarray’s, so a quantified xarray object and a plain quantity share it. It has the
mass_fluxcontext. Convert a methane flux from moles to mass converts a methane flux with it.See also
mass_fluxThe context that converts between moles and mass.
lair.inventories.convert_unitsConverts an array’s
unitsattribute for a pollutant.
Examples
A quantity is a number with a unit, and the registry reads the unit from text, CF spellings such as
m-2 s-1included.toconverts within one dimension; a flux in moles needs themass_fluxcontext to become a flux in mass.In [1]: from lair import units In [2]: flux = 10 * units("nmol m-2 s-1") In [3]: print(f"{flux:~P}") 10.0 nmol/m²/s In [4]: print(f"{flux.to('mol km-2 d-1'):~P.3f}") 864.000 mol/km²/d