insert_into_header

sofia_redux.scan.utilities.utils.insert_into_header(header, key, value, comment=None, refkey='HISTORY', after=False, delete_special=False)[source]

Insert a key, value into the header at a specific location.

The key will always be inserted at the desired location. If it already exists in the header, the old value will be removed before insertion.

Parameters:
headerfits.Header

The header in which to insert the key.

keystr

The name of the header key to insert.

valuestr or object

The value of the header key.

commentstr, optional

An optional header comment. If None and the key already exists in the header, the old comment will be used instead.

refkeystr, optional

A key in the header marking the location at which to insert key. If not present in the header, the key will be inserted in the standard manner.

afterbool, optional

If True, insert key after refkey. If False, insert key before refkey.

delete_specialbool, optional

If True, allow deletion of previous HISTORY and COMMENT entries containing the same value.

Returns:
None