readhdr

sofia_redux.instruments.exes.readhdr.readhdr(header, check_header=True, config_file=None, comments_file=None)[source]

Read and update an EXES FITS header.

Keywords that must be present in the output header are defined in exes/data/header/headerdef.dat. Default values and acceptable ranges are also defined there. For each keyword defined there, the header is checked for a value. If it is found, the value is added to the output header.

If checkreq=True, it is checked against the allowed values. If it is out of range, header_ok will be set to False. If the value is not found, the default value is added. If it is missing and required, header_ok will be set to False, but the value will be updated.

Some additional special values are added to the output header:

  • Comments associated with all keywords are read from exes/data/header/headercomment.dat.

  • The full path to the package containing this routine is stored under the key ‘PKGPATH’.

  • The full path to the package/data directory is stored under the key ‘DATAPATH’.

  • Distortion correction parameters are read from exes/data/tort/*.dat and added to the output header. Some additional parameters are calculated from these and other header parameters and added to the output header.

  • The slit angle is converted from degrees to cm using the values in exes/data/slitval.dat.

  • Filenames for BPM, LINFILE, and DARKFILE are looked up by date from exes/data/caldefault.dat.

  • The current date is added under the key ‘DATE’.

Parameters:
headerfits.Header

The FITS header to check and update.

check_headerbool, optional

If True, check against header requirements and return success or failure status.

config_filestr, optional

Path to the headerdef.dat header defaults configuration file

comments_filestr, optional

Path to the headercomment.dat header keyword comments file

Returns:
updated_headerfits.Header

The updated FITS header

successbool, optional

True if header checks succeeded; False if they did not.

Raises:
ValueError if header is incorrectly formatted.