next up previous contents FITSIO Home
Next: Creating a new FITS Up: Programming Guidelines Previous: Programming Guidelines

Reading an existing FITS file

The following sequence of subroutine calls illustrate a simple example of reading an existing FITS file. Refer to the FITSIO Cookbook for more detailed examples of the correct FITSIO usage.

 1. Open the file with FTOPEN.
 2. Read any desired header keywords with FTGHPR or FTGKYx.
 3. Read the primary data, if any, with FTGPVx or FTGPFx.
 4. Repeat steps 2 and 3 until all the desired information has been read.
 5. Move to another extension with FTMAHD or FTMRHD.
 6. Read any extension header keywords (e.g. with FTGHTB, FTGHBN or FTGKYx)
 7. Read any columns of data from the extension (e.g. with FTGCVx or FTGCFx)
 8. Repeat steps 6 and 7 until all the information has been read.
 9. Repeat steps 5 through 8 for any other extensions.
10. Close the file with FTCLOS.