2015-06-30 02:36:20 +08:00
|
|
|
__all__ = []
|
|
|
|
|
2014-11-23 08:56:51 +08:00
|
|
|
_prefixes_str = "pnum_kMG"
|
2015-06-26 22:20:13 +08:00
|
|
|
_smallest_prefix_exp = -12
|
2014-09-05 12:03:22 +08:00
|
|
|
|
2014-05-17 20:08:50 +08:00
|
|
|
|
2014-10-05 21:01:08 +08:00
|
|
|
def _register_unit(unit, prefixes):
|
2015-06-26 22:20:13 +08:00
|
|
|
exponent = _smallest_prefix_exp
|
2014-09-05 12:03:22 +08:00
|
|
|
for prefix in _prefixes_str:
|
|
|
|
if prefix in prefixes:
|
2014-10-05 21:01:08 +08:00
|
|
|
full_name = prefix + unit if prefix != "_" else unit
|
2015-06-26 22:20:13 +08:00
|
|
|
globals()[full_name] = 10.**exponent
|
2015-06-30 02:36:20 +08:00
|
|
|
__all__.append(full_name)
|
2015-06-26 22:20:13 +08:00
|
|
|
exponent += 3
|
|
|
|
|
2014-05-17 20:08:50 +08:00
|
|
|
|
2014-08-13 17:52:01 +08:00
|
|
|
_register_unit("s", "pnum_")
|
2018-05-23 01:36:02 +08:00
|
|
|
_register_unit("Hz", "m_kMG")
|
2015-01-09 22:09:17 +08:00
|
|
|
_register_unit("dB", "_")
|
2015-02-21 00:37:54 +08:00
|
|
|
_register_unit("V", "um_k")
|
2016-10-13 06:45:17 +08:00
|
|
|
_register_unit("A", "um_")
|
2017-03-07 08:17:40 +08:00
|
|
|
_register_unit("W", "um_")
|