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
Creates an angle from a value in arcseconds.
display_in
display_in(unit: AngleUnit, format_spec: str = '') -> str
microarcseconds
staticmethod
Creates an angle from a value in microarcseconds.
microradians
staticmethod
Creates an angle from a value in microradians.
milliarcseconds
staticmethod
Creates an angle from a value in milliarcseconds.
AngleUnit
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–Creates an angular rate from a value in degrees per second.
-
display_in–Returns the value formatted in the given unit, e.g.
"15.0 deg/s". -
radians_per_second–Creates an angular rate from a value in radians per second.
-
to–Returns the value in the given unit.
-
to_degrees_per_second–Returns the value in degrees per second.
-
to_radians_per_second–Returns the value in radians per second.
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:
-
(unitAngularRateUnit) –The unit to display the value in.
-
(format_specstr, 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.
AngularRateUnit
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–Returns the value formatted in the given unit, e.g.
"2.0 m²". -
square_kilometers–Creates an area from a value in square kilometers.
-
square_meters–Creates an area from a value in square meters.
-
to–Returns the value in the given unit.
-
to_square_kilometers–Returns the value in square kilometers.
-
to_square_meters–Returns the value in square meters.
display_in
display_in(unit: AreaUnit, format_spec: str = '') -> str
square_kilometers
staticmethod
Creates an area from a value in square kilometers.
square_meters
staticmethod
Creates an area from a value in square meters.
AreaUnit
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–Returns the value formatted in the given unit, e.g.
"0.01 m²/kg". -
square_meters_per_kilogram–Creates an area-to-mass ratio from a value in square meters per kilogram.
-
to–Returns the value in the given unit.
-
to_square_meters_per_kilogram–Returns the value in square meters per kilogram.
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:
-
(unitAreaToMassUnit) –The unit to display the value in.
-
(format_specstr, 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_square_meters_per_kilogram
to_square_meters_per_kilogram() -> float
Returns the value in square meters per kilogram.
AreaToMassUnit
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–Creates a data rate from a value in bits per second.
-
display_in–Returns the value formatted in the given unit, e.g.
"150.0 Mbit/s". -
gigabits_per_second–Creates a data rate from a value in gigabits per second.
-
kilobits_per_second–Creates a data rate from a value in kilobits per second.
-
megabits_per_second–Creates a data rate from a value in megabits per second.
-
to–Returns the value in the given unit.
-
to_bits_per_second–Returns the value in bits per second.
-
to_gigabits_per_second–Returns the value in gigabits per second.
-
to_kilobits_per_second–Returns the value in kilobits per second.
-
to_megabits_per_second–Returns the value in megabits per second.
bits_per_second
staticmethod
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:
-
(unitDataRateUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
gigabits_per_second
staticmethod
Creates a data rate from a value in gigabits per second.
kilobits_per_second
staticmethod
Creates a data rate from a value in kilobits per second.
megabits_per_second
staticmethod
Creates a data rate from a value in megabits per second.
DataRateUnit
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).
display_in
display_in(unit: DataVolumeUnit, format_spec: str = '') -> str
Returns the value formatted in the given unit, e.g. "4.0 GB".
Parameters:
-
(unitDataVolumeUnit) –The unit to display the value in.
-
(format_specstr, 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).
DataVolumeUnit
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
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:
-
(unitDecibelUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
from_linear
staticmethod
Creates a value in decibels from a linear power ratio.
DecibelUnit
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–Creates a power level in dBW from a value in dBm.
-
decibel_watts–Creates a power level in dBW from a value in dBW.
-
display_in–Returns the value formatted in the given unit, e.g.
"10.0 dBW". -
to–Returns the value in the given unit.
-
to_decibel_milliwatts–Returns the value in dBm.
-
to_decibel_watts–Returns the value in dBW.
-
to_power–Returns the power level as a linear power.
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:
-
(unitDecibelWattsUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
DecibelWattsUnit
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
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:
-
(unitDistanceUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
kilometers
staticmethod
Creates a distance from a value in kilometers.
DistanceUnit
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:
-
(unitFrequencyUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
gigahertz
staticmethod
Creates a frequency from a value in gigahertz.
kilohertz
staticmethod
Creates a frequency from a value in kilohertz.
megahertz
staticmethod
Creates a frequency from a value in megahertz.
terahertz
staticmethod
Creates a frequency from a value in terahertz.
FrequencyUnit
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
display_in(unit: GravitationalParameterUnit, format_spec: str = '') -> str
Returns the value formatted in the given unit, e.g. "398600.4418 km³/s²".
Parameters:
-
(unitGravitationalParameterUnit) –The unit to display the value in.
-
(format_specstr, 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².
GravitationalParameterUnit
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
metric_tons
staticmethod
Creates a mass from a value in metric tons.
MassUnit
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
PowerUnit
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:
-
(unitPressureUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
hectopascals
staticmethod
Creates a pressure from a value in hectopascals.
PressureUnit
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". -
square_kilometers_per_second–Creates a specific angular momentum from a value in km²/s.
-
square_meters_per_second–Creates a specific angular momentum from a value in m²/s.
-
to–Returns the value in the given unit.
-
to_square_kilometers_per_second–Returns the value in km²/s.
-
to_square_meters_per_second–Returns the value in m²/s.
display_in
display_in(unit: SpecificAngularMomentumUnit, format_spec: str = '') -> str
Returns the value formatted in the given unit, e.g. "52000.0 km²/s".
Parameters:
-
(unitSpecificAngularMomentumUnit) –The unit to display the value in.
-
(format_specstr, 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_square_kilometers_per_second
to_square_kilometers_per_second() -> float
Returns the value in km²/s.
SpecificAngularMomentumUnit
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–Returns the value formatted in the given unit, e.g.
"-29.6 km²/s²". -
square_kilometers_per_second_squared–Creates a specific energy from a value in km²/s².
-
square_meters_per_second_squared–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–Returns the value in km²/s².
-
to_square_meters_per_second_squared–Returns the value in m²/s² (J/kg).
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:
-
(unitSpecificEnergyUnit) –The unit to display the value in.
-
(format_specstr, 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_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
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:
-
(unitTemperatureUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
kelvin
staticmethod
kelvin(value: float) -> Temperature
Creates a temperature from a value in kelvin.
TemperatureUnit
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–Creates a velocity from a value in astronomical units per day.
-
display_in–Returns the value formatted in the given unit, e.g.
"7.5 km/s". -
fraction_of_speed_of_light–Creates a velocity from a value in fractions of the speed of light.
-
kilometers_per_second–Creates a velocity from a value in kilometers per second.
-
meters_per_second–Creates a velocity from a value in meters per second.
-
to–Returns the value in the given unit.
-
to_astronomical_units_per_day–Returns the value in astronomical units per day.
-
to_fraction_of_speed_of_light–Returns the value in fractions of the speed of light.
-
to_kilometers_per_second–Returns the value in kilometers per second.
-
to_meters_per_second–Returns the value in meters per second.
astronomical_units_per_day
staticmethod
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:
-
(unitVelocityUnit) –The unit to display the value in.
-
(format_specstr, default:'') –A format spec for the number, e.g. ".3f".
fraction_of_speed_of_light
staticmethod
Creates a velocity from a value in fractions of the speed of light.
kilometers_per_second
staticmethod
Creates a velocity from a value in kilometers per second.
meters_per_second
staticmethod
Creates a velocity from a value in meters per second.
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.