27.01.2015 Views

CCfits - HEASARC - NASA

CCfits - HEASARC - NASA

CCfits - HEASARC - NASA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10 Selecting Table Data 24<br />

const string inFileName("atestfil.fit");<br />

const string outFileName("btestfil.fit");<br />

int status(0);<br />

status = 0;<br />

remove(outFileName.c_str());<br />

// Delete old file if it already exists<br />

// open the existing FITS file<br />

FITS inFile(inFileName);<br />

// custom constructor FITS::FITS(const string&, const FITS&) for<br />

// this particular task.<br />

FITS outFile(outFileName,inFile);<br />

// copy extension by number...<br />

outFile.copy(inFile.extension(2));<br />

// copy extension by name...<br />

outFile.copy(inFile.extension("TABLE_BINARY"));<br />

return 0;<br />

}<br />

10 Selecting Table Data<br />

This function demonstrates the operation of filtering a table by selecting rows that<br />

satisfy a condition and writing them to a new file, or overwriting a table with the filtered<br />

data. A third mode, where a filtered dataset is appended to the file containing the source<br />

data, will be available shortly, but is currently not supported by cfitsio.<br />

The expression syntax for the conditions that may be applied to table data are described<br />

in the cfitsio manual. In the example below, we illustrate filtering with<br />

a boolean expression involving one of the columns.<br />

The two flags at the end of the call to FITS::filter are an ‘overwrite’ flag - which only<br />

has meaning if the inFile and outFile are the same, and a ’read’ flag. overwrite defaults<br />

to true. The second flag is a ’read’ flag which defaults to false. When set true the user<br />

has immediate access to the filtered data.<br />

(Also see the section "Reading with Extended File Name Syntax")<br />

int selectRows()<br />

{<br />

const string inFile("atestfil.fit");<br />

const string outFile("btestfil.fit");<br />

const string newFile("ctestfil.fit");<br />

remove(newFile.c_str());<br />

Generated on Tue Dec 6 2011 16:12:51 for <strong>CCfits</strong> by Doxygen

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!