The astro_metadata_translator package provides generalized infrastructure for handling metadata extraction for astronomical instrumentation.

There are header translation classes implemented as subclasses of MetadataTranslator. These translation subclasses implement methods corresponding to each derived property defined in ObservationInfo. The methods are named to_{property} and can be implemented explicitly by a translation class, or implicitly by defining trivial mappings from a header item to a property, or constant mappings that are fixed for all headers independent of any header values. Defining a new translator subclass that inherits from MetadataTranslator and giving it a name, automatically registers the translator as being available for automated header translation. A translation class does not need to reside in the astro_metadata_translator package.

ObservationInfo is a class summarizing the information from the translators. An instance of this class can be instantiated from any dict-like header. By default the header translation class to use is determined by asking each registered translator whether it knows how to translate it. If an explicit translation class should be used it can be specified explicitly.


The existing set of property names in ObservationInfo should be considered as beta quality. Some of the names could yet be changed for consistency with other data dictionaries.

Command Line Utilities

Summarize headers from astronomical data files

usage: [-h] [-q] [-d] [--traceback] [-n HDRNUM] [-r REGEX]
                           [-p PACKAGES]
                           file [file ...]

positional arguments


File(s) from which headers will be parsed. If a directory is given it will be scanned for files matching the regular expression defined in –regex.

optional arguments

-h, --help

show this help message and exit

-q, --quiet

Do not report the translation content from each header

-d, --dumphdr

Dump the header in YAML format to standard output rather than translating it


Give detailed trace back when any errors encountered

-n <hdrnum>, --hdrnum <hdrnum>

HDU number to read. If the HDU can not be found, a warning is issued but translation is attempted using the primary header. The primary header is always read and merged with this header.

-r <regex>, --regex <regex>

When looking in a directory, regular expression to use to determine whether a file should be examined. Default: ‘.fit[s]?b’

-p <packages>, --packages <packages>

Python packages to import to register additional translators

Python API reference

astro_metadata_translator Package


cache_translation(func[, method]) Decorator to cache the result of a translation method.
fix_header(header[, search_path, …]) Update, in place, the supplied header with known corrections.
makeObservationInfo(**kwargs) Construct an ObservationInfo from the supplied parameters.
merge_headers(headers[, mode, sort, first, last]) Merge multiple headers into a single dict.


DecamTranslator(header[, filename]) Metadata translator for DECam standard headers.
FitsTranslator(header[, filename]) Metadata translator for FITS standard headers.
HscTranslator(header[, filename]) Metadata translator for HSC standard headers.
MegaPrimeTranslator(header[, filename]) Metadata translator for CFHT MegaPrime standard headers.
MetadataTranslator(header[, filename]) Per-instrument metadata translation support
ObservationGroup(members[, …]) A collection of ObservationInfo headers.
ObservationInfo(header[, filename, …]) Standardized representation of an instrument header for a single exposure observation.
SdssTranslator(header[, filename]) Metadata translator for SDSS standard headers.
StubTranslator(header[, filename]) Translator where all the translations are stubbed out and issue warnings.
SubaruTranslator(header[, filename]) Metadata translator for Subaru telescope headers.
SuprimeCamTranslator(header[, filename]) Metadata translator for HSC standard headers.

Class Inheritance Diagram

Inheritance diagram of astro_metadata_translator.translators.decam.DecamTranslator, astro_metadata_translator.translators.fits.FitsTranslator, astro_metadata_translator.translators.hsc.HscTranslator, astro_metadata_translator.translators.megaprime.MegaPrimeTranslator, astro_metadata_translator.translator.MetadataTranslator, astro_metadata_translator.observationGroup.ObservationGroup, astro_metadata_translator.observationInfo.ObservationInfo, astro_metadata_translator.translators.sdss.SdssTranslator, astro_metadata_translator.translator.StubTranslator, astro_metadata_translator.translators.subaru.SubaruTranslator, astro_metadata_translator.translators.suprimecam.SuprimeCamTranslator

astro_metadata_translator.bin.translateheader Module

Implementation of the script.

Read file metadata from the specified files and report the translated content.


main() Read metadata from the supplied files and translate the content to standard form.
process_files(files, regex, hdrnum, dumphdr, …) Read and translate metadata from the specified files.