merge_headers

astro_metadata_translator.merge_headers(headers, mode='overwrite')

Merge multiple headers into a single dict.

Given a list of dict-like data headers, combine them following the specified mode.

Parameters:
headers : list of dict (or dict-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.
Returns:
merged : dict

Single dict combining all the headers using the specified combination mode.