fits2hdf.idi module

idi.py

Abstract classes for python Header-Data unit object. This is similar to the HDU in FITS. Each HDU has a header dictionary and a data dictionary. The data dictionary can be converted into a pandas DataFrame object, and there are a few view / verify items also.

class fits2hdf.idi.IdiColumn(*args, **kwargs)

Bases: astropy.table.column.Column

IDI version of astropy.table Column()

This subclasses the astropy.table Column() class, to provide an equivalent comment object for IDI data conversion. This subclass adds the ability to name the column

name: string
name of column. This is a required argument for IdiColumn, and must be the first argument. Column name and key for reference within Table
data : list, ndarray or None
Column data values
dtype : numpy.dtype compatible value
Data type for column
shape : tuple or ()
Dimensions of a single row element in the column data
length : int or 0
Number of row elements in column data
description : str or None
Full description of column
unit : str or None
Physical unit
format : str or None or function or callable
Format string for outputting column values. This can be an “old-style” (format % value) or “new-style” (str.format) format specification string or a function or any callable object that accepts a single value and returns a string.
meta : dict-like or None
Meta-data associated with the column
class fits2hdf.idi.IdiComment(comment=None)

Bases: list

Class for storing comments within a HDU

This stores comments as a list of strings. The FITS ‘COMMENT’ keyword should be stripped, and only the actual comment should be passed.

comment: list, string, or None
Comment values to be used in initialization (more can be added later by using the append method / other list methods).
class fits2hdf.idi.IdiHdulist(*args, **kwds)

Bases: collections.OrderedDict

OrderedDict subclass for a dictionary of Header-data units (HDU).

This is used as a container equivalent to the FITS HDUList. This can be initialized with no arguments, then HDUs may be appended to it using regular ordered dict methods

dict_data: dict
This class can be initialized with zero arguments, or you can pass a python-style dictionary.
add_image_hdu(name, header=None, data=None, history=None, comment=None)

Add a Image HDU to HDU list

name: str
Name for table HDU
header=None: dict
Header keyword:value pairs dictionary. optional
data=None: np.ndarray or equivalent
Array that contains the image data
history=None: list
list of history data
comment=None: list
list of comments
add_primary_hdu(name, header=None, history=None, comment=None)

Add a Primary HDU to HDU list. This should not have a data payload.

name: str
Name for table HDU
header=None: dict
Header keyword:value pairs dictionary. optional
history=None: list
list of history data
comment=None: list
list of comments
add_table_hdu(name, header=None, data=None, history=None, comment=None)

Add a Table HDU to HDU list

name: str
Name for table HDU
header=None: dict
Header keyword:value pairs dictionary. optional
data=None: IdiTableHdu
IdiTableHdu that contains the data
history=None: list
list of history data
comment=None: list
list of comments
keys()
values()
class fits2hdf.idi.IdiHeader(values=None)

Bases: collections.OrderedDict

Header unit for storing header information

This object stores a header dictionary. For FITS files, order is important (particularly for HISTORY cards); but HDF5 does not assign any ordering to attributes. As such, order may be lost in translation between the two formats.

Comments should be passed to this object as dictionary entries with keys key_COMMENT, e.g. CARD1: 1.20, CARD1_COMMENT: ‘Example entry’

values: dict
Dictionary of header keyword : value pairs.
class fits2hdf.idi.IdiHistory(history)

Bases: fits2hdf.idi.IdiComment

Class for storing history within a HDU

This stores history log notes as a list of strings. The FITS ‘HISTORY’ keyword should be stripped and only actual history log should be passed.

history: list, string, or None
Comment values to be used in initialization (more can be added later by using the append method / other list methods).
class fits2hdf.idi.IdiImageHdu(*args, **kwargs)

Bases: astropy.nddata.nddata.NDData

Header-data unit for storing table data

stores header dictionary and data dictionary

name : string
Name of HDU. Required.
comment : list
List of comments. Optional
history : list
List of history entries. Optional
header: dict
Header dictionary of keyword:value pairs. Optional
data: dict
dictionary of key:value pairs, where data are stored as numpy arrays
class fits2hdf.idi.IdiPrimaryHdu(name, header=None, history=None, comment=None)

Bases: collections.OrderedDict

Header-data unit for storing PRIMARY metadata

This is used for storing the FITS / HDFITS PRIMARY HDU, where there is NO data payload. Otherwise, the IdiImageHdu should be used.

name : string
Name of HDU. Required.
comment : list
List of comments. Optional
history : list
List of history entries. Optional
header: dict
Header dictionary of keyword:value pairs. Optional
class fits2hdf.idi.IdiTableHdu(*args, **kwargs)

Bases: astropy.table.table.Table

Header-data unit for storing table data

This subclasses the astropy.table Table() class. It attaches comments, history and a header to make it a “HDU”, instead of just a Table

name : string
Name of HDU. Required.
comment : list
List of comments. Optional
history : list
List of history entries. Optional
header: dict
Header dictionary of keyword:value pairs. Optional
data : numpy ndarray, dict, list, or Table, optional
Data to initialize table.
mask : numpy ndarray, dict, list, optional
The mask to initialize the table
names : list, optional
Specify column names
dtypes : list, optional
Specify column data types
meta : dict, optional
Metadata associated with the table
copy : boolean, optional
Copy the input data (default=True).
exception fits2hdf.idi.VerificationError

Bases: exceptions.Exception

Custom data verification exception