CCfits  2.4
Reading a Table Extension

Reading table data is similarly straightforward (unsurprisingly, because this application is exactly what CCfits was designed to do easily in the first place).

The two extensions are read on construction, including all the column data [readDataFlag == true] and then printed.

Note that if the data are read as part of the construction, then CCfits uses the row-optimization techniques describe in chapter 13 of the cfitsio manual; a chunk of data equal to the size of the available buffer space is read from contiguous disk blocks and transferred to memory storage, as opposed to each column being read in turn. Thus the most efficient way of reading files is to acquire the data on construction.

 int readTable()
 {
        // read a table and explicitly read selected columns. To read instead all the
        // data on construction, set the last argument of the FITS constructor
        // call to 'true'. This functionality was tested in the last release.
        std::vector<string> hdus(2);
        hdus[0] = "PLANETS_ASCII";
        hdus[1] = "TABLE_BINARY";
        
        
        std::auto_ptr<FITS> pInfile(new FITS("atestfil.fit",Read,hdus,false));
        
        ExtHDU& table = pInfile->extension(hdus[1]);
        
        
        
        std::vector < valarray <int > > pp;
        table.column("powerSeq").readArrays( pp, 1,3 );
                        
        std::vector < valarray <std::complex<double> > > cc;
        table.column("dcomplex-roots").readArrays( cc, 1,3 );
        
        std::valarray < std::complex<float> > ff;
        table.column("fcomplex-roots").read( ff, 4 );
        
        std::cout << pInfile->extension(hdus[0]) << std::endl;
        
        std::cout << pInfile->extension(hdus[1]) << std::endl;
         
        return 0;       
 }