CCfits - HEASARC - NASA

CCfits - HEASARC - NASA CCfits - HEASARC - NASA

heasarc.gsfc.nasa.gov
from heasarc.gsfc.nasa.gov More from this publisher
27.01.2015 Views

8 Creating and Writing to a Binary Table Extension 19 The interface supports writing to vector tables the following data structures: C-arrays (- T∗), std::vector objects, std::valarray objects, and std::vector. The last of these is the internal representation of the data. The function below exercises the following functionality: • Create a BinTable extension • Write vector rows to the table • Insert table rows • Write complex data to both scalar and vector columns. • Insert Table columns • Delete Table rows • Write HISTORY and COMMENT cards to the Table int writeBinary () { //********************************************************************* // Create a BINARY table extension and write and manipulate vector rows //********************************************************************* std::auto_ptr pFits(0); try { const std::string fileName("atestfil.fit"); pFits.reset( new FITS(fileName,Write) ); } catch (CCfits::FITS::CantOpen) { return -1; } unsigned long rows(3); string hduName("TABLE_BINARY"); std::vector colName(7,""); std::vector colForm(7,""); std::vector colUnit(7,""); colName[0] = "numbers"; colName[1] = "sequences"; colName[2] = "powers"; colName[3] = "big-integers"; colName[4] = "dcomplex-roots"; colName[5] = "fcomplex-roots"; colName[6] = "scalar-complex"; Generated on Tue Dec 6 2011 16:12:51 for CCfits by Doxygen

8 Creating and Writing to a Binary Table Extension 20 colForm[0] = "8A"; colForm[1] = "20J"; colForm[2] = "20D"; colForm[3] = "20V"; colForm[4] = "20M"; colForm[5] = "20C"; colForm[6] = "1M"; colUnit[0] = "magnets"; colUnit[1] = "bulbs"; colUnit[2] = "batteries"; colUnit[3] = "mulberries"; colUnit[4] = ""; colUnit[5] = ""; colUnit[6] = "pico boo"; std::vector numbers(rows); const string num("NUMBER-"); for (size_t j = 0; j < rows; ++j) { #ifdef HAVE_STRSTREAM std::ostrstream pStr; #else std::ostringstream pStr; #endif pStr

8 Creating and Writing to a Binary Table Extension 20<br />

colForm[0] = "8A";<br />

colForm[1] = "20J";<br />

colForm[2] = "20D";<br />

colForm[3] = "20V";<br />

colForm[4] = "20M";<br />

colForm[5] = "20C";<br />

colForm[6] = "1M";<br />

colUnit[0] = "magnets";<br />

colUnit[1] = "bulbs";<br />

colUnit[2] = "batteries";<br />

colUnit[3] = "mulberries";<br />

colUnit[4] = "";<br />

colUnit[5] = "";<br />

colUnit[6] = "pico boo";<br />

std::vector numbers(rows);<br />

const string num("NUMBER-");<br />

for (size_t j = 0; j < rows; ++j)<br />

{<br />

#ifdef HAVE_STRSTREAM<br />

std::ostrstream pStr;<br />

#else<br />

std::ostringstream pStr;<br />

#endif<br />

pStr

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

Saved successfully!

Ooh no, something went wrong!