CCfits - HEASARC - NASA
CCfits - HEASARC - NASA
CCfits - HEASARC - NASA
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
7 Creating and Writing to an Ascii Table Extension 16<br />
{<br />
// Create an ASCII Table extension containing 3 columns and 6 rows *<br />
//******************************************************************<br />
// declare auto-pointer to FITS at function scope. Ensures no resources<br />
// leaked if something fails in dynamic allocation.<br />
std::auto_ptr pFits(0);<br />
try<br />
{<br />
const std::string fileName("atestfil.fit");<br />
// append the new extension to file created in previous function call.<br />
// <strong>CCfits</strong> writing constructor.<br />
// if this had been a new file, then the following code would create<br />
// a dummy primary array with BITPIX=8 and NAXIS=0.<br />
pFits.reset( new FITS(fileName,Write) );<br />
}<br />
catch (<strong>CCfits</strong>::FITS::CantOpen)<br />
{<br />
// ... or not, as the case may be.<br />
return -1;<br />
}<br />
unsigned long rows(6);<br />
string hduName("PLANETS_ASCII");<br />
std::vector colName(3,"");<br />
std::vector colForm(3,"");<br />
std::vector colUnit(3,"");<br />
/* define the name, datatype, and physical units for the 3 columns */<br />
colName[0] = "Planet";<br />
colName[1] = "Diameter";<br />
colName[2] = "Density";<br />
colForm[0] = "a8";<br />
colForm[1] = "i6";<br />
colForm[2] = "f4.2";<br />
colUnit[0] = "";<br />
colUnit[1] = "km";<br />
colUnit[2] = "g/cm^-3";<br />
std::vector planets(rows);<br />
const char *planet[] = {"Mercury", "Venus", "Earth",<br />
"Mars","Jupiter","Saturn"};<br />
const char *mnemoy[] = {"Many", "Volcanoes", "Erupt",<br />
"Mulberry","Jam","Sandwiches","Under",<br />
"Normal","Pressure"};<br />
long diameter[] = { 4880, 12112, 12742, 6800, 143000,<br />
Generated on Tue Dec 6 2011 16:12:51 for <strong>CCfits</strong> by Doxygen