UnitReference

class geodetic_engine.persistablereference.UnitReference[source]

Bases: Reference

A unit, stated by how it converts to its SI base.

USO states a scale and an offset, UAD a rational polynomial. The polynomial reduces to a scale and an offset whenever its d term is zero, which is the usual case.

symbol

The unit’s symbol, for example "ft".

measurement

What it measures, for example "length", or "".

coefficients

The polynomial (a, b, c, d) in si = (a + b * value) / (c + d * value). A scale and offset is held as (offset, scale, 1, 0), which is the same conversion.

property scale: float

The conversion’s scale factor.

Raises:

UnsupportedReferenceError – If the conversion is not linear, and so has no single scale.

property offset: float

The conversion’s offset, in the SI base unit.

Raises:

UnsupportedReferenceError – If the conversion is not linear.

to_si(value)[source]

Convert a value in this unit to the SI base unit.

Parameters:

value (float) – The value to convert.

Return type:

float

Returns:

The value in the SI base unit.

Raises:

MalformedReferenceError – If the conversion is undefined at this value.

from_si(value)[source]

Convert a value in the SI base unit to this unit.

Parameters:

value (float) – The value in the SI base unit.

Return type:

float

Returns:

The value in this unit.

Raises:

MalformedReferenceError – If the conversion cannot be inverted at this value.

convert_to(other, value)[source]

Convert a value from this unit to another.

Parameters:
  • other (UnitReference) – The unit to convert to, which must measure the same thing.

  • value (float) – The value in this unit.

Return type:

float

Returns:

The value in other.

Raises:
__init__(raw, kind, name, authority_code, version, symbol, measurement, coefficients)