Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Importing Flexible Image Transport System (FITS) Files

The FITS file format is the standard data format used in astronomy, endorsed by both NASA and the International Astronomical Union (IAU). For more information about the FITS standard, go to the FITS Web site, http://fits.gsfc.nasa.gov/.

The FITS file format 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 a complete list of extensions, see fitsread.

To get information about the contents of a Flexible Image Transport System (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.

To import data into the MATLAB® workspace from a Flexible Image Transport System (FITS) file, use the fitsread function. Using this function, you can import the primary data in the file or you can import the data in any of the extensions in the file, such as the Image extension, as shown in this example.

  1. Determine which extensions the FITS file contains, using the fitsinfo function.

    info = fitsinfo('tst0012.fits')
    
    info = 
    
           Filename: 'matlabroot\tst0012.fits'
        FileModDate: '12-Mar-2001 19:37:46'
           FileSize: 109440
           Contents: {'Primary'  'Binary Table'  'Unknown'  'Image'  'ASCII Table'}
        PrimaryData: [1x1 struct]
        BinaryTable: [1x1 struct]
            Unknown: [1x1 struct]
              Image: [1x1 struct]
         AsciiTable: [1x1 struct]

    The info structure shows that the file contains several extensions including the Binary Table, ASCII Table, and Image extensions.

  2. Read data from the file.

    To read the Primary data in the file, specify the filename as the only argument:

    pdata = fitsread('tst0012.fits');

    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 Binary Table extension from the FITS file:

    bindata = fitsread('tst0012.fits','binarytable');
Was this topic helpful?