sunpy.io.fits.extract_waveunit(header)[source] [edit on github]

Attempt to read the wavelength unit from a given FITS header.


header (sunpy.io.header.FileHeader) – One FileHeader instance which was created by reading a FITS file. For example, sunpy.io.fits.get_header returns a list of such instances.


waveunit (str) – The wavelength unit that could be found or None otherwise.


The goal of this function is to return a string that can be used in conjunction with the astropy.units module so that the return value can be directly passed to astropy.units.Unit.

>>> import astropy.units
>>> header = {'WAVEUNIT': 'Angstrom', 'KEYCOMMENTS': {}}
>>> waveunit = extract_waveunit(header)
>>> if waveunit is not None:
...     unit = astropy.units.Unit(waveunit)