make_header

sofia_redux.instruments.fifi_ls.make_header.make_header(headers=None, checkheader=False, default_file=None, comment_file=None, check_all=False)[source]

Standardize and combine input headers.

Generates output headers for pipeline data products.

The procedure is:

  1. Read the header keyword defaults and requirements from data/headerdef.dat and their associated default comments from data/headercomment.dat.

  2. Copy the earliest header for symmetric mode, or earliest A header for C2NC2 mode. “Earliest” is defined by DATE-OBS.

  3. Loop through all keywords defined in headerdef.dat
    1. Get the value from the header as defined in the configuration algorithm. The combination options are: and (for booleans), concatendate unique values with commas (for string values), use default value, use last value (i.e. latest according to DATE-OBS), or (for booleans), sum (for numerical values), mean (for numerical values), use the first value. The default and most common case is to use the first value. The combined keyword value is written to the output header.

    2. Check the value against requirements if desired. Required keywords are checked for presence, checked against a specified data type (float, int, long, string, bool), and may additionally be checked against an enumerated value or min/max value range. If requirements are not met, or if a defined keyword is not found in the input header, it is set to the default value in the output header.

  4. Some additional values are added or modified in the output header:

    • ASSC_AOR is copied from AOR_ID if not present

    • ASSC_MSN is copied from MISSN-ID if not present

    • DATE is set to the current date/time

    • PROCSTAT is set to LEVEL_2 (unless it is already LEVEL_3 or LEVEL_4

    • FILENUM is set from the raw filename if not present, or from the range of input file numbers (first-last)

    • ASSC_OBS is copied from OBS_ID if not present

    • OBS_ID is prepended with P_ if not already done

Parameters:
headersarray_like of fits.Header, optional

array of input FITS headers

checkheaderbool, optional

If True, will check keywords against SOFIA requirements. If set, the return value will be a 2-tuple rather than a FITS header (see Return values).

default_filestr, optional

Path to the header keyword default file

comment_filestr, optional

Path to the header keyword comment file

check_allbool, optional

If checkheader is True and a failure was encountered, keep checking the remainder of the keyword values and output warning messages. Otherwise, the default is to return failure at the first bad keyword/value.

Returns:
fits.Header

a combined, standardized FITS header if checkheader is True then the return value will be a 2-tuple. The first element will be the header, and the second will be a boolean value indicating whether the header was created without any errors (False = errors were encountered).