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.
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).
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.
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
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
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
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