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
|
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 : | |
---|---|
inFile : file path, file object or file-like object
replace : bool, optional
|
Get a keyword value from the CardList. If no keyword is found, return the default value.
Parameters : | |
---|---|
key : str or int
default : object, optional
|
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 |
Return a list of keys with duplicates removed.
Rename a card’s keyword in the header.
Parameters : | |
---|---|
oldkey : str or int
newkey : str
force : bool
|
Output the header parameters to a file in ASCII format.
Parameters : | |
---|---|
outFile : 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
|
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 : :
|
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.