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

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


header : FileHeader

One sunpy.io.header.FileHeader instance which was created by reading a FITS file. 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
>>> waveunit = extract_waveunit(header)
>>> if waveunit is not None:
...     unit = astropy.units.Unit(waveunit)