merge_headers¶
-
astro_metadata_translator.
merge_headers
(headers, mode='overwrite', sort=False, first=None, last=None)¶ Merge multiple headers into a single dict.
Given a list of dict-like data headers, combine them following the specified mode.
Parameters: - headers :
list
ofdict
(ordict
-like) Collection of headers to combine.
PropertyList
is supported.- mode :
str
Scheme to use when a header has the same key as another header but different value. Options are:
'overwrite'
: Value in later header overwrites earlier value.'drop'
: Entire key is dropped.'first'
: Retain first value encountered.'append'
: Convert value to list with a value for each header (None
if the key was not present). If the value is identical in multiple headers but key is missing in some, then the single identical header is stored.
- sort :
bool
, optional If
True
, sort the supplied headers into date order if possible. This affects the resulting merged output depending on the requested merge mode. An attempt will be made to extract a date from the headers.- first :
list
ortuple
, optional Keys to retain even if they differ. For all modes excepting
append
(where it is ignored) the value in the merged header will always be the value first encountered. This is usually to allow time-dependent headers such asDATE-OBS
andAZSTART
to be retained to allow the header to indicate the range of values. No exception is raised if a key can not be found in a header since this allows a range of expected headers to be listed covering multiple instruments.- last :
list
ortuple
, optional Keys to retain even if they differ. For all modes excepting
append
(where it is ignored) the value in the merged header will always be the final value encountered. This is usually to allow time-dependent headers such asDATE-END
andAZEND
to be retained to allow the header to indicate the range of values. No exception is raised if a key can not be found in a header since this allows a range of expected headers to be listed covering multiple instruments.
Returns: Notes
If
first
andlast
are supplied, the keys fromfirst
are handled first, followed by the keys fromlast
. No check is made to ensure that the keys do not overlap.- headers :