add_enabled_aliases#

astropy.units.add_enabled_aliases(aliases)[source]#

Add aliases for units.

This is useful for handling alternate spellings for units, or misspelled units in files one is trying to read.

Since no aliases are enabled by default, generally it is recommended to use set_enabled_aliases.

Parameters:
aliasesdict of str, Unit

The aliases to add. The keys must be the string aliases, and values must be the astropy.units.Unit that the alias will be mapped to.

Raises:
ValueError

If the alias already defines a different unit.

Examples

To temporarily allow for a misspelled ‘Angstroem’ unit:

>>> from astropy import units as u
>>> with u.add_enabled_aliases({'Angstroem': u.Angstrom}):
...     print(u.Unit("Angstroem", parse_strict="raise") == u.Angstrom)
True