FITS header class. This class exposes both a dict-like interface and a list-like interface to FITS headers.
The header may be indexed by keyword and, like a dict, the associated value will be returned. When the header contains cards with duplicate keywords, only the value of the first card with the given keyword will be returned. It is also possible to use a 2-tuple as the index in the form (keyword, n)–this returns the n-th value with that keyword, in the case where there are duplicate keywords.
For example:
>>> header['NAXIS']0>>> header[('FOO', 1)] # Return the value of the second FOO keyword'foo'
The header may also be indexed by card number:
>>> header[0] # Return the value of the first card in the header'T'
Commentary keywords such as HISTORY and COMMENT are special cases: When indexing the Header object with either ‘HISTORY’ or ‘COMMENT’ a list of all the HISTORY/COMMENT values is returned:
>>> header['HISTORY']This is the first history entry in this header.This is the second history entry in this header....
See the Astropy documentation for more details on working with headers.
Notes:
Although FITS keywords must be exclusively upper case, retrieving an item in a Header object is case insensitive.
Construct a Header from an iterable and/or text file.
Parameters:
cards: list of Card, optional
The cards to initialize the header with. Also allowed are other Header (or dict -like) objects.
Changed in version 1.2: Allowed cards to be a dict -like object.
copy: bool, optional
If True copies the cards if they were another Header instance. Default is False.