FITS I/O with IDL can be accomplished using the IDL Astronomy Library from the GSFC. The IDL Astronomy Library contains four different sets of procedures for reading, writing, and modifying FITS files. The reason for having four different methods of FITS I/O with IDL is partly historical, as different groups developed the software independently. However, each method also has its own strengths and weakness for any particular task. For example, the procedure MRDFITS()--which can read a FITS table into an IDL structure--is the easiest procedure for analyzing FITS files at the IDL prompt level (provided that one is comfortable with IDL structures). But mapping a table into an IDL structure includes extra overhead, so that when performing FITS I/O at the procedure level, it may be desirable to use more efficient procedures such as FITS_READ and FTAB_EXT.
For example a data cube can be read into an IDL array using the FXREAD method.
; Read the FITS file
fxread, 'ifu_file.fit', DATA, HEADER
; Determine the size of the image
SIZEX=fxpar(header, 'NAXIS1')
SIZEY=fxpar(header, 'NAXIS2')
SIZEZ=fxpar(header, 'NAXIS3')
; Find the data type being read
DTYPE=fxpar(header, 'BITPIX')
As can be seen, various values contained within the FITS header of the original file can be obtained using the FXPAR procedure.
Alternatively the MRDFITS procedure can be used, as in this example.
; Read the FITS file
data = mrdfits('ifu_file.fit',0,header)
In both examples the image data is read into an IDL array called DATA, while the FITS header information is read into another array, of TYPE STRING, called HEADER.
In addition FITS files can be read into IDL using the CONVERT package's on-the-fly file conversion ability and the READ_NDF IDL function.
The IFU Data-Product Cookbook