Programming Previous page   Next Page

Working with Flexible Image Transport System (FITS) Files

MATLAB includes functions that let you import and export data using the Flexible Image Transport System (FITS) format. FITS is the standard data format used in astronomy, endorsed by both NASA and the International Astronomical Union (IAU). FITS is designed to store scientific data sets consisting of multidimensional arrays (1-D spectra, 2-D images, or 3-D data cubes) and two-dimensional tables containing rows and columns of data.

A data file in FITS format can contain multiple components, each marked by an ASCII text header followed by binary data. The first component in a FITS file is known as the primary, which can be followed by any number of other components, called extensions, in FITS terminology. For more information about the FITS standard, go to the official FITS Web site, fits.gsfc.nasa.gov/.

The MATLAB FITS functions are described in the following sections:

Getting Information About FITS Files

To get information about the contents of a FITS file, use the fitsinfo function. The fitsinfo function returns a structure containing the information about the file and detailed information about the data in the file.

This example returns information about a sample FITS file included with MATLAB. The structure returned contains fields for the primary component, PrimaryData, and all the extensions in the file, such as the BinaryTable, Image, and AsciiTable extensions.

Importing Data from a FITS File

To import data into the MATLAB workspace from a FITS file, use the fitsread function. Using this function, you can import the data in the PrimaryData section of the file or you can import the data in any of the extensions in the file, such as the Image extension. This example illustrates how to use the fitsread function to read data from a FITS file:

  1. Determine which extensions the FITS file contains, using the fitsinfo function.
  1. The info structure shows that the file contains several extensions including the BinaryTable, AsciiTable, and Image extensions.

  1. Read data from the file.
  1. To read the PrimaryData in the file, specify the filename as the only argument:

    To read any of the extensions in the file, you must specify the name of the extension as an optional parameter. This example reads the BinaryTable extension from the FITS file:


Previous page  Working with Common Data Format (CDF) Files Working with Hierarchical Data Format (HDF5) Files Next page

© 1994-2005 The MathWorks, Inc.