Programming |
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.
info = fitsinfo('tst0012.fits') info = Filename: 'tst0012.fits' FileModDate: '12-Mar-2001 18:37:46' FileSize: 109440 Contents: {1x5 cell} PrimaryData: [1x1 struct] BinaryTable: [1x1 struct] Unknown: [1x1 struct] Image: [1x1 struct] AsciiTable: [1x1 struct]
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:
info
structure shows that the file contains several extensions including the BinaryTable
, AsciiTable
, and Image
extensions.
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:
Note
To read the BinaryTable extension using fitsread , you must specify the parameter 'bintable' . Similarly, to read the AsciiTable extension, you must specify the parameter 'table' . See the fitsread reference page for more information.
|
Working with Common Data Format (CDF) Files | Working with Hierarchical Data Format (HDF5) Files |
© 1994-2005 The MathWorks, Inc.