read_basic_metadata_from_file

astro_metadata_translator.file_helpers.read_basic_metadata_from_file(file: str, hdrnum: int, can_raise: bool = True) MutableMapping[str, Any] | None

Read a raw header from a file, merging if necessary.

Parameters:
filestr

Name of file to read. Can be FITS, YAML or JSON. YAML or JSON must be a simple top-level dict.

hdrnumint

Header number to read. Only relevant for FITS. If greater than 1 it will be merged with the primary header. If a negative number is given the second header, if present, will be merged with the primary header. If there is only a primary header a negative number behaves identically to specifying 0 for the HDU number.

can_raisebool, optional

Indicate whether the function can raise an exception (default) or should return None on error. Can still raise if an unexpected error is encountered.

Returns:
headerdict

The header as a dict. Can be None if there was a problem reading the file.