Previous: Reading an existing FITS file
Up: Usage Guidelines and Suggestions
Next: Advanced Usage
Previous Page: Reading an existing FITS file
Next Page: Advanced Usage
The following sequence of subroutine calls illustrate a simple example of writing a new FITS file:
1. Create the new file with FTINIT. 2. Write the required primary array keywords with FTPHPR. 3. Write any additional keywords with FTPKYx. 4. Define the structure of the primary array with FTPDEF. 5. Write the primary array data, if any, with FTPPRx. 6. Create another extension, if desired, with FTCRHD. 7. Write required header keywords for the extension with FTPHTB or FTPHBN. 8. Write any additional keywords with FTPKYx 9. Define the extension data structure with FTADEF or FTBDEF. 10. Write data to the extension, one column at a time with FTPCLx 11. Repeat steps 6 - 10 for any more extensions. 12. Close the FITS file with FTCLOSNote that the application program must NOT explicitly write the required 'END' keyword at the end of each header; the FITSIO interface will automatically append the END record whenever the header is closed As a standard practice, users should always read back any FITS files that they have created to ensure that the header values and data structure are correct and self-consistent.