yippy.header#
Module for handling FITS header data.
Classes#
A dataclass for storing the header data with units attached. |
Module Contents#
- class yippy.header.HeaderData[source]#
A dataclass for storing the header data with units attached.
I think this will be a useful system, however this has not been tested considerably. This is just a suggestion for a more robust way to keep the FITS header data attached to the coronagraph. Right now, the header data is loaded by Coronagraph from the stellar_intens file. This may make more sense if Offax, StellarIntens, and SkyTrans each load their own header.
- static extract_unit(comment, default_unit, key)[source]#
Extract a unit from the comment string of a FITS header entry.
This attempts to read the FITS header comment and search for an astropy Unit. This seems fairly robust, but it may not catch all cases in which case a warning is raised. It is also possible that the unit is not explicitly stated in the comment, in which case a default unit is returned.
- Args:
- comment (str):
The comment string associated with a FITS header key.
- default_unit (u.Unit):
The default unit to return if no unit is found in the comment.
- key (str):
The key of the header entry to extract the unit from.
- Returns:
- u.Unit:
The extracted astropy unit or the default unit if no recognizable unit is found.
- Raises:
- Warning:
Logs a warning if no unit could be extracted and the default unit is used.
- static get_header_value(header, key, default_unit)[source]#
Retrieves a header value by key and converts it to a specified unit.
- Args:
- header (fits.Header):
The FITS header from which to retrieve the value.
- key (str):
The key of the header entry to retrieve.
- default_unit (u.Unit):
The unit to associate with the returned value.
- Returns:
- Optional[u.Quantity]:
The header value with the specified unit, or None if the key is not present.
- Parameters:
header (astropy.io.fits.Header)
key (str)
default_unit (astropy.units.Unit)
- static from_fits_header(header)[source]#
Parses a FITS header.
This parses the FITS header to initialize the HeaderData class, checking for any unhandled fields.
- Args:
- header (fits.Header):
The FITS header to parse.
- Returns:
- HeaderData:
An initialized HeaderData object populated with values from the FITS header.
- Raises:
- Warning:
Logs a warning for any unhandled fields in the FITS header.
- Parameters:
header (astropy.io.fits.Header)