Skip to main content
`Ctrl`+`K`

# set_enabled_units

astropy.units.set_enabled_units(units)

  Sets the units enabled in the unit registry.

  These units are searched when using `UnitBase.find_equivalent_units`, for example.

  This may be used either permanently, or as a context manager using the `with` statement (see example below).

  Parameters:
    units `python:list` of python:sequence, `python:dict`, or python:module

      This is a list of things in which units may be found (sequences, dicts or modules), or units themselves. The entire set will be “enabled” for searching through by methods like `UnitBase.find_equivalent_units` and `UnitBase.compose`.

  Examples

      >>> from astropy import units as u
      >>> with u.set_enabled_units([u.pc]):
      ...     u.m.find_equivalent_units()
      ...
        Primary name | Unit definition | Aliases
      [
        pc           | 3.08568e+16 m   | parsec  ,
      ]
      >>> 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                  ,
        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                            ,
        micron       | 1e-06 m         |                                  ,
        pc           | 3.08568e+16 m   | parsec                           ,
        solRad       | 6.957e+08 m     | R_sun, Rsun                      ,
      ]