| MATLAB® | ![]() |
| On this page… |
|---|
To get information about the contents of a Flexible Image Transport System (FITS) file, use the fitsinfo function. 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 official FITS Web site, http://fits.gsfc.nasa.gov/.
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. 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]To import data into the MATLAB workspace from a Flexible Image Transport System (FITS) file, use the fitsread function. 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. 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:
Determine which extensions the FITS file contains, using the fitsinfo function.
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]The info structure shows that the file contains several extensions including the BinaryTable, AsciiTable, and Image extensions.
To read the PrimaryData 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 BinaryTable extension from the FITS file:
bindata = fitsread('tst0012.fits','bintable');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. |
![]() | Network Common Data Form (netCDF) Files | Hierarchical Data Format (HDF5) Files | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |