add_enabled_units#
- astropy.units.add_enabled_units(units)[源代码]#
添加到在单位注册表中启用的单位集。
使用时会搜索这些单位
UnitBase.find_equivalent_units
例如。它可以永久使用,也可以作为上下文管理器使用
with
语句(见下面的示例)。- 参数:
- units :
list
的 sequence ,dict
,或 modulePYTHON:PYTHON:SEQUENCE、PYTHON:DICT或PYTHON:MODULE的列表 这是一个列表,其中可以找到单元(序列、指令或模块),或单元本身。整个集合将被添加到“enabled”集合中,以便通过以下方法进行搜索
UnitBase.find_equivalent_units
和UnitBase.compose
.
- units :
实例
>>> from astropy import units as u >>> from astropy.units import imperial >>> with u.add_enabled_units(imperial): ... u.m.find_equivalent_units() ... Primary name | Unit definition | Aliases [ AU | 1.49598e+11 m | au, astronomical_unit , Angstrom | 1e-10 m | AA, angstrom , cm | 0.01 m | centimeter , earthRad | 6.3781e+06 m | R_earth, Rearth , ft | 0.3048 m | foot , fur | 201.168 m | furlong , inch | 0.0254 m | , jupiterRad | 7.1492e+07 m | R_jup, Rjup, R_jupiter, Rjupiter , lsec | 2.99792e+08 m | lightsecond , lyr | 9.46073e+15 m | lightyear , m | irreducible | meter , mi | 1609.34 m | mile , micron | 1e-06 m | , mil | 2.54e-05 m | thou , nmi | 1852 m | nauticalmile, NM , pc | 3.08568e+16 m | parsec , solRad | 6.957e+08 m | R_sun, Rsun , yd | 0.9144 m | yard , ]