Bases: _abcoll.MutableMapping
FITS header class.
The purpose of this class is to present the header like a dictionary as opposed to a list of cards.
The attribute ascard supplies the header like a list of cards.
The header class uses the card’s keyword as the dictionary key and the cards value is the dictionary value.
The has_key, get, and keys methods are implemented to provide the corresponding dictionary functionality. The header may be indexed by keyword value and like a dictionary, 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.
The header may also be indexed by card list index number. In that case, the value of the card at the given index in the card list will be returned.
A delete method has been implemented to allow deletion from the header. When del is called, all cards with the given keyword are deleted from the header.
The Header class has an associated iterator class _Header_iter which will allow iteration over the unique keywords in the header dictionary.
Construct a Header from a CardList and/or text file.
Parameters: | |
---|---|
cards : A list of Card objects, optional
txtfile : file path, file object or file-like object, optional
|
Add a blank card.
Parameters: | |
---|---|
value : str, optional
before : str or int, optional
after : str or int, optional
|
Add a COMMENT card.
Parameters: | |
---|---|
value : str
before : str or int, optional
after : str or int, optional
|
Add a HISTORY card.
Parameters: | |
---|---|
value : str
before : str or int, optional
after : str or int, optional
|
Make a copy of the Header.
Parameters: | |
---|---|
strip : bool, optional
|
Input the header parameters from an ASCII file.
The input header cards will be used to update the current header. Therefore, when an input card key matches a card key that already exists in the header, that card will be updated in place. Any input cards that do not already exist in the header will be added. Cards will not be deleted from the header.
Parameters: | |
---|---|
fileobj : file path, file object or file-like object
replace : bool, optional
|
Creates an HDU header from a byte string containing the entire header data.
Parameters: | |
---|---|
data : str
|
Get all comment cards as a list of string texts.
Get all history cards as a list of string texts.
Check for existence of a keyword.
Parameters: | |
---|---|
key : str or int
|
|
Returns: | |
has_key : bool |
Override items since the default implementation does not propertly handle duplicate keywords.
Override iteritems since the default implementation does not properly handle duplicate keywords.
Override itervalues since the default implementation does not properly handle duplicate keywords.
Return a list of keys with duplicates removed.
Warning
There is a surprising incogruity in Header objecets between Header.keys() and Header.iterkeys(). The latter does not remove duplicates. This incongruity exists for historical reasons, but is not be design. In PyFITS 3.1 it is done away with, and :meth:Header.keys returns the exact keywords appearin the header, including duplicates.
If key is not found, d is returned if given, otherwise KeyError is raised.
as a 2-tuple; but raise KeyError if D is empty.
Rename a card’s keyword in the header.
Parameters: | |
---|---|
oldkey : str or int
newkey : str
force : bool
|
PyFITS < 3.1 won’t allow item assignment to keywords that don’t already exist, but for the setdefault dict method to work at all, it needs to be able to add nonexistent keywords with the default value.
Output the header parameters to a file in ASCII format.
Parameters: | |
---|---|
fileobj : file path, file object or file-like object
clobber : bool
|
Update one header card.
If the keyword already exists, it’s value and/or comment will be updated. If it does not exist, a new card will be created and it will be placed before or after the specified location. If no before or after is specified, it will be appended at the end.
Parameters: | |
---|---|
key : str
value : str
comment : str, optional
before : str or int, optional
after : str or int, optional
savecomment : bool, optional
|
Override values since the default implementation does not properly handle duplicate keywords.
Bases: list
FITS header card list class.
Construct the CardList object from a list of Card objects.
Parameters: | |
---|---|
cards :
|
Append a Card to the CardList.
Parameters: | |
---|---|
card : Card object
useblanks : bool, optional
bottom : bool, optional |
Returns how many blank cards are directly before the END card.
Construct a CardList that contains references to all of the cards in this CardList that match the input key value including any special filter keys (*, ?, and ...).
Parameters: | |
---|---|
key : str
|
|
Returns: | |
cardlist : :
|
Construct a CardList that contains references to all of the cards in this CardList that match the input key value including any special filter keys (*, ?, and ...).
Parameters: | |
---|---|
key : str
|
|
Returns: | |
cardlist : :
|
Get the index of a keyword in the CardList.
Parameters: | |
---|---|
key : str or int
backward : bool, optional
|
|
Returns: | |
index : int
|
Insert a Card to the CardList.
Parameters: | |
---|---|
pos : int
card : Card object
useblanks : bool, optional |
Return a list of all keywords from the CardList.
Keywords include field_specifier for RecordValuedKeywordCard objects.
Return a list of the values of all cards in the CardList.
For RecordValuedKeywordCard objects, the value returned is the floating point value, exclusive of the field_specifier.