smif.convert.unit module

Handles conversion between units used in the SosModel

First implementation delegates to pint.

Summary

Classes:

UnitRegister

Functions:

get_register Returns a reference to the unit registry

Reference

class smif.convert.unit.UnitRegister[source]

Bases: smif.convert.register.Register

names
register(unit_file)[source]

Load unit definitions into the registry

get_entry(name)[source]
get_coefficients(source, destination)[source]
convert_old(data, from_unit, to_unit)[source]

Convert the data from one unit to another unit

Parameters:
  • data (numpy.ndarray) – An array of values with dimensions regions x intervals
  • from_unit (str) – The name of the unit of the data
  • to_unit (str) – The name of the required unit
Returns:

An array of data with dimensions regions x intervals

Return type:

numpy.ndarray

Raises:

ValueError – If the units are not in the unit register or conversion is not possible

parse_unit(unit_string)[source]

Parse a unit string (abbreviation or full) into a Unit object

Parameters:unit (str) –
Returns:quantity
Return type:pint.Unit
smif.convert.unit.get_register()[source]

Returns a reference to the unit registry