UnitReference¶
- class geodetic_engine.persistablereference.UnitReference[source]¶
Bases:
ReferenceA unit, stated by how it converts to its SI base.
USOstates a scale and an offset,UADa rational polynomial. The polynomial reduces to a scale and an offset whenever itsdterm 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)insi = (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:
- 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:
- 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:
- Returns:
The value in
other.- Raises:
MalformedReferenceError – If either conversion is undefined at this value.
UnsupportedReferenceError – If the two units measure different things, where a conversion would be meaningless.
- __init__(raw, kind, name, authority_code, version, symbol, measurement, coefficients)¶