Table Of Contents

Previous topic

Headers

Next topic

Tables

This Page

Cards

Inheritance diagram of Card, RecordValuedKeywordCard

Card

class pyfits.Card(key='', value='', comment='')

Bases: pyfits.verify._Verify

Construct a card from key, value, and (optionally) comment. Any specifed arguments, except defaults, must be compliant to FITS standard.

Parameters:
 

key : str, optional

keyword name

value : str, optional

keyword value

comment : str, optional

comment

ascardimage(*args, **kwargs)
classmethod fromstring(cardimage)

Construct a Card object from a (raw) string. It will pad the string if it is not the length of a card image (80 columns). If the card image is longer than 80 columns, assume it contains CONTINUE card(s).

run_option(option='warn', err_text='', fix_text='Fixed.', fix=None, fixable=True)

Execute the verification with selected option.

verify(option='warn')

Verify all values in the instance.

Parameters:
 

option : str

Output verification option. Must be one of "fix", "silentfix", "ignore", "warn", or "exception". See Verification options for more info.

cardimage
comment

Card comment

key

Card keyword

length = 80
value

Card value

RecordValuedKeywordCard

class pyfits.RecordValuedKeywordCard(key='', value='', comment='')

Bases: pyfits.card.Card

Class to manage record-valued keyword cards as described in the FITS WCS Paper IV proposal for representing a more general distortion model.

Record-valued keyword cards are string-valued cards where the string is interpreted as a definition giving a record field name, and its floating point value. In a FITS header they have the following syntax:

keyword = 'field-specifier: float'

where keyword is a standard eight-character FITS keyword name, float is the standard FITS ASCII representation of a floating point number, and these are separated by a colon followed by a single blank. The grammar for field-specifier is:

field-specifier:
    field
    field-specifier.field

field:
    identifier
    identifier.index

where identifier is a sequence of letters (upper or lower case), underscores, and digits of which the first character must not be a digit, and index is a sequence of digits. No blank characters may occur in the field-specifier. The index is provided primarily for defining array elements though it need not be used for that purpose.

Multiple record-valued keywords of the same name but differing values may be present in a FITS header. The field-specifier may be viewed as part of the keyword name.

Some examples follow:

DP1     = 'NAXIS: 2'
DP1     = 'AXIS.1: 1'
DP1     = 'AXIS.2: 2'
DP1     = 'NAUX: 2'
DP1     = 'AUX.1.COEFF.0: 0'
DP1     = 'AUX.1.POWER.0: 1'
DP1     = 'AUX.1.COEFF.1: 0.00048828125'
DP1     = 'AUX.1.POWER.1: 1'
Parameters:
 

key : str, optional

The key, either the simple key or one that contains a field-specifier

value : str, optional

The value, either a simple value or one that contains a field-specifier

comment : str, optional

The comment

ascardimage(*args, **kwargs)
classmethod coerce(card)

Coerces an input Card object to a RecordValuedKeywordCard object if the value of the card meets the requirements of this type of card.

Parameters:
 

card : Card object

A Card object to coerce

Returns:
 

card :

classmethod create(key='', value='', comment='')

Create a card given the input key, value, and comment. If the input key and value qualify for a RecordValuedKeywordCard then that is the object created. Otherwise, a standard Card object is created.

Parameters:
 

key : str, optional

The key

value : str, optional

The value

comment : str, optional

The comment

Returns:
 

card :

Either a RecordValuedKeywordCard or a Card object.

classmethod createCard(*args, **kwargs)

Create a card given the input key, value, and comment. If the input key and value qualify for a RecordValuedKeywordCard then that is the object created. Otherwise, a standard Card object is created.

Parameters:
 

key : str, optional

The key

value : str, optional

The value

comment : str, optional

The comment

Returns:
 

card :

Either a RecordValuedKeywordCard or a Card object.

classmethod createCardFromString(*args, **kwargs)

Create a card given the input string. If the input string can be parsed into a key and value that qualify for a RecordValuedKeywordCard then that is the object created. Otherwise, a standard Card object is created.

Parameters:
 

input : str

The string representing the card

Returns:
 

card :

either a RecordValuedKeywordCard or a Card object

classmethod fromstring(input)

Create a card given the input string. If the input string can be parsed into a key and value that qualify for a RecordValuedKeywordCard then that is the object created. Otherwise, a standard Card object is created.

Parameters:
 

input : str

The string representing the card

Returns:
 

card :

either a RecordValuedKeywordCard or a Card object

run_option(option='warn', err_text='', fix_text='Fixed.', fix=None, fixable=True)

Execute the verification with selected option.

strvalue()

Method to extract the field specifier and value from the card image. This is what is reported to the user when requesting the value of the Card using either an integer index or the card key without any field specifier.

classmethod upperKey(*args, **kwargs)

classmethod to convert a keyword value that may contain a field-specifier to uppercase. The effect is to raise the key to uppercase and leave the field specifier in its original case.

Parameters:
 

key : int or str

A keyword value that could be an integer, a key, or a key.field-specifier value

Returns:
 

Integer input :

the original integer key

String input :

the converted string

classmethod upper_key(key)

classmethod to convert a keyword value that may contain a field-specifier to uppercase. The effect is to raise the key to uppercase and leave the field specifier in its original case.

Parameters:
 

key : int or str

A keyword value that could be an integer, a key, or a key.field-specifier value

Returns:
 

Integer input :

the original integer key

String input :

the converted string

classmethod validKeyValue(*args, **kwargs)

Determine if the input key and value can be used to form a valid RecordValuedKeywordCard object. The key parameter may contain the key only or both the key and field-specifier. The value may be the value only or the field-specifier and the value together. The value parameter is optional, in which case the key parameter must contain both the key and the field specifier.

Parameters:
 

key : str

The key to parse

value : str or float-like, optional

The value to parse

Returns:
 

valid input : A list containing the key, field-specifier, value

invalid input : An empty list

Examples

>>> valid_key_value('DP1','AXIS.1: 2')
>>> valid_key_value('DP1.AXIS.1', 2)
>>> valid_key_value('DP1.AXIS.1')
classmethod valid_key_value(key, value=0)

Determine if the input key and value can be used to form a valid RecordValuedKeywordCard object. The key parameter may contain the key only or both the key and field-specifier. The value may be the value only or the field-specifier and the value together. The value parameter is optional, in which case the key parameter must contain both the key and the field specifier.

Parameters:
 

key : str

The key to parse

value : str or float-like, optional

The value to parse

Returns:
 

valid input : A list containing the key, field-specifier, value

invalid input : An empty list

Examples

>>> valid_key_value('DP1','AXIS.1: 2')
>>> valid_key_value('DP1.AXIS.1', 2)
>>> valid_key_value('DP1.AXIS.1')
verify(option='warn')

Verify all values in the instance.

Parameters:
 

option : str

Output verification option. Must be one of "fix", "silentfix", "ignore", "warn", or "exception". See Verification options for more info.

cardimage
comment

Card comment

field = '[a-zA-Z_]\\w*(\\.\\d+)?'
field_specifier
field_specifier_NFSC_image_RE = <_sre.SRE_Pattern object at 0x4089020>
field_specifier_NFSC_val = '(?P<keyword>[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*): (?P<val>[+-]? *(\\.\\d+|\\d+(\\.\\d*)?) *([deDE] *[+-]? *\\d+)?\\s*)'
field_specifier_NFSC_val_RE = <_sre.SRE_Pattern object at 0x4089780>
field_specifier_s = '[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*'
field_specifier_val = '(?P<keyword>[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*): (?P<val>[+-]?(\\.\\d+|\\d+(\\.\\d*)?)([DE][+-]?\\d+)?\\s*)'
identifier = '[a-zA-Z_]\\w*'
key

Card keyword

keyword_NFSC_val = "\\'(?P<keyword>[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*): (?P<val>[+-]? *(\\.\\d+|\\d+(\\.\\d*)?) *([deDE] *[+-]? *\\d+)?\\s*)\\'"
keyword_NFSC_val_comm = " +\\'(?P<keyword>[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*): (?P<val>[+-]? *(\\.\\d+|\\d+(\\.\\d*)?) *([deDE] *[+-]? *\\d+)?\\s*)\\' *(/ *(?P<comm>[ -~]*))?$"
keyword_NFSC_val_comm_RE = <_sre.SRE_Pattern object at 0x408bd10>
keyword_name_RE = <_sre.SRE_Pattern object at 0x3b7bd30>
keyword_val = "\\'(?P<keyword>[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*): (?P<val>[+-]?(\\.\\d+|\\d+(\\.\\d*)?)([DE][+-]?\\d+)?\\s*)\\'"
keyword_val_comm = " +\\'(?P<keyword>[a-zA-Z_]\\w*(\\.\\d+)?(\\.[a-zA-Z_]\\w*(\\.\\d+)?)*): (?P<val>[+-]?(\\.\\d+|\\d+(\\.\\d*)?)([DE][+-]?\\d+)?\\s*)\\' *(/ *(?P<comm>[ -~]*))?$"
keyword_val_comm_RE = <_sre.SRE_Pattern object at 0x4088a70>
length = 80
raw

Return this card as a normal Card object not parsed as a record-valued keyword card. Note that this returns a copy, so that modifications to it do not update the original record-valued keyword card.

value

Card value

Free functions

create_card

pyfits.create_card(key='', value='', comment='')

Create a card given the input key, value, and comment. If the input key and value qualify for a RecordValuedKeywordCard then that is the object created. Otherwise, a standard Card object is created.

Parameters:
 

key : str, optional

The key

value : str, optional

The value

comment : str, optional

The comment

Returns:
 

card :

Either a RecordValuedKeywordCard or a Card object.

create_card_from_string

pyfits.create_card_from_string(input)

Create a card given the input string. If the input string can be parsed into a key and value that qualify for a RecordValuedKeywordCard then that is the object created. Otherwise, a standard Card object is created.

Parameters:
 

input : str

The string representing the card

Returns:
 

card :

either a RecordValuedKeywordCard or a Card object

upper_key

pyfits.upper_key(key)

classmethod to convert a keyword value that may contain a field-specifier to uppercase. The effect is to raise the key to uppercase and leave the field specifier in its original case.

Parameters:
 

key : int or str

A keyword value that could be an integer, a key, or a key.field-specifier value

Returns:
 

Integer input :

the original integer key

String input :

the converted string