Table Of Contents

Previous topic

Supported Formats

Next topic

VO tables

This Page

FITS tables

Note

The Flexible Image Transport System (FITS) format is a widely used file format in Astronomy, that is used to store, transmit, and manipulate images and tables. FITS tables contain one or more header-data units (HDU) which can be either images or tables in ASCII or binary format. Tables can contain meta-data, stored in the header.

Overview

FITS tables are supported thanks to the pyfits module. Reading FITS tables is straightforward:

>>> t = atpy.Table('table.fits')

If more than one table is present in the file, the HDU can be specified:

>>> t = atpy.Table('table.fits', hdu=2)

To read in all HDUs in a file, use the TableSet class:

>>> t = atpy.TableSet('table.fits')

Compressed FITS files can be read easily:

>>> t = atpy.Table('table.fits.gz')

In the event that ATpy does not recognize a FITS table (for example if the file extension is obscure), the type can be explicitly given:

>>> t = atpy.Table('table', type='fits')

Note

As for all file formats, the verbose argument can be specified to control whether warning messages are shown when reading (the default is verbose=True), and the overwrite argument can be used when writing to overwrite a file (the default is overwrite=False).

Full API for advanced users

Note

The following functions should not be called directly - the arguments should be passed to Table()/Table.read(), Table.write(), TableSet()/TableSet.read(), and TableSet.write() respectively.

atpy.fitstable.read(self, filename, hdu=None, memmap=False, verbose=True)

Read a table from a FITS file

Required Arguments:

filename: [ string ]
The FITS file to read the table from

Optional Keyword Arguments:

hdu: [ integer ]
The HDU to read from the FITS file (this is only required if there are more than one table in the FITS file)
memmap: [ bool ]
Whether PyFITS should use memory mapping
atpy.fitstable.write(self, filename, overwrite=False)

Write the table to a FITS file

Required Arguments:

filename: [ string ]
The FITS file to write the table to

Optional Keyword Arguments:

overwrite: [ True | False ]
Whether to overwrite any existing file without warning
atpy.fitstable.read_set(self, filename, memmap=False, verbose=True)

Read all tables from a FITS file

Required Arguments:

filename: [ string ]
The FITS file to read the tables from

Optional Keyword Arguments:

memmap: [ bool ]
Whether PyFITS should use memory mapping
atpy.fitstable.write_set(self, filename, overwrite=False)

Write the tables to a FITS file

Required Arguments:

filename: [ string ]
The FITS file to write the tables to

Optional Keyword Arguments:

overwrite: [ True | False ]
Whether to overwrite any existing file without warning