artiq/artiq/language/units.py
David Nadlinger f4d639242d units: Add nW (nanowatts)
We found this quite useful/common for laser beams.
2022-06-18 15:11:05 +08:00

23 lines
550 B
Python

__all__ = []
_prefixes_str = "pnum_kMG"
_smallest_prefix_exp = -12
def _register_unit(unit, prefixes):
exponent = _smallest_prefix_exp
for prefix in _prefixes_str:
if prefix in prefixes:
full_name = prefix + unit if prefix != "_" else unit
globals()[full_name] = 10.**exponent
__all__.append(full_name)
exponent += 3
_register_unit("s", "pnum_")
_register_unit("Hz", "m_kMG")
_register_unit("dB", "_")
_register_unit("V", "um_k")
_register_unit("A", "um_")
_register_unit("W", "num_")