cosmiq.units#

Units. cosmiq computes in µs, µm and rad/µs; these multipliers convert into them.

from cosmiq.units import us, ns, um, MHz
duration = 250 * ns         # 0.25 (µs)
omega = 1.5 * MHz           # 9.424777... (rad/µs), since 1 MHz = 2π rad/µs

Plain numbers mean µs, µm, rad/µs and rad. MHz is an input and display unit only; nothing is stored in MHz.

format_frequency

An angular frequency for people, in both units: "15.080 rad/µs (2π·2.400 MHz)".

MHz

kHz

m

ms

nm

ns

rad_per_us

s

um

us

Functions

cosmiq.units.format_frequency(value: float, *, versus: float | None = None) → str#

An angular frequency for people, in both units: "15.080 rad/µs (2π·2.400 MHz)".

Three decimals; magnitudes below 0.01 or from 1e7 up switch to scientific notation, so a resolution such as 1e-6 rad/µs doesn’t print as zero. The sign goes in front of \(2\pi\).

versus is a value shown beside this one, such as the limit it’s compared with. When the two differ but their MHz parts would print the same, the MHz part gets the digits that tell them apart: 15.079 rad/µs against the limit \(2\pi \cdot 2.4\,\mathrm{MHz}\) is "(2π·2.3999 MHz)".

Values

cosmiq.units.MHz: float = 6.283185307179586#
cosmiq.units.kHz: float = 0.006283185307179587#
cosmiq.units.m: float = 1000000.0#
cosmiq.units.ms: float = 1000.0#
cosmiq.units.nm: float = 0.001#
cosmiq.units.ns: float = 0.001#
cosmiq.units.rad_per_us: float = 1.0#
cosmiq.units.s: float = 1000000.0#
cosmiq.units.um: float = 1.0#
cosmiq.units.us: float = 1.0#