Bases: pyfits.hdu.table._TableBaseHDU
Binary table HDU class.
Parameters: | |
---|---|
header : Header instance
data : array
name : str
|
Add the CHECKSUM and DATASUM cards to this HDU with the values set to the checksum calculated for the HDU and the data respectively. The addition of the DATASUM card may be overridden.
Parameters: | |
---|---|
when : str, optional
override_datasum : bool, optional
blocking: str, optional :
|
Notes
For testing purposes, first call add_datasum with a when argument, then call add_checksum with a when argument and override_datasum set to True. This will provide consistent comments for both cards and enable the generation of a CHECKSUM card with a consistent value.
Add the DATASUM card to this HDU with the value set to the checksum calculated for the data.
Parameters: | |
---|---|
when : str, optional
blocking: str, optional :
|
|
Returns: | |
checksum : int
|
Notes
For testing purposes, provide a when argument to enable the comment value in the card to remain consistent. This will enable the generation of a CHECKSUM card with a consistent value.
Make a copy of the table HDU, both header and data are copied.
Calculates and returns the number of bytes that this HDU will write to a file.
Parameters: | |
---|---|
None : | |
Returns: | |
Number of bytes : |
Returns a dictionary detailing information about the locations of this HDU within any associated file. The values are only valid after a read or write of the associated file with no intervening changes to the HDUList.
Parameters: | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
None : |
|||||||||||||
Returns: | |||||||||||||
dictionary or None :
|
Creates a new HDU object of the appropriate type from a string containing the HDU’s entire header and, optionally, its data.
Parameters: | |
---|---|
data : str
fileobj : file, optional
offset : int, optional
checksum : bool optional
ignore_missing_end : bool, optional
kwargs : optional
|
[Deprecated] Returns the table’s column definitions.
Read the HDU from a file. Normally an HDU should be opened with fitsopen() which reads the entire HDU list in a FITS file. But this method is still provided for symmetry with writeto().
Parameters: | |
---|---|
fileobj : file object or file-like object
checksum : bool
ignore_missing_end : bool
|
Check the existence, location, and value of a required Card.
TODO: Write about parameters
If pos = None, it can be anywhere. If the card does not exist, the new card will have the fix_value as its value when created. Also check the card’s value by using the test argument.
Execute the verification with selected option.
Size (in bytes) of the data portion of the HDU.
Create a table from the input ASCII files. The input is from up to three separate files, one containing column definitions, one containing header parameters, and one containing column data. The column definition and header parameters files are not required. When absent the column definitions and/or header parameters are taken from the current values in this HDU.
Parameters: | |
---|---|
datafile : file path, file object or file-like object
cdfile : file path, file object, file-like object, optional
hfile : file path, file object, file-like object, optional
replace : bool
|
Notes
The primary use for the tcreate method is to allow the input of ASCII data that was edited in a standard text editor of the table data and parameters. The tdump method can be used to create the initial ASCII files.
datafile: Each line of the data file represents one row of table data. The data is output one column at a time in column order. If a column contains an array, each element of the column array in the current row is output before moving on to the next column. Each row ends with a new line.
Integer data is output right-justified in a 21-character field followed by a blank. Floating point data is output right justified using ‘g’ format in a 21-character field with 15 digits of precision, followed by a blank. String data that does not contain whitespace is output left-justified in a field whose width matches the width specified in the TFORM header parameter for the column, followed by a blank. When the string data contains whitespace characters, the string is enclosed in quotation marks (""). For the last data element in a row, the trailing blank in the field is replaced by a new line character.
For column data containing variable length arrays (‘P’ format), the array data is preceded by the string 'VLA_Length= ' and the integer length of the array for that row, left-justified in a 21-character field, followed by a blank.
For column data representing a bit field (‘X’ format), each bit value in the field is output right-justified in a 21-character field as 1 (for true) or 0 (for false).
cdfile: Each line of the column definitions file provides the definitions for one column in the table. The line is broken up into 8, sixteen-character fields. The first field provides the column name (TTYPEn). The second field provides the column format (TFORMn). The third field provides the display format (TDISPn). The fourth field provides the physical units (TUNITn). The fifth field provides the dimensions for a multidimensional array (TDIMn). The sixth field provides the value that signifies an undefined value (TNULLn). The seventh field provides the scale factor (TSCALn). The eighth field provides the offset value (TZEROn). A field value of "" is used to represent the case where no value is provided.
hfile: Each line of the header parameters file provides the definition of a single HDU header card as represented by the card image.
Dump the table HDU to a file in ASCII format. The table may be dumped in three separate files, one containing column definitions, one containing header parameters, and one for table data.
Parameters: | |
---|---|
datafile : file path, file object or file-like object, optional
cdfile : file path, file object or file-like object, optional
hfile : file path, file object or file-like object, optional
clobber : bool
|
Notes
The primary use for the tdump method is to allow editing in a standard text editor of the table data and parameters. The tcreate method can be used to reassemble the table from the three ASCII files.
datafile: Each line of the data file represents one row of table data. The data is output one column at a time in column order. If a column contains an array, each element of the column array in the current row is output before moving on to the next column. Each row ends with a new line.
Integer data is output right-justified in a 21-character field followed by a blank. Floating point data is output right justified using ‘g’ format in a 21-character field with 15 digits of precision, followed by a blank. String data that does not contain whitespace is output left-justified in a field whose width matches the width specified in the TFORM header parameter for the column, followed by a blank. When the string data contains whitespace characters, the string is enclosed in quotation marks (""). For the last data element in a row, the trailing blank in the field is replaced by a new line character.
For column data containing variable length arrays (‘P’ format), the array data is preceded by the string 'VLA_Length= ' and the integer length of the array for that row, left-justified in a 21-character field, followed by a blank.
For column data representing a bit field (‘X’ format), each bit value in the field is output right-justified in a 21-character field as 1 (for true) or 0 (for false).
cdfile: Each line of the column definitions file provides the definitions for one column in the table. The line is broken up into 8, sixteen-character fields. The first field provides the column name (TTYPEn). The second field provides the column format (TFORMn). The third field provides the display format (TDISPn). The fourth field provides the physical units (TUNITn). The fifth field provides the dimensions for a multidimensional array (TDIMn). The sixth field provides the value that signifies an undefined value (TNULLn). The seventh field provides the scale factor (TSCALn). The eighth field provides the offset value (TZEROn). A field value of "" is used to represent the case where no value is provided.
hfile: Each line of the header parameters file provides the definition of a single HDU header card as represented by the card image.
Update header keywords to reflect recent changes of columns.
Update the extension name associated with the HDU.
If the keyword already exists in the Header, 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: | |
---|---|
value : str
comment : str, optional
before : str or int, optional
after : str or int, optional
savecomment : bool, optional
|
Update the extension version associated with the HDU.
If the keyword already exists in the Header, 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: | |
---|---|
value : str
comment : str, optional
before : str or int, optional
after : str or int, optional
savecomment : bool, optional
|
Verify all values in the instance.
Parameters: | |
---|---|
option : str
|
Verify that the value in the CHECKSUM keyword matches the value calculated for the current HDU CHECKSUM.
Returns: | |
---|---|
valid : int
|
Verify that the value in the DATASUM keyword matches the value calculated for the DATASUM of the current HDU data.
Returns: | |
---|---|
valid : int
|
Works similarly to the normal writeto(), but prepends a default PrimaryHDU are required by extension HDUs (which cannot stand on their own).
Works similarly to property(), but computes the value only once.
Adapted from the recipe at http://code.activestate.com/recipes/363602-lazy-property-evaluation
Works similarly to property(), but computes the value only once.
Adapted from the recipe at http://code.activestate.com/recipes/363602-lazy-property-evaluation
Bases: pyfits.hdu.table._TableBaseHDU
FITS ASCII table extension HDU class.
Add the CHECKSUM and DATASUM cards to this HDU with the values set to the checksum calculated for the HDU and the data respectively. The addition of the DATASUM card may be overridden.
Parameters: | |
---|---|
when : str, optional
override_datasum : bool, optional
blocking: str, optional :
|
Notes
For testing purposes, first call add_datasum with a when argument, then call add_checksum with a when argument and override_datasum set to True. This will provide consistent comments for both cards and enable the generation of a CHECKSUM card with a consistent value.
Add the DATASUM card to this HDU with the value set to the checksum calculated for the data.
Parameters: | |
---|---|
when : str, optional
blocking: str, optional :
|
|
Returns: | |
checksum : int
|
Notes
For testing purposes, provide a when argument to enable the comment value in the card to remain consistent. This will enable the generation of a CHECKSUM card with a consistent value.
Make a copy of the table HDU, both header and data are copied.
Calculates and returns the number of bytes that this HDU will write to a file.
Parameters: | |
---|---|
None : | |
Returns: | |
Number of bytes : |
Returns a dictionary detailing information about the locations of this HDU within any associated file. The values are only valid after a read or write of the associated file with no intervening changes to the HDUList.
Parameters: | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
None : |
|||||||||||||
Returns: | |||||||||||||
dictionary or None :
|
Creates a new HDU object of the appropriate type from a string containing the HDU’s entire header and, optionally, its data.
Parameters: | |
---|---|
data : str
fileobj : file, optional
offset : int, optional
checksum : bool optional
ignore_missing_end : bool, optional
kwargs : optional
|
[Deprecated] Returns the table’s column definitions.
Read the HDU from a file. Normally an HDU should be opened with fitsopen() which reads the entire HDU list in a FITS file. But this method is still provided for symmetry with writeto().
Parameters: | |
---|---|
fileobj : file object or file-like object
checksum : bool
ignore_missing_end : bool
|
Check the existence, location, and value of a required Card.
TODO: Write about parameters
If pos = None, it can be anywhere. If the card does not exist, the new card will have the fix_value as its value when created. Also check the card’s value by using the test argument.
Execute the verification with selected option.
Size (in bytes) of the data portion of the HDU.
Update header keywords to reflect recent changes of columns.
Update the extension name associated with the HDU.
If the keyword already exists in the Header, 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: | |
---|---|
value : str
comment : str, optional
before : str or int, optional
after : str or int, optional
savecomment : bool, optional
|
Update the extension version associated with the HDU.
If the keyword already exists in the Header, 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: | |
---|---|
value : str
comment : str, optional
before : str or int, optional
after : str or int, optional
savecomment : bool, optional
|
Verify all values in the instance.
Parameters: | |
---|---|
option : str
|
Verify that the value in the CHECKSUM keyword matches the value calculated for the current HDU CHECKSUM.
Returns: | |
---|---|
valid : int
|
Verify that the value in the DATASUM keyword matches the value calculated for the DATASUM of the current HDU data.
Returns: | |
---|---|
valid : int
|
Works similarly to the normal writeto(), but prepends a default PrimaryHDU are required by extension HDUs (which cannot stand on their own).
Works similarly to property(), but computes the value only once.
Adapted from the recipe at http://code.activestate.com/recipes/363602-lazy-property-evaluation
Works similarly to property(), but computes the value only once.
Adapted from the recipe at http://code.activestate.com/recipes/363602-lazy-property-evaluation
Bases: object
Class which contains the definition of one column, e.g. ttype, tform, etc. and the array containing values for the column. Does not support theap yet.
Construct a Column by specifying attributes. All attributes except format can be optional.
Parameters: | |
---|---|
name : str, optional
format : str, optional
unit : str, optional
null : str, optional
bscale : int-like, optional
bzero : int-like, optional
disp : str, optional
start : int, optional
dim : str, optional
|
Bases: object
Column definitions class.
It has attributes corresponding to the Column attributes (e.g. ColDefs has the attribute names while Column has name). Each attribute in ColDefs is a list of corresponding attribute values from all Column objects.
Parameters: | |
---|---|
input : :
**(Deprecated) tbtype** : str, optional
|
Change an attribute (in the commonName list) of a Column.
Change a Column‘s name.
Change a Column‘s unit.
Delete (the definition of) one Column.
Get attribute(s) information of the column definition.
Parameters: | |
---|---|
attrib : str
output : file, optional
|
Notes
This function doesn’t return anything by default; it just prints to stdout.
What was originally self.columns is now self.data; this provides some backwards compatibility.
Bases: object
FITS record class.
FITS_record is used to access records of the FITS_rec object. This will allow us to deal with scaled columns. It also handles conversion/scaling of columns in ASCII tables. The FITS_record class expects a FITS_rec object as input.
Parameters: | |
---|---|
input : array
row : int, optional
start : int, optional
end : int, optional
|
Get the field data of the record.
Set the field data of the record.
Bases: numpy.core.records.recarray
FITS record array class.
FITS_rec is the data part of a table HDU’s data part. This is a layer over the recarray, so we can deal with scaled columns.
It inherits all of the standard methods from numpy.ndarray.
x.__init__(...) initializes x; see help(type(x)) for signature
A user-visible accessor for the coldefs. See ticket #44.
Create a new table from the input column definitions.
Warning: Creating a new table using this method creates an in-memory copy of all the column arrays in the input. This is because if they are separate arrays they must be combined into a single contiguous array.
If the column data is already in a single contiguous array (such as an existing record array) it may be better to create a BinTableHDU instance directly. See the PyFITS documentation for more details.
Parameters: | |
---|---|
input : sequence of Column or ColDefs objects
header : Header instance
nrows : int
fill : bool tbtype : str
|
Dump a table HDU to a file in ASCII format. The table may be dumped in three separate files, one containing column definitions, one containing header parameters, and one for table data.
Parameters: | |
---|---|
filename : file path, file object or file-like object
datafile : file path, file object or file-like object (optional)
cdfile : file path, file object or file-like object (optional)
hfile : file path, file object or file-like object (optional)
ext : int
clobber : bool
|
Notes
The primary use for the tdump function is to allow editing in a standard text editor of the table data and parameters. The tcreate function can be used to reassemble the table from the three ASCII files.
datafile: Each line of the data file represents one row of table data. The data is output one column at a time in column order. If a column contains an array, each element of the column array in the current row is output before moving on to the next column. Each row ends with a new line.
Integer data is output right-justified in a 21-character field followed by a blank. Floating point data is output right justified using ‘g’ format in a 21-character field with 15 digits of precision, followed by a blank. String data that does not contain whitespace is output left-justified in a field whose width matches the width specified in the TFORM header parameter for the column, followed by a blank. When the string data contains whitespace characters, the string is enclosed in quotation marks (""). For the last data element in a row, the trailing blank in the field is replaced by a new line character.
For column data containing variable length arrays (‘P’ format), the array data is preceded by the string 'VLA_Length= ' and the integer length of the array for that row, left-justified in a 21-character field, followed by a blank.
For column data representing a bit field (‘X’ format), each bit value in the field is output right-justified in a 21-character field as 1 (for true) or 0 (for false).
cdfile: Each line of the column definitions file provides the definitions for one column in the table. The line is broken up into 8, sixteen-character fields. The first field provides the column name (TTYPEn). The second field provides the column format (TFORMn). The third field provides the display format (TDISPn). The fourth field provides the physical units (TUNITn). The fifth field provides the dimensions for a multidimensional array (TDIMn). The sixth field provides the value that signifies an undefined value (TNULLn). The seventh field provides the scale factor (TSCALn). The eighth field provides the offset value (TZEROn). A field value of "" is used to represent the case where no value is provided.
hfile: Each line of the header parameters file provides the definition of a single HDU header card as represented by the card image.
Create a table from the input ASCII files. The input is from up to three separate files, one containing column definitions, one containing header parameters, and one containing column data. The header parameters file is not required. When the header parameters file is absent a minimal header is constructed.
Parameters: | |
---|---|
datafile : file path, file object or file-like object
cdfile : file path, file object or file-like object
hfile : file path, file object or file-like object (optional)
|
Notes
The primary use for the tcreate function is to allow the input of ASCII data that was edited in a standard text editor of the table data and parameters. The tdump function can be used to create the initial ASCII files.
datafile: Each line of the data file represents one row of table data. The data is output one column at a time in column order. If a column contains an array, each element of the column array in the current row is output before moving on to the next column. Each row ends with a new line.
Integer data is output right-justified in a 21-character field followed by a blank. Floating point data is output right justified using ‘g’ format in a 21-character field with 15 digits of precision, followed by a blank. String data that does not contain whitespace is output left-justified in a field whose width matches the width specified in the TFORM header parameter for the column, followed by a blank. When the string data contains whitespace characters, the string is enclosed in quotation marks (""). For the last data element in a row, the trailing blank in the field is replaced by a new line character.
For column data containing variable length arrays (‘P’ format), the array data is preceded by the string 'VLA_Length= ' and the integer length of the array for that row, left-justified in a 21-character field, followed by a blank.
For column data representing a bit field (‘X’ format), each bit value in the field is output right-justified in a 21-character field as 1 (for true) or 0 (for false).
cdfile: Each line of the column definitions file provides the definitions for one column in the table. The line is broken up into 8, sixteen-character fields. The first field provides the column name (TTYPEn). The second field provides the column format (TFORMn). The third field provides the display format (TDISPn). The fourth field provides the physical units (TUNITn). The fifth field provides the dimensions for a multidimensional array (TDIMn). The sixth field provides the value that signifies an undefined value (TNULLn). The seventh field provides the scale factor (TSCALn). The eighth field provides the offset value (TZEROn). A field value of "" is used to represent the case where no value is provided.
hfile: Each line of the header parameters file provides the definition of a single HDU header card as represented by the card image.