fix_header¶
- astro_metadata_translator.fix_header(header: MutableMapping[str, Any], search_path: str | Sequence[str] | None = None, translator_class: type[astro_metadata_translator.translator.MetadataTranslator] | None = None, filename: str | None = None) bool ¶
Update, in place, the supplied header with known corrections.
- Parameters:
- header
dict
-like Header to correct.
- search_path
list
orstr
, optional Explicit directory paths to search for correction files. A single directory path can be given as a string.
- translator_class
MetadataTranslator
-class, optional If not
None
, the class to use to translate the supplied headers into standard form. Otherwise each registered translator class will be asked in turn if it knows how to translate the supplied header.- filename
str
, optional Name of the file whose header is being translated. For some datasets with missing header information this can sometimes allow for some fixups in translations.
- header
- Returns:
- Raises:
- TypeError
Raised if the supplied translation class is not a
MetadataTranslator
.
Notes
In order to determine that a header update is required it is necessary for the header to be handled by the supplied translator class or else support automatic translation class determination. It is also required that the
observation_id
andinstrument
be calculable prior to header fix up. If a translator class can not be found or if there is a problem determining the instrument or observation ID, the function will return without action.Correction files use names of the form
instrument-obsid.yaml
(for exampleLATISS-AT_O_20190329_000022.yaml
). The YAML file should have the format of:EXPTIME: 30.0 IMGTYPE: bias
where each key/value pair is copied directly into the supplied header, overwriting any previous values.
This function searches a number of locations for such a correction file. The search order is:
Any paths explicitly supplied through
search_path
.The contents of the PATH-like environment variable
$METADATA_CORRECTIONS_PATH
.Any search paths supplied by the matching translator class.
The first file located in the search path is used for the correction.