Skip to content

Units

Every dimensioned value in the Python API is a quantity object such as Distance or Angle. Quantities store their value in SI units and never convert to a plain float implicitly, so a distance cannot end up where an angle or a bare number is expected.

Creating Quantities

Multiply a number by a unit constant, or use one of the static constructors named after the units:

import lox_space as lox

altitude = 500 * lox.km
inclination = 97.4 * lox.deg
carrier = 8.4 * lox.GHz
duration = 90 * lox.minutes

altitude = lox.Distance.kilometers(500)

Unit constants such as lox.km are unit objects (DistanceUnit), not quantities. A unit can also be looked up by its symbol, e.g. lox.DistanceUnit("km").

Converting to Numbers

to(unit) returns the value as a float in the given unit. Each quantity also has to_* methods named after its units:

altitude.to(lox.km)  # 500.0
altitude.to_meters()  # 500000.0
duration.to(lox.seconds)  # 5400.0

Formatting

str() shows the value in SI units with the unit symbol, and format specs apply to the number. display_in formats the value in another unit:

str(altitude)  # "500000 m"
f"{altitude:.1f}"  # "500000.0 m"
altitude.display_in(lox.km)  # "500.0 km"
altitude.display_in(lox.km, ".1f")  # "500.0 km"

Arithmetic

Quantities of the same kind can be added, subtracted and compared, and scaled by numbers. Dividing two quantities of the same kind gives a float. A few products and quotients change the dimension:

Expression Result
Distance / TimeDelta Velocity
Velocity * TimeDelta Distance
Angle / TimeDelta AngularRate
AngularRate * TimeDelta Angle
Distance * Distance Area
Area / Mass AreaToMass
DataRate * TimeDelta DataVolume
DataVolume / TimeDelta DataRate
DecibelWatts ± Decibel DecibelWatts
DecibelWatts - DecibelWatts Decibel

Products work with the operands in either order.

total = 100 * lox.km + 500 * lox.m  # Distance
ratio = (2 * lox.km) / (500 * lox.m)  # 4.0
speed = (7 * lox.km) / (1 * lox.seconds)  # Velocity
eirp = 10 * lox.dBW + 30 * lox.dB  # DecibelWatts

Unit Constants

Angle

Constant Symbol Unit
lox.rad rad radians
lox.urad µrad microradians
lox.deg deg degrees
lox.arcsec arcsec arcseconds
lox.mas mas milliarcseconds
lox.uas µas microarcseconds

AngularRate

Constant Symbol Unit
lox.rad_per_s rad/s radians per second
lox.deg_per_s deg/s degrees per second

Area

Constant Symbol Unit
lox.m2 m² square meters
lox.km2 km² square kilometers

AreaToMass

Constant Symbol Unit
lox.m2_per_kg m²/kg square meters per kilogram

DataRate

Constant Symbol Unit
lox.bps bit/s bits per second
lox.kbps kbit/s kilobits per second
lox.Mbps Mbit/s megabits per second
lox.Gbps Gbit/s gigabits per second

DataVolume

Constant Symbol Unit
lox.bit bit bits
lox.kbit kbit kilobits
lox.Mbit Mbit megabits
lox.Gbit Gbit gigabits
lox.Tbit Tbit terabits
lox.B B bytes
lox.kB kB kilobytes (10³ bytes)
lox.MB MB megabytes (10⁶ bytes)
lox.GB GB gigabytes (10⁹ bytes)
lox.TB TB terabytes (10¹² bytes)
lox.KiB KiB kibibytes (2¹⁰ bytes)
lox.MiB MiB mebibytes (2²⁰ bytes)
lox.GiB GiB gibibytes (2³⁰ bytes)
lox.TiB TiB tebibytes (2⁴⁰ bytes)

Decibel

Constant Symbol Unit
lox.dB dB decibels

DecibelWatts

Constant Symbol Unit
lox.dBW dBW decibel watts
lox.dBm dBm decibel milliwatts

Distance

Constant Symbol Unit
lox.m m meters
lox.km km kilometers
lox.au au astronomical units

Frequency

Constant Symbol Unit
lox.Hz Hz hertz
lox.kHz kHz kilohertz
lox.MHz MHz megahertz
lox.GHz GHz gigahertz
lox.THz THz terahertz

GravitationalParameter

Constant Symbol Unit
lox.m3_per_s2 m³/s² cubic meters per second squared
lox.km3_per_s2 km³/s² cubic kilometers per second squared

Mass

Constant Symbol Unit
lox.g g grams
lox.kg kg kilograms
lox.t t metric tons

Power

Constant Symbol Unit
lox.W W watts
lox.kW kW kilowatts

Pressure

Constant Symbol Unit
lox.Pa Pa pascals
lox.hPa hPa hectopascals

SpecificAngularMomentum

Constant Symbol Unit
lox.m2_per_s m²/s square meters per second
lox.km2_per_s km²/s square kilometers per second

SpecificEnergy

Constant Symbol Unit
lox.m2_per_s2 m²/s² square meters per second squared
lox.km2_per_s2 km²/s² square kilometers per second squared

Temperature

Constant Symbol Unit
lox.K K kelvin

Velocity

Constant Symbol Unit
lox.m_per_s m/s meters per second
lox.km_per_s km/s kilometers per second
lox.au_per_d au/d astronomical units per day
lox.c c fraction of the speed of light

TimeDelta

Constant Symbol Unit
lox.attoseconds as attoseconds
lox.femtoseconds fs femtoseconds
lox.picoseconds ps picoseconds
lox.nanoseconds ns nanoseconds
lox.microseconds µs microseconds
lox.milliseconds ms milliseconds
lox.seconds s seconds
lox.minutes min minutes
lox.hours h hours
lox.days d days of 86400 s
lox.julian_years a Julian years of 365.25 days
lox.julian_centuries cy Julian centuries of 36525 days

Angle

An angle, stored in SI units.

Create one by multiplying a number by a unit, e.g. 30 * lox.deg, or with one of the static constructors named after the units, e.g. Angle.degrees(30). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • arcseconds –

    Creates an angle from a value in arcseconds.

  • degrees –

    Creates an angle from a value in degrees.

  • display_in –

    Returns the value formatted in the given unit, e.g. "30.0 deg".

  • microarcseconds –

    Creates an angle from a value in microarcseconds.

  • microradians –

    Creates an angle from a value in microradians.

  • milliarcseconds –

    Creates an angle from a value in milliarcseconds.

  • radians –

    Creates an angle from a value in radians.

  • to –

    Returns the value in the given unit.

  • to_arcseconds –

    Returns the value in arcseconds.

  • to_degrees –

    Returns the value in degrees.

  • to_microarcseconds –

    Returns the value in microarcseconds.

  • to_microradians –

    Returns the value in microradians.

  • to_milliarcseconds –

    Returns the value in milliarcseconds.

  • to_radians –

    Returns the value in radians.

arcseconds staticmethod

arcseconds(value: float) -> Angle

Creates an angle from a value in arcseconds.

degrees staticmethod

degrees(value: float) -> Angle

Creates an angle from a value in degrees.

display_in

display_in(unit: AngleUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "30.0 deg".

Parameters:

  • unit

    (AngleUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

microarcseconds staticmethod

microarcseconds(value: float) -> Angle

Creates an angle from a value in microarcseconds.

microradians staticmethod

microradians(value: float) -> Angle

Creates an angle from a value in microradians.

milliarcseconds staticmethod

milliarcseconds(value: float) -> Angle

Creates an angle from a value in milliarcseconds.

radians staticmethod

radians(value: float) -> Angle

Creates an angle from a value in radians.

to

to(unit: AngleUnit) -> float

Returns the value in the given unit.

to_arcseconds

to_arcseconds() -> float

Returns the value in arcseconds.

to_degrees

to_degrees() -> float

Returns the value in degrees.

to_microarcseconds

to_microarcseconds() -> float

Returns the value in microarcseconds.

to_microradians

to_microradians() -> float

Returns the value in microradians.

to_milliarcseconds

to_milliarcseconds() -> float

Returns the value in milliarcseconds.

to_radians

to_radians() -> float

Returns the value in radians.

AngleUnit

A unit of Angle.

Multiply a number by a unit to create a quantity, e.g. 30 * lox.deg.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "rad".

Attributes:

symbol property

symbol: str

The unit symbol.


AngularRate

An angular rate, stored in SI units.

Create one by multiplying a number by a unit, e.g. 15 * lox.deg_per_s, or with one of the static constructors named after the units, e.g. AngularRate.degrees_per_second(15). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

degrees_per_second staticmethod

degrees_per_second(value: float) -> AngularRate

Creates an angular rate from a value in degrees per second.

display_in

display_in(unit: AngularRateUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "15.0 deg/s".

Parameters:

  • unit

    (AngularRateUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

radians_per_second staticmethod

radians_per_second(value: float) -> AngularRate

Creates an angular rate from a value in radians per second.

to

to(unit: AngularRateUnit) -> float

Returns the value in the given unit.

to_degrees_per_second

to_degrees_per_second() -> float

Returns the value in degrees per second.

to_radians_per_second

to_radians_per_second() -> float

Returns the value in radians per second.

AngularRateUnit

A unit of AngularRate.

Multiply a number by a unit to create a quantity, e.g. 15 * lox.deg_per_s.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "rad/s".

Attributes:

symbol property

symbol: str

The unit symbol.


Area

An area, stored in SI units.

Create one by multiplying a number by a unit, e.g. 2 * lox.m2, or with one of the static constructors named after the units, e.g. Area.square_meters(2). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

display_in

display_in(unit: AreaUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "2.0 m²".

Parameters:

  • unit

    (AreaUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

square_kilometers staticmethod

square_kilometers(value: float) -> Area

Creates an area from a value in square kilometers.

square_meters staticmethod

square_meters(value: float) -> Area

Creates an area from a value in square meters.

to

to(unit: AreaUnit) -> float

Returns the value in the given unit.

to_square_kilometers

to_square_kilometers() -> float

Returns the value in square kilometers.

to_square_meters

to_square_meters() -> float

Returns the value in square meters.

AreaUnit

A unit of Area.

Multiply a number by a unit to create a quantity, e.g. 2 * lox.m2.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m²".

Attributes:

symbol property

symbol: str

The unit symbol.


AreaToMass

An area-to-mass ratio, stored in SI units.

Create one by multiplying a number by a unit, e.g. 0.01 * lox.m2_per_kg, or with one of the static constructors named after the units, e.g. AreaToMass.square_meters_per_kilogram(0.01). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

display_in

display_in(unit: AreaToMassUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "0.01 m²/kg".

Parameters:

  • unit

    (AreaToMassUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

square_meters_per_kilogram staticmethod

square_meters_per_kilogram(value: float) -> AreaToMass

Creates an area-to-mass ratio from a value in square meters per kilogram.

to

to(unit: AreaToMassUnit) -> float

Returns the value in the given unit.

to_square_meters_per_kilogram

to_square_meters_per_kilogram() -> float

Returns the value in square meters per kilogram.

AreaToMassUnit

A unit of AreaToMass.

Multiply a number by a unit to create a quantity, e.g. 0.01 * lox.m2_per_kg.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m²/kg".

Attributes:

symbol property

symbol: str

The unit symbol.


DataRate

A data rate, stored in SI units.

Create one by multiplying a number by a unit, e.g. 150 * lox.Mbps, or with one of the static constructors named after the units, e.g. DataRate.megabits_per_second(150). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

bits_per_second staticmethod

bits_per_second(value: float) -> DataRate

Creates a data rate from a value in bits per second.

display_in

display_in(unit: DataRateUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "150.0 Mbit/s".

Parameters:

  • unit

    (DataRateUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

gigabits_per_second staticmethod

gigabits_per_second(value: float) -> DataRate

Creates a data rate from a value in gigabits per second.

kilobits_per_second staticmethod

kilobits_per_second(value: float) -> DataRate

Creates a data rate from a value in kilobits per second.

megabits_per_second staticmethod

megabits_per_second(value: float) -> DataRate

Creates a data rate from a value in megabits per second.

to

to(unit: DataRateUnit) -> float

Returns the value in the given unit.

to_bits_per_second

to_bits_per_second() -> float

Returns the value in bits per second.

to_gigabits_per_second

to_gigabits_per_second() -> float

Returns the value in gigabits per second.

to_kilobits_per_second

to_kilobits_per_second() -> float

Returns the value in kilobits per second.

to_megabits_per_second

to_megabits_per_second() -> float

Returns the value in megabits per second.

DataRateUnit

A unit of DataRate.

Multiply a number by a unit to create a quantity, e.g. 150 * lox.Mbps.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "bit/s".

Attributes:

symbol property

symbol: str

The unit symbol.


DataVolume

A data volume, stored in SI units.

Create one by multiplying a number by a unit, e.g. 4 * lox.GB, or with one of the static constructors named after the units, e.g. DataVolume.gigabytes(4). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • bits –

    Creates a data volume from a value in bits.

  • bytes –

    Creates a data volume from a value in bytes.

  • display_in –

    Returns the value formatted in the given unit, e.g. "4.0 GB".

  • gibibytes –

    Creates a data volume from a value in gibibytes (2³⁰ bytes).

  • gigabits –

    Creates a data volume from a value in gigabits.

  • gigabytes –

    Creates a data volume from a value in gigabytes (10⁹ bytes).

  • kibibytes –

    Creates a data volume from a value in kibibytes (2¹⁰ bytes).

  • kilobits –

    Creates a data volume from a value in kilobits.

  • kilobytes –

    Creates a data volume from a value in kilobytes (10³ bytes).

  • mebibytes –

    Creates a data volume from a value in mebibytes (2²⁰ bytes).

  • megabits –

    Creates a data volume from a value in megabits.

  • megabytes –

    Creates a data volume from a value in megabytes (10⁶ bytes).

  • tebibytes –

    Creates a data volume from a value in tebibytes (2⁴⁰ bytes).

  • terabits –

    Creates a data volume from a value in terabits.

  • terabytes –

    Creates a data volume from a value in terabytes (10¹² bytes).

  • to –

    Returns the value in the given unit.

  • to_bits –

    Returns the value in bits.

  • to_bytes –

    Returns the value in bytes.

  • to_gibibytes –

    Returns the value in gibibytes (2³⁰ bytes).

  • to_gigabits –

    Returns the value in gigabits.

  • to_gigabytes –

    Returns the value in gigabytes (10⁹ bytes).

  • to_kibibytes –

    Returns the value in kibibytes (2¹⁰ bytes).

  • to_kilobits –

    Returns the value in kilobits.

  • to_kilobytes –

    Returns the value in kilobytes (10³ bytes).

  • to_mebibytes –

    Returns the value in mebibytes (2²⁰ bytes).

  • to_megabits –

    Returns the value in megabits.

  • to_megabytes –

    Returns the value in megabytes (10⁶ bytes).

  • to_tebibytes –

    Returns the value in tebibytes (2⁴⁰ bytes).

  • to_terabits –

    Returns the value in terabits.

  • to_terabytes –

    Returns the value in terabytes (10¹² bytes).

bits staticmethod

bits(value: float) -> DataVolume

Creates a data volume from a value in bits.

bytes staticmethod

bytes(value: float) -> DataVolume

Creates a data volume from a value in bytes.

display_in

display_in(unit: DataVolumeUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "4.0 GB".

Parameters:

  • unit

    (DataVolumeUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

gibibytes staticmethod

gibibytes(value: float) -> DataVolume

Creates a data volume from a value in gibibytes (2³⁰ bytes).

gigabits staticmethod

gigabits(value: float) -> DataVolume

Creates a data volume from a value in gigabits.

gigabytes staticmethod

gigabytes(value: float) -> DataVolume

Creates a data volume from a value in gigabytes (10⁹ bytes).

kibibytes staticmethod

kibibytes(value: float) -> DataVolume

Creates a data volume from a value in kibibytes (2¹⁰ bytes).

kilobits staticmethod

kilobits(value: float) -> DataVolume

Creates a data volume from a value in kilobits.

kilobytes staticmethod

kilobytes(value: float) -> DataVolume

Creates a data volume from a value in kilobytes (10³ bytes).

mebibytes staticmethod

mebibytes(value: float) -> DataVolume

Creates a data volume from a value in mebibytes (2²⁰ bytes).

megabits staticmethod

megabits(value: float) -> DataVolume

Creates a data volume from a value in megabits.

megabytes staticmethod

megabytes(value: float) -> DataVolume

Creates a data volume from a value in megabytes (10⁶ bytes).

tebibytes staticmethod

tebibytes(value: float) -> DataVolume

Creates a data volume from a value in tebibytes (2⁴⁰ bytes).

terabits staticmethod

terabits(value: float) -> DataVolume

Creates a data volume from a value in terabits.

terabytes staticmethod

terabytes(value: float) -> DataVolume

Creates a data volume from a value in terabytes (10¹² bytes).

to

to(unit: DataVolumeUnit) -> float

Returns the value in the given unit.

to_bits

to_bits() -> float

Returns the value in bits.

to_bytes

to_bytes() -> float

Returns the value in bytes.

to_gibibytes

to_gibibytes() -> float

Returns the value in gibibytes (2³⁰ bytes).

to_gigabits

to_gigabits() -> float

Returns the value in gigabits.

to_gigabytes

to_gigabytes() -> float

Returns the value in gigabytes (10⁹ bytes).

to_kibibytes

to_kibibytes() -> float

Returns the value in kibibytes (2¹⁰ bytes).

to_kilobits

to_kilobits() -> float

Returns the value in kilobits.

to_kilobytes

to_kilobytes() -> float

Returns the value in kilobytes (10³ bytes).

to_mebibytes

to_mebibytes() -> float

Returns the value in mebibytes (2²⁰ bytes).

to_megabits

to_megabits() -> float

Returns the value in megabits.

to_megabytes

to_megabytes() -> float

Returns the value in megabytes (10⁶ bytes).

to_tebibytes

to_tebibytes() -> float

Returns the value in tebibytes (2⁴⁰ bytes).

to_terabits

to_terabits() -> float

Returns the value in terabits.

to_terabytes

to_terabytes() -> float

Returns the value in terabytes (10¹² bytes).

DataVolumeUnit

A unit of DataVolume.

Multiply a number by a unit to create a quantity, e.g. 4 * lox.GB.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "bit".

Attributes:

symbol property

symbol: str

The unit symbol.


Decibel

A ratio in decibels, stored in SI units.

Create one by multiplying a number by a unit, e.g. 3 * lox.dB, or with one of the static constructors named after the units, e.g. Decibel.decibels(3). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • decibels –

    Creates a ratio in decibels from a value in decibels.

  • display_in –

    Returns the value formatted in the given unit, e.g. "3.0 dB".

  • from_linear –

    Creates a value in decibels from a linear power ratio.

  • to –

    Returns the value in the given unit.

  • to_decibels –

    Returns the value in decibels.

  • to_linear –

    Returns the linear power ratio.

decibels staticmethod

decibels(value: float) -> Decibel

Creates a ratio in decibels from a value in decibels.

display_in

display_in(unit: DecibelUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "3.0 dB".

Parameters:

  • unit

    (DecibelUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

from_linear staticmethod

from_linear(value: float) -> Decibel

Creates a value in decibels from a linear power ratio.

to

to(unit: DecibelUnit) -> float

Returns the value in the given unit.

to_decibels

to_decibels() -> float

Returns the value in decibels.

to_linear

to_linear() -> float

Returns the linear power ratio.

DecibelUnit

A unit of Decibel.

Multiply a number by a unit to create a quantity, e.g. 3 * lox.dB.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "dB".

Attributes:

symbol property

symbol: str

The unit symbol.


DecibelWatts

A power level in dBW, stored in SI units.

Create one by multiplying a number by a unit, e.g. 10 * lox.dBW, or with one of the static constructors named after the units, e.g. DecibelWatts.decibel_watts(10). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

decibel_milliwatts staticmethod

decibel_milliwatts(value: float) -> DecibelWatts

Creates a power level in dBW from a value in dBm.

decibel_watts staticmethod

decibel_watts(value: float) -> DecibelWatts

Creates a power level in dBW from a value in dBW.

display_in

display_in(unit: DecibelWattsUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "10.0 dBW".

Parameters:

  • unit

    (DecibelWattsUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

to

to(unit: DecibelWattsUnit) -> float

Returns the value in the given unit.

to_decibel_milliwatts

to_decibel_milliwatts() -> float

Returns the value in dBm.

to_decibel_watts

to_decibel_watts() -> float

Returns the value in dBW.

to_power

to_power() -> Power

Returns the power level as a linear power.

DecibelWattsUnit

A unit of DecibelWatts.

Multiply a number by a unit to create a quantity, e.g. 10 * lox.dBW.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "dBW".

Attributes:

symbol property

symbol: str

The unit symbol.


Distance

A distance, stored in SI units.

Create one by multiplying a number by a unit, e.g. 7000 * lox.km, or with one of the static constructors named after the units, e.g. Distance.kilometers(7000). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • astronomical_units –

    Creates a distance from a value in astronomical units.

  • display_in –

    Returns the value formatted in the given unit, e.g. "7000.0 km".

  • kilometers –

    Creates a distance from a value in kilometers.

  • meters –

    Creates a distance from a value in meters.

  • to –

    Returns the value in the given unit.

  • to_astronomical_units –

    Returns the value in astronomical units.

  • to_kilometers –

    Returns the value in kilometers.

  • to_meters –

    Returns the value in meters.

astronomical_units staticmethod

astronomical_units(value: float) -> Distance

Creates a distance from a value in astronomical units.

display_in

display_in(unit: DistanceUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "7000.0 km".

Parameters:

  • unit

    (DistanceUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

kilometers staticmethod

kilometers(value: float) -> Distance

Creates a distance from a value in kilometers.

meters staticmethod

meters(value: float) -> Distance

Creates a distance from a value in meters.

to

to(unit: DistanceUnit) -> float

Returns the value in the given unit.

to_astronomical_units

to_astronomical_units() -> float

Returns the value in astronomical units.

to_kilometers

to_kilometers() -> float

Returns the value in kilometers.

to_meters

to_meters() -> float

Returns the value in meters.

DistanceUnit

A unit of Distance.

Multiply a number by a unit to create a quantity, e.g. 7000 * lox.km.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m".

Attributes:

symbol property

symbol: str

The unit symbol.


Frequency

A frequency, stored in SI units.

Create one by multiplying a number by a unit, e.g. 8.4 * lox.GHz, or with one of the static constructors named after the units, e.g. Frequency.gigahertz(8.4). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • display_in –

    Returns the value formatted in the given unit, e.g. "8.4 GHz".

  • gigahertz –

    Creates a frequency from a value in gigahertz.

  • hertz –

    Creates a frequency from a value in hertz.

  • kilohertz –

    Creates a frequency from a value in kilohertz.

  • megahertz –

    Creates a frequency from a value in megahertz.

  • terahertz –

    Creates a frequency from a value in terahertz.

  • to –

    Returns the value in the given unit.

  • to_gigahertz –

    Returns the value in gigahertz.

  • to_hertz –

    Returns the value in hertz.

  • to_kilohertz –

    Returns the value in kilohertz.

  • to_megahertz –

    Returns the value in megahertz.

  • to_terahertz –

    Returns the value in terahertz.

display_in

display_in(unit: FrequencyUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "8.4 GHz".

Parameters:

  • unit

    (FrequencyUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

gigahertz staticmethod

gigahertz(value: float) -> Frequency

Creates a frequency from a value in gigahertz.

hertz staticmethod

hertz(value: float) -> Frequency

Creates a frequency from a value in hertz.

kilohertz staticmethod

kilohertz(value: float) -> Frequency

Creates a frequency from a value in kilohertz.

megahertz staticmethod

megahertz(value: float) -> Frequency

Creates a frequency from a value in megahertz.

terahertz staticmethod

terahertz(value: float) -> Frequency

Creates a frequency from a value in terahertz.

to

to(unit: FrequencyUnit) -> float

Returns the value in the given unit.

to_gigahertz

to_gigahertz() -> float

Returns the value in gigahertz.

to_hertz

to_hertz() -> float

Returns the value in hertz.

to_kilohertz

to_kilohertz() -> float

Returns the value in kilohertz.

to_megahertz

to_megahertz() -> float

Returns the value in megahertz.

to_terahertz

to_terahertz() -> float

Returns the value in terahertz.

FrequencyUnit

A unit of Frequency.

Multiply a number by a unit to create a quantity, e.g. 8.4 * lox.GHz.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "Hz".

Attributes:

symbol property

symbol: str

The unit symbol.


GravitationalParameter

A gravitational parameter, stored in SI units.

Create one by multiplying a number by a unit, e.g. 398600.4418 * lox.km3_per_s2, or with one of the static constructors named after the units, e.g. GravitationalParameter.km3_per_s2(398600.4418). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • display_in –

    Returns the value formatted in the given unit, e.g. "398600.4418 km³/s²".

  • km3_per_s2 –

    Creates a gravitational parameter from a value in km³/s².

  • m3_per_s2 –

    Creates a gravitational parameter from a value in m³/s².

  • to –

    Returns the value in the given unit.

  • to_km3_per_s2 –

    Returns the value in km³/s².

  • to_m3_per_s2 –

    Returns the value in m³/s².

display_in

Returns the value formatted in the given unit, e.g. "398600.4418 km³/s²".

Parameters:

  • unit

    (GravitationalParameterUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

km3_per_s2 staticmethod

km3_per_s2(value: float) -> GravitationalParameter

Creates a gravitational parameter from a value in km³/s².

m3_per_s2 staticmethod

m3_per_s2(value: float) -> GravitationalParameter

Creates a gravitational parameter from a value in m³/s².

to

Returns the value in the given unit.

to_km3_per_s2

to_km3_per_s2() -> float

Returns the value in km³/s².

to_m3_per_s2

to_m3_per_s2() -> float

Returns the value in m³/s².

GravitationalParameterUnit

A unit of GravitationalParameter.

Multiply a number by a unit to create a quantity, e.g. 398600.4418 * lox.km3_per_s2.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m³/s²".

Attributes:

symbol property

symbol: str

The unit symbol.


Mass

A mass, stored in SI units.

Create one by multiplying a number by a unit, e.g. 500 * lox.kg, or with one of the static constructors named after the units, e.g. Mass.kilograms(500). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • display_in –

    Returns the value formatted in the given unit, e.g. "500.0 kg".

  • grams –

    Creates a mass from a value in grams.

  • kilograms –

    Creates a mass from a value in kilograms.

  • metric_tons –

    Creates a mass from a value in metric tons.

  • to –

    Returns the value in the given unit.

  • to_grams –

    Returns the value in grams.

  • to_kilograms –

    Returns the value in kilograms.

  • to_metric_tons –

    Returns the value in metric tons.

display_in

display_in(unit: MassUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "500.0 kg".

Parameters:

  • unit

    (MassUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

grams staticmethod

grams(value: float) -> Mass

Creates a mass from a value in grams.

kilograms staticmethod

kilograms(value: float) -> Mass

Creates a mass from a value in kilograms.

metric_tons staticmethod

metric_tons(value: float) -> Mass

Creates a mass from a value in metric tons.

to

to(unit: MassUnit) -> float

Returns the value in the given unit.

to_grams

to_grams() -> float

Returns the value in grams.

to_kilograms

to_kilograms() -> float

Returns the value in kilograms.

to_metric_tons

to_metric_tons() -> float

Returns the value in metric tons.

MassUnit

A unit of Mass.

Multiply a number by a unit to create a quantity, e.g. 500 * lox.kg.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "kg".

Attributes:

symbol property

symbol: str

The unit symbol.


Power

A power, stored in SI units.

Create one by multiplying a number by a unit, e.g. 20 * lox.W, or with one of the static constructors named after the units, e.g. Power.watts(20). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • display_in –

    Returns the value formatted in the given unit, e.g. "20.0 W".

  • kilowatts –

    Creates a power from a value in kilowatts.

  • to –

    Returns the value in the given unit.

  • to_decibel_watts –

    Returns the power as a level in dBW.

  • to_kilowatts –

    Returns the value in kilowatts.

  • to_watts –

    Returns the value in watts.

  • watts –

    Creates a power from a value in watts.

display_in

display_in(unit: PowerUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "20.0 W".

Parameters:

  • unit

    (PowerUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

kilowatts staticmethod

kilowatts(value: float) -> Power

Creates a power from a value in kilowatts.

to

to(unit: PowerUnit) -> float

Returns the value in the given unit.

to_decibel_watts

to_decibel_watts() -> DecibelWatts

Returns the power as a level in dBW.

to_kilowatts

to_kilowatts() -> float

Returns the value in kilowatts.

to_watts

to_watts() -> float

Returns the value in watts.

watts staticmethod

watts(value: float) -> Power

Creates a power from a value in watts.

PowerUnit

A unit of Power.

Multiply a number by a unit to create a quantity, e.g. 20 * lox.W.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "W".

Attributes:

symbol property

symbol: str

The unit symbol.


Pressure

A pressure, stored in SI units.

Create one by multiplying a number by a unit, e.g. 1013.25 * lox.hPa, or with one of the static constructors named after the units, e.g. Pressure.hectopascals(1013.25). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • display_in –

    Returns the value formatted in the given unit, e.g. "1013.25 hPa".

  • hectopascals –

    Creates a pressure from a value in hectopascals.

  • pascals –

    Creates a pressure from a value in pascals.

  • to –

    Returns the value in the given unit.

  • to_hectopascals –

    Returns the value in hectopascals.

  • to_pascals –

    Returns the value in pascals.

display_in

display_in(unit: PressureUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "1013.25 hPa".

Parameters:

  • unit

    (PressureUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

hectopascals staticmethod

hectopascals(value: float) -> Pressure

Creates a pressure from a value in hectopascals.

pascals staticmethod

pascals(value: float) -> Pressure

Creates a pressure from a value in pascals.

to

to(unit: PressureUnit) -> float

Returns the value in the given unit.

to_hectopascals

to_hectopascals() -> float

Returns the value in hectopascals.

to_pascals

to_pascals() -> float

Returns the value in pascals.

PressureUnit

A unit of Pressure.

Multiply a number by a unit to create a quantity, e.g. 1013.25 * lox.hPa.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "Pa".

Attributes:

symbol property

symbol: str

The unit symbol.


SpecificAngularMomentum

A specific angular momentum, stored in SI units.

Create one by multiplying a number by a unit, e.g. 52000 * lox.km2_per_s, or with one of the static constructors named after the units, e.g. SpecificAngularMomentum.square_kilometers_per_second(52000). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

display_in

Returns the value formatted in the given unit, e.g. "52000.0 km²/s".

Parameters:

  • unit

    (SpecificAngularMomentumUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

square_kilometers_per_second staticmethod

square_kilometers_per_second(value: float) -> SpecificAngularMomentum

Creates a specific angular momentum from a value in km²/s.

square_meters_per_second staticmethod

square_meters_per_second(value: float) -> SpecificAngularMomentum

Creates a specific angular momentum from a value in m²/s.

to

Returns the value in the given unit.

to_square_kilometers_per_second

to_square_kilometers_per_second() -> float

Returns the value in km²/s.

to_square_meters_per_second

to_square_meters_per_second() -> float

Returns the value in m²/s.

SpecificAngularMomentumUnit

A unit of SpecificAngularMomentum.

Multiply a number by a unit to create a quantity, e.g. 52000 * lox.km2_per_s.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m²/s".

Attributes:

symbol property

symbol: str

The unit symbol.


SpecificEnergy

A specific energy, stored in SI units.

Create one by multiplying a number by a unit, e.g. -29.6 * lox.km2_per_s2, or with one of the static constructors named after the units, e.g. SpecificEnergy.square_kilometers_per_second_squared(-29.6). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

display_in

display_in(unit: SpecificEnergyUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "-29.6 km²/s²".

Parameters:

  • unit

    (SpecificEnergyUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

square_kilometers_per_second_squared staticmethod

square_kilometers_per_second_squared(value: float) -> SpecificEnergy

Creates a specific energy from a value in km²/s².

square_meters_per_second_squared staticmethod

square_meters_per_second_squared(value: float) -> SpecificEnergy

Creates a specific energy from a value in m²/s² (J/kg).

to

Returns the value in the given unit.

to_square_kilometers_per_second_squared

to_square_kilometers_per_second_squared() -> float

Returns the value in km²/s².

to_square_meters_per_second_squared

to_square_meters_per_second_squared() -> float

Returns the value in m²/s² (J/kg).

SpecificEnergyUnit

A unit of SpecificEnergy.

Multiply a number by a unit to create a quantity, e.g. -29.6 * lox.km2_per_s2.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m²/s²".

Attributes:

symbol property

symbol: str

The unit symbol.


Temperature

A temperature, stored in SI units.

Create one by multiplying a number by a unit, e.g. 290 * lox.K, or with one of the static constructors named after the units, e.g. Temperature.kelvin(290). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

  • display_in –

    Returns the value formatted in the given unit, e.g. "290.0 K".

  • kelvin –

    Creates a temperature from a value in kelvin.

  • to –

    Returns the value in the given unit.

  • to_kelvin –

    Returns the value in kelvin.

display_in

display_in(unit: TemperatureUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "290.0 K".

Parameters:

  • unit

    (TemperatureUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

kelvin staticmethod

kelvin(value: float) -> Temperature

Creates a temperature from a value in kelvin.

to

to(unit: TemperatureUnit) -> float

Returns the value in the given unit.

to_kelvin

to_kelvin() -> float

Returns the value in kelvin.

TemperatureUnit

A unit of Temperature.

Multiply a number by a unit to create a quantity, e.g. 290 * lox.K.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "K".

Attributes:

symbol property

symbol: str

The unit symbol.


Velocity

A velocity, stored in SI units.

Create one by multiplying a number by a unit, e.g. 7.5 * lox.km_per_s, or with one of the static constructors named after the units, e.g. Velocity.kilometers_per_second(7.5). Convert it to a number with to(unit) or one of the to_* methods.

Methods:

astronomical_units_per_day staticmethod

astronomical_units_per_day(value: float) -> Velocity

Creates a velocity from a value in astronomical units per day.

display_in

display_in(unit: VelocityUnit, format_spec: str = '') -> str

Returns the value formatted in the given unit, e.g. "7.5 km/s".

Parameters:

  • unit

    (VelocityUnit) –

    The unit to display the value in.

  • format_spec

    (str, default: '' ) –

    A format spec for the number, e.g. ".3f".

fraction_of_speed_of_light staticmethod

fraction_of_speed_of_light(value: float) -> Velocity

Creates a velocity from a value in fractions of the speed of light.

kilometers_per_second staticmethod

kilometers_per_second(value: float) -> Velocity

Creates a velocity from a value in kilometers per second.

meters_per_second staticmethod

meters_per_second(value: float) -> Velocity

Creates a velocity from a value in meters per second.

to

to(unit: VelocityUnit) -> float

Returns the value in the given unit.

to_astronomical_units_per_day

to_astronomical_units_per_day() -> float

Returns the value in astronomical units per day.

to_fraction_of_speed_of_light

to_fraction_of_speed_of_light() -> float

Returns the value in fractions of the speed of light.

to_kilometers_per_second

to_kilometers_per_second() -> float

Returns the value in kilometers per second.

to_meters_per_second

to_meters_per_second() -> float

Returns the value in meters per second.

VelocityUnit

A unit of Velocity.

Multiply a number by a unit to create a quantity, e.g. 7.5 * lox.km_per_s.

Parameters:

  • symbol

    –

    The unit symbol, e.g. "m/s".

Attributes:

symbol property

symbol: str

The unit symbol.