lair.mass_flux#

lair.mass_flux#

The pint context that converts a flux between moles and mass, given mw.

It converts [substance]/[area]/[time] to [mass]/[area]/[time] and back, multiplying or dividing by mw, the molar mass as a quantity in g/mol: units.context("mass_flux", mw=16.04 * units("g/mol")). Without mw, or with a plain number, the conversion raises a TypeError that names mw. Importing lair adds it to units; Convert a methane flux from moles to mass shows it on a methane flux.

See also

units

The registry that has the context.

lair.inventories.molecular_weight

The molar mass of a pollutant, for mw.

lair.inventories.convert_units

Does this conversion for a pollutant’s name.

Examples

10 nmol m-2 s-1 of methane (16.04 g/mol) is 13.86 kg km-2 d-1, and back:

In [1]: from lair import units

In [2]: mw = 16.04 * units("g/mol")

In [3]: flux = 10 * units("nmol m-2 s-1")

In [4]: with units.context("mass_flux", mw=mw):
   ...:     kg = flux.to("kg km-2 d-1")
   ...:     mol = kg.to("nmol m-2 s-1")
   ...: 

In [5]: print(f"{kg:~P.2f}")
13.86 kg/km²/d

In [6]: print(f"{mol:~P.2f}")
10.00 nmol/m²/s