CCfits: Reading Header information from a HDU

CCfits 2.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

Reading Header information from a HDU

This function demonstrates selecting one HDU from the file, reading the header information and printing out the keys that have been read and the descriptions of the columns.

The readData flag is by default false (see below for the alternative case), which means that the data in the column is not read.

    int readHeader()
    {

        const string SPECTRUM("SPECTRUM");

        // read a particular HDU within the file. This call reads just the header
        // information from SPECTRUM

        std::auto_ptr<FITS> pInfile(new FITS("file1.pha",Read,SPECTRUM));

        // define a reference for clarity. (std::auto_ptr<T>::get returns a pointer

        ExtHDU& table = pInfile->extension(SPECTRUM);

        // read all the keywords, excluding those associated with columns.

        table.readAllKeys();

        // print the result.

        std::cout << table << std::endl;

        return 0;
     }