Table Of Contents

Previous topic

Headers

Next topic

Tables

This Page

Cards

Inheritance diagram of Card, RecordValuedKeywordCard

Card

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

Bases: pyfits.core._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(option='silentfix')

Generate a (new) card image from the attributes: key, value, and comment, or from raw string.

Parameters :
 

option : str

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

fromstring(input)

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='pass', fixable=1)

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.

RecordValuedKeywordCard

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

Bases: pyfits.core.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(option='silentfix')

Generate a (new) card image from the attributes: key, value, and comment, or from raw string.

Parameters :
 

option : str

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

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 :

  • If the input card is coercible:

    a new RecordValuedKeywordCard constructed from the key, value, and comment of the input card.

  • If the input card is not coercible:

    the input card

classmethod createCard(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 createCardFromString(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

fromstring(input)

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='pass', fixable=1)

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(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(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

>>> validKeyValue('DP1','AXIS.1: 2')
>>> validKeyValue('DP1.AXIS.1', 2)
>>> validKeyValue('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.

Free functions

createCard

pyfits.core.createCard(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.

createCardFromString

pyfits.core.createCardFromString(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

upperKey

pyfits.core.upperKey(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