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

5.1 Driver Program 11 int main(); int writeImage(); int writeAscii(); int writeBinary(); int copyHDU(); int selectRows(); int readHeader(); int readImage(); int readTable(); int readExtendedSyntax(); int main() { FITS::setVerboseMode(true); try { if (!writeImage()) std::cerr

6 Writing Primary Images and Image Extensions 12 nearly all functions return a non-zero status code on error, and have a final argument status of type int): if ( [cfitsio call](args,...,&status)) throw FitsError(status); FitsError, derived from FitsException, uses a cfitsio library call to convert the status code to a string message. The few exceptions that are not derived from FitsException indicate fatal conditions implying bugs in the library. These print a message suggesting the user contact HEA- SARC to report the problem. Note also the lack of statements for closing files in any of the following routines, The destructor (dtor) for the FITS object does this when it falls out of scope. A call FITS::destroy() throw() is provided for closing files explicitly; destroy() is also responsible for cleaning up the FITS object and deallocating its resources. When the data are being read instead of written, the user is expected to copy the data into other program variables [rather than use references to the data contained in the FITS object]. The routines in this program test the following functionality: writeImage() Writing Primary Images and Image Extensions writeAscii() Creating and Writing to an Ascii Table Extension writeBinary() Creating and Writing to a Binary Table Extension copyHDU() Copying an Extension between Files selectRows() Selecting Table Data readHeader() Reading Header information from a HDU readImage() Reading an Image readTable() Reading a Table Extension readExtendedSyntax() Reading with Extended File Name Syntax 6 Writing Primary Images and Image Extensions This section of the code demonstrates creation of images. Because every fits file must have a PHDU element, all the FITS constructors (ctors) instantiate a PHDU object. In the case of a new file, the default is to establish an empty HDU with BITPIX = 8 (BYTE_IMG). A current limitation of the code is that the data type of the PHDU cannot be replaced after the FITS file is created. Arguments to the FITS ctors allow the specification of the data type and the number of axes and their lengths. An image Generated on Tue Dec 6 2011 16:12:51 for CCfits by Doxygen

6 Writing Primary Images and Image Extensions 12<br />

nearly all functions return a non-zero status code on error, and have a final argument<br />

status of type int):<br />

if ( [cfitsio call](args,...,&status)) throw FitsError(status);<br />

FitsError, derived from FitsException, uses a cfitsio library call to convert the status<br />

code to a string message.<br />

The few exceptions that are not derived from FitsException indicate fatal conditions<br />

implying bugs in the library. These print a message suggesting the user contact HEA-<br />

SARC to report the problem.<br />

Note also the lack of statements for closing files in any of the following routines, The<br />

destructor (dtor) for the FITS object does this when it falls out of scope. A call<br />

FITS::destroy() throw()<br />

is provided for closing files explicitly; destroy() is also responsible for cleaning up the<br />

FITS object and deallocating its resources.<br />

When the data are being read instead of written, the user is expected to copy the data<br />

into other program variables [rather than use references to the data contained in the<br />

FITS object].<br />

The routines in this program test the following functionality:<br />

writeImage() Writing Primary Images and Image Extensions<br />

writeAscii() Creating and Writing to an Ascii Table Extension<br />

writeBinary() Creating and Writing to a Binary Table Extension<br />

copyHDU() Copying an Extension between Files<br />

selectRows() Selecting Table Data<br />

readHeader() Reading Header information from a HDU<br />

readImage() Reading an Image<br />

readTable() Reading a Table Extension<br />

readExtendedSyntax() Reading with Extended File Name Syntax<br />

6 Writing Primary Images and Image Extensions<br />

This section of the code demonstrates creation of images. Because every fits file must<br />

have a PHDU element, all the FITS constructors (ctors) instantiate a PHDU object.<br />

In the case of a new file, the default is to establish an empty HDU with BITPIX = 8<br />

(BYTE_IMG). A current limitation of the code is that the data type of the PHDU<br />

cannot be replaced after the FITS file is created. Arguments to the FITS ctors allow<br />

the specification of the data type and the number of axes and their lengths. An image<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!