joseki.units

Units module.

Attributes

Functions

to_quantity(value[, units])

Convert to a pint.Quantity.

to_quantity_array_like(value[, units])

Module Contents

joseki.units.to_quantity(value, units=None)[source]

Convert to a pint.Quantity.

Parameters:
  • value (pint.Quantity | dict | int | float | list | numpy.ndarray | xarray.DataArray) – Value which will be converted. If value is an ArrayLike, it is assumed to be dimensionless (unless units is set). If a DataArray is passed and units_error is True, it is assumed to have a units key in its attrs field; otherwise, it is assumed to be dimensionless.

  • units (None | str) – Units to assign. If None, the units are inferred from the value argument.

Returns:

The corresponding quantity.

Return type:

pint.Quantity

Notes

This function can also be used on DataArray and Dataset coordinate variables.

joseki.units.to_quantity_array_like(value, units=None)[source]
Parameters:
  • value (numpy.typing.ArrayLike)

  • units (None | str)

Return type:

pint.Quantity

joseki.units.definitions = ['@alias ppm = parts_per_million = ppmv', 'parts_per_billion = 1e-9 = ppb = ppbv',...
joseki.units.logger
joseki.units.ureg