GammaLib  2.0.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFits Class Reference

FITS file class. More...

#include <GFits.hpp>

Inheritance diagram for GFits:
GContainer GBase

Classes

struct  cdouble
 
struct  cfloat
 

Public Member Functions

 GFits (void)
 Void constructor. More...
 
 GFits (const GFilename &filename, const bool &create=false)
 FITS file constructor. More...
 
 GFits (const GFits &fits)
 Copy constructor. More...
 
virtual ~GFits (void)
 Destructor. More...
 
GFitsoperator= (const GFits &fits)
 Assignment operator. More...
 
GFitsHDUoperator[] (const int &extno)
 Get pointer to HDU. More...
 
const GFitsHDUoperator[] (const int &extno) const
 Get pointer to HDU (const version) More...
 
GFitsHDUoperator[] (const std::string &extname)
 Get pointer to HDU. More...
 
const GFitsHDUoperator[] (const std::string &extname) const
 Get pointer to HDU (const version) More...
 
void clear (void)
 Clear FITS file. More...
 
GFitsclone (void) const
 Clone FITS file. More...
 
std::string classname (void) const
 Return class name. More...
 
GFitsHDUat (const int &extno)
 Get pointer to HDU. More...
 
const GFitsHDUat (const int &extno) const
 Get pointer to HDU (const version) More...
 
GFitsHDUat (const std::string &extname)
 Get pointer to HDU. More...
 
const GFitsHDUat (const std::string &extname) const
 Get pointer to HDU (const version) More...
 
GFitsImageimage (const int &extno)
 Get pointer to image HDU. More...
 
const GFitsImageimage (const int &extno) const
 Get pointer to image HDU (const version) More...
 
GFitsImageimage (const std::string &extname)
 Get pointer to image HDU. More...
 
const GFitsImageimage (const std::string &extname) const
 Get pointer to image HDU (const version) More...
 
GFitsTabletable (const int &extno)
 Get pointer to table HDU. More...
 
const GFitsTabletable (const int &extno) const
 Get pointer to table HDU (const version) More...
 
GFitsTabletable (const std::string &extname)
 Get pointer to table HDU. More...
 
const GFitsTabletable (const std::string &extname) const
 Get pointer to table HDU. More...
 
int size (void) const
 Return number of HDUs in FITS file. More...
 
bool is_empty (void) const
 Signals if there are no HDUs in FITS file. More...
 
GFitsHDUset (const int &extno, const GFitsHDU &hdu)
 Set HDU for the specified extension number. More...
 
GFitsHDUset (const std::string &extname, const GFitsHDU &hdu)
 Set HDU for the specified extension name. More...
 
GFitsHDUappend (const GFitsHDU &hdu)
 Append HDU to FITS file. More...
 
GFitsHDUinsert (const int &extno, const GFitsHDU &hdu)
 Set HDU for the specified extension number. More...
 
GFitsHDUinsert (const std::string &extname, const GFitsHDU &hdu)
 Insert HDU into FITS file. More...
 
void remove (const int &extno)
 Remove HDU from FITS file. More...
 
void remove (const std::string &extname)
 Remove HDU from FITS file. More...
 
void reserve (const int &num)
 Reserves space for HDUs in FITS file. More...
 
void extend (const GFits &fits)
 Append FITS file. More...
 
bool contains (const int &extno) const
 Check if HDU exists in FITS file. More...
 
bool contains (const std::string &extname) const
 Check if HDU exists in FITS file. More...
 
const GFilenamefilename (void) const
 Return FITS filename. More...
 
int extno (const std::string &extname) const
 Return extension number for specified extension name. More...
 
void open (const GFilename &filename, const bool &create=false)
 Open or (optionally) create FITS file. More...
 
void save (const bool &clobber=false)
 Saves FITS file. More...
 
void saveto (const GFilename &filename, const bool &clobber=false)
 Saves to specified FITS file. More...
 
void close (void)
 Close FITS file. More...
 
void publish (const int &extno, const std::string &name="") const
 Publish FITS HDU on VO Hub. More...
 
void publish (const std::string &extname, const std::string &name="") const
 Publish FITS HDU on VO Hub. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print FITS information. More...
 
- Public Member Functions inherited from GContainer
virtual ~GContainer (void)
 Destructor. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Private Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GFits &fits)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
GFitsImagenew_image (void)
 Allocate new FITS image and return memory pointer. More...
 
GFitsImagenew_primary (void)
 Return minimal primary HDU. More...
 

Private Attributes

std::vector< GFitsHDU * > m_hdu
 Pointers to HDUs. More...
 
GFilename m_filename
 FITS file name. More...
 
void * m_fitsfile
 FITS file pointer. More...
 
bool m_readwrite
 FITS file is readwrite (true/false) More...
 
bool m_created
 FITS file has been created (true/false) More...
 

Detailed Description

FITS file class.

This class provides a physical representation of a FITS file in memory. It handles creation, manipulation, writing and reading of FITS files. As a FITS file is a collection of Header Data Units (HDUs), also known as FITS file extensions, the class is designed as a container class of HDUs.

HDUs are represented by the abstract GFitsHDU base class. A HDU may be either an image, represented by the abstract GFitsImage base class, or a table, represented by the abstract GFitsTable class. The image() and table() method allow accessing the HDUs. HDUs may be accessed by index (also called extension number) or by extension name.

Definition at line 63 of file GFits.hpp.

Constructor & Destructor Documentation

GFits::GFits ( void  )

Void constructor.

Constructs empty FITS file.

Definition at line 90 of file GFits.cpp.

References init_members().

Referenced by clone().

GFits::GFits ( const GFilename filename,
const bool &  create = false 
)

FITS file constructor.

Parameters
[in]filenameFITS file name.
[in]createCreate file if it does not exist? (default: false)

Construct an object by opening a FITS file. If the file does not exist it will be created if create is set to true.

Definition at line 109 of file GFits.cpp.

References init_members(), and open().

GFits::GFits ( const GFits fits)

Copy constructor.

Parameters
[in]fitsFITS file.

Definition at line 127 of file GFits.cpp.

References copy_members(), and init_members().

GFits::~GFits ( void  )
virtual

Destructor.

Definition at line 143 of file GFits.cpp.

References free_members().

Member Function Documentation

GFitsHDU * GFits::append ( const GFitsHDU hdu)

Append HDU to FITS file.

Parameters
[in]hduHDU.
Returns
Pointer to appended HDU.

Append HDU to the next free position in a FITS file. In case that no HDU exists so far in the FITS file and if the HDU to append is NOT an image, an empty primary image will be inserted as first HDU in the FITS file. This guarantees the compatibility with the FITS standard.

Definition at line 665 of file GFits.cpp.

References GFitsHDU::clone(), GFitsHDU::connect(), GFitsHDU::extno(), GFitsHDU::exttype(), FPTR, __fitsfile::HDUposition, GFitsHDU::HT_ASCII_TABLE, GFitsHDU::HT_BIN_TABLE, GFitsHDU::HT_IMAGE, m_fitsfile, m_hdu, new_primary(), and size().

Referenced by GVOClient::publish(), GCOMIaq::save(), GCOMTim::save(), GModelSpectralTable::save(), GSkyMap::save(), GObservations::likelihood::save_fits(), saveto(), GLATPsfV1::write(), GLATPsfV3::write(), GCTAEventList::write(), GGti::write(), GRmf::write(), GEnergies::write(), GNodeArray::write(), GArf::write(), GEbounds::write(), GPha::write(), GSkyMap::write(), GLATAeff::write_aeff(), GSPIResponse::write_detids(), GLATEdisp::write_edisp(), GLATAeff::write_efficiency(), GSPIResponse::write_energies(), and GLATPsfBase::write_scale().

GFitsHDU * GFits::at ( const int &  extno)

Get pointer to HDU.

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to HDU.
Exceptions
GException::out_of_rangeExtension number is out of range.
GException::fits_hdu_not_foundNo HDU found for specified extension number.

Returns a pointer to the HDU with the specified extension number extno. An exception is thrown if the HDU is not valid (i.e. NULL).

Definition at line 233 of file GFits.cpp.

References extno(), G_AT1, m_hdu, size(), and gammalib::str().

Referenced by image(), GSkyMap::load(), operator[](), publish(), GLATEventCube::read(), GMWLSpectrum::read(), GCTAObservation::read(), GModelSpatialDiffuseCube::read(), table(), and GCTAObservation::write().

const GFitsHDU * GFits::at ( const int &  extno) const

Get pointer to HDU (const version)

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to HDU.
Exceptions
GException::out_of_rangeExtension number is out of range.
GException::fits_hdu_not_foundNo HDU found for specified extension number.

Returns a pointer to the HDU with the specified extension number extno. An exception is thrown if the HDU is not valid (i.e. NULL).

Definition at line 270 of file GFits.cpp.

References extno(), G_AT1, m_hdu, size(), and gammalib::str().

GFitsHDU * GFits::at ( const std::string &  extname)

Get pointer to HDU.

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to HDU.
Exceptions
GException::fits_hdu_not_foundNo HDU with specified name has been found.

Returns a pointer to the HDU with the specified extname. An exception is thrown if the HDU is not valid (i.e. NULL).

Definition at line 305 of file GFits.cpp.

References extno(), G_AT2, and m_hdu.

const GFitsHDU * GFits::at ( const std::string &  extname) const

Get pointer to HDU (const version)

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to HDU.
Exceptions
GException::fits_hdu_not_foundNo HDU with specified name has been found.

Returns a pointer to the HDU with the specified extname. An exception is thrown if the HDU is not valid (i.e. NULL).

Definition at line 333 of file GFits.cpp.

References extno(), G_AT2, and m_hdu.

std::string GFits::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GFits").

Implements GBase.

Definition at line 157 of file GFits.hpp.

void GFits::clear ( void  )
virtual

Clear FITS file.

Implements GBase.

Definition at line 195 of file GFits.cpp.

References free_members(), and init_members().

Referenced by GCaldb::init_members().

GFits * GFits::clone ( void  ) const
virtual

Clone FITS file.

Returns
Pointer to deep copy of FITS file.

Implements GBase.

Definition at line 213 of file GFits.cpp.

References GFits().

void GFits::close ( void  )

Close FITS file.

Closing detaches a FITS file from the GFits object and returns a clean empty object.

Definition at line 1314 of file GFits.cpp.

References free_members(), and init_members().

Referenced by GCaldb::close(), GCTAEventList::fetch(), GCTAEdisp2D::fetch(), GCOMInstChars::load(), GCOMD1Response::load(), GCOMD2Response::load(), GCOMEventList::load(), GMWLSpectrum::load(), GCTAAeffArf::load(), GCTAPsfVector::load(), GLATEventList::load(), GCOMTim::load(), GCTABackground3D::load(), GLATEventCube::load(), GCOMEventCube::load(), GCTAPsf2D::load(), GCTAPsfKing::load(), GCTAPsfTable::load(), GCTAAeff2D::load(), GSPIEventCube::load(), GCOMOads::load(), GCTAEventList::load(), GCTACubeBackground::load(), GSPIObservation::load(), GLATLtCube::load(), GCTAEventCube::load(), GGti::load(), GCTACubeExposure::load(), GCOMResponse::load(), GCTAModelSpatialLookup::load(), GEnergies::load(), GModelSpectralTable::load(), GNodeArray::load(), GEbounds::load(), GCTACubePsf::load(), GCTACubeEdisp::load(), GCOMObservation::load(), GSPIResponse::load(), GCOMDri::load(), GCTAObservation::load(), GSkyMap::load(), GCTAResponseIrf::load_aeff(), GCOMObservation::load_drb(), GCOMObservation::load_dre(), GCOMObservation::load_drg(), GCOMObservation::load_drx(), GCTAResponseIrf::load_edisp(), GSPIResponse::load_irf(), GSPIResponse::load_irfs(), GModelTemporalLightCurve::load_nodes(), GModelTemporalPhaseCurve::load_nodes(), GCTAResponseIrf::load_psf(), GCOMStatus::load_status(), GLATObservation::load_unbinned(), GCOMEventList::save(), GSPIEventCube::save(), GCTACubeBackground::save(), GCTACubeExposure::save(), GCTACubePsf::save(), GCTACubeEdisp::save(), GSPIResponse::save(), GCOMDri::save(), GObservations::likelihood::save_fits(), and saveto().

bool GFits::contains ( const int &  extno) const
inline

Check if HDU exists in FITS file.

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
True if HDU with specified extno exists, false otherwise.

Returns true if a HDU with the specified extension number is present, false otherwise.

Definition at line 282 of file GFits.hpp.

References size().

Referenced by GCTAResponseIrf::load_aeff(), GCTAResponseIrf::load_edisp(), GCTAResponseIrf::load_psf(), GLATEventList::read(), GLATPsf::read(), GLATEdisp::read(), GCTAEventList::read(), GLATAeff::read(), GCTAEventCube::read(), GCTAObservation::read(), GPha::read(), GSPIResponse::read_energies(), GLATLtCubeMap::write(), GCTAEventCube::write(), GGti::write(), GRmf::write(), GEnergies::write(), GCTACubeEdisp::write(), GNodeArray::write(), GArf::write(), GEbounds::write(), GCTAObservation::write(), and GPha::write().

bool GFits::contains ( const std::string &  extname) const
inline

Check if HDU exists in FITS file.

Parameters
[in]extnameName of HDU extension.
Returns
True if HDU with specified extname exists, false otherwise.

Returns true if a HDU with the specified extension name is present, false otherwise.

Definition at line 298 of file GFits.hpp.

References extno().

void GFits::copy_members ( const GFits fits)
private

Copy class members.

Parameters
fitsObject to be copied

The method does not copy the FITS file name and FITS file pointer. This prevents that several copies of the FITS file pointer exist in different instances of GFits, which would lead to confusion since one instance could close the file while for another it still would be opened. The rule ONE INSTANCE - ONE FILE applies.

Definition at line 1507 of file GFits.cpp.

References GFilename::clear(), m_created, m_filename, m_fitsfile, m_hdu, and m_readwrite.

Referenced by GFits(), and operator=().

void GFits::extend ( const GFits fits)

Append FITS file.

Parameters
[in]fitsFITS file.

Append all extension of fits file to FITS file.

Todo:
Handle HDU update in FITS file.

Definition at line 919 of file GFits.cpp.

References GFitsHDU::connect(), GFitsHDU::extno(), extno(), FPTR, __fitsfile::HDUposition, is_empty(), m_fitsfile, m_hdu, reserve(), and size().

int GFits::extno ( const std::string &  extname) const

Return extension number for specified extension name.

Parameters
[in]extnameName of HDU extension.
Returns
Extension number (-1 of not found).

Returns the extension number for a specified extension name extname. If the extension name if "PRIMARY" an extension number of 0 is returned. If the extension is not found, -1 is returned.

Definition at line 973 of file GFits.cpp.

References m_hdu, size(), and gammalib::toupper().

Referenced by at(), contains(), extend(), insert(), publish(), remove(), and set().

const GFilename & GFits::filename ( void  ) const
inline

Return FITS filename.

Returns
FITS file name.

Returns the FITS file name. If the object is not yet associated to a file the file name will be empty.

Definition at line 313 of file GFits.hpp.

References m_filename.

Referenced by GCTAEventList::fetch(), open(), GSPIEventCube::read(), GMWLSpectrum::read(), GCTAEventList::read(), GCTAObservation::read(), GSPIEventCube::read_models(), gammalib::spi_hdu(), gammalib::spi_num_hdus(), and GCTAEventList::write().

void GFits::free_members ( void  )
private

Delete class members.

Closes the FITS file if it had been opened and deallocate all HDUs.

If the G_DELETE_EMPTY_FITS_FILES option is defined, files without HDUs or corrupted files will be deleted. This prevents leaving corrupted files on disk (yet, corrupted files may be generated by another application, thus this is not 100% safe; better make the code solid against reading corrupted FITS files).

Definition at line 1537 of file GFits.cpp.

References __ffclos, __ffdelt, FPTR, G_FREE_MEM, m_created, m_fitsfile, m_hdu, and size().

Referenced by clear(), close(), operator=(), and ~GFits().

GFitsImage * GFits::image ( const int &  extno)

Get pointer to image HDU.

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to FITS image.
Exceptions
GException::fits_hdu_not_imageRequested HDU is not an image.

Returns a pointer to the image HDU with extension number extno.

Definition at line 360 of file GFits.cpp.

References at(), G_IMAGE1, and gammalib::str().

Referenced by GCOMResponse::load(), GCOMDri::load(), GCOMObservation::load_drb(), GCOMObservation::load_drg(), GCOMObservation::load_drx(), GSPIResponse::load_irf(), new_image(), new_primary(), publish(), GLATEventCube::read(), GCOMEventCube::read(), GCTACubeBackground::read(), GCTAEventCube::read(), GCTACubeExposure::read(), GCTACubePsf::read(), GCTACubeEdisp::read(), and GSPIResponse::read().

const GFitsImage * GFits::image ( const int &  extno) const

Get pointer to image HDU (const version)

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to FITS image.
Exceptions
GException::fits_hdu_not_imageRequested HDU is not an image.

Returns a pointer to the image HDU with extension number extno.

Definition at line 388 of file GFits.cpp.

References at(), G_IMAGE1, and gammalib::str().

GFitsImage * GFits::image ( const std::string &  extname)

Get pointer to image HDU.

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to FITS image.
Exceptions
GException::fits_hdu_not_imageRequested HDU is not an image.

Returns a pointer to the image HDU with extension name extname.

Definition at line 416 of file GFits.cpp.

References at(), and G_IMAGE2.

const GFitsImage * GFits::image ( const std::string &  extname) const

Get pointer to image HDU (const version)

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to FITS image.
Exceptions
GException::fits_hdu_not_imageRequested HDU is not an image.

Returns a pointer to the image HDU with extension name extname.

Definition at line 444 of file GFits.cpp.

References at(), and G_IMAGE2.

void GFits::init_members ( void  )
private

Initialise class members.

Definition at line 1482 of file GFits.cpp.

References GFilename::clear(), m_created, m_filename, m_fitsfile, m_hdu, and m_readwrite.

Referenced by clear(), close(), GFits(), and operator=().

GFitsHDU * GFits::insert ( const int &  extno,
const GFitsHDU hdu 
)

Set HDU for the specified extension number.

Parameters
[in]extnoExtension number [0,...,size()-1].
[in]hduHDU.
Returns
Pointer to cloned HDU.
Exceptions
GException::out_of_rangeExtension number out of range.
GException::invalid_argumentAttempt to insert non-image HDU in first slot.

Definition at line 765 of file GFits.cpp.

References GFitsHDU::clone(), GFitsHDU::connect(), GFitsHDU::extno(), extno(), GFitsHDU::exttype(), FPTR, G_INSERT1, __fitsfile::HDUposition, GFitsHDU::HT_IMAGE, m_fitsfile, m_hdu, and size().

Referenced by insert().

GFitsHDU * GFits::insert ( const std::string &  extname,
const GFitsHDU hdu 
)

Insert HDU into FITS file.

Parameters
[in]extnameExtension name.
[in]hduExtension.
Returns
Pointer to deep copy of extension hdu.
Exceptions
GException::invalid_argumentExtension name not found.

Inserts an extension hdu into the FITS file before the extension with the specified extname.

Definition at line 823 of file GFits.cpp.

References extno(), G_INSERT2, and insert().

bool GFits::is_empty ( void  ) const
inlinevirtual

Signals if there are no HDUs in FITS file.

Returns
True if FITS file is empty, false otherwise.

Signals if the FITS file does not contain any HDUs.

Implements GContainer.

Definition at line 251 of file GFits.hpp.

References m_hdu.

Referenced by extend().

GFitsImage * GFits::new_image ( void  )
private

Allocate new FITS image and return memory pointer.

Depending on the number of bits per pixel, a FITS image is allocated and the pointer is returned. The following FITS image classes are handled: GFitsImageByte (bitpix=8) GFitsImageShort (bitpix=16) GFitsImageLong (bitpix=32) GFitsImageLongLong (bitpix=64) GFitsImageFloat (bitpix=-32) GFitsImageDouble (bitpix=-64) The information about the number of bits per pixels is extracted from the actual HDU.

Todo:
Additional code is needed to detect unsigned integer images. This code may be insprired by the code used for table columns as the unsigned information is stored in the BZERO keyword.

Definition at line 1615 of file GFits.cpp.

References __ffgiet, __ffgky, __TLONGLONG, FPTR, G_NEW_IMAGE, image(), and m_fitsfile.

Referenced by open().

GFitsImage * GFits::new_primary ( void  )
private

Return minimal primary HDU.

Creates a primary HDU in memory and open it using the GFitsHDU::open() method.

Definition at line 1695 of file GFits.cpp.

References __ffclos, __ffcrim, __ffdelt, __ffinit, FPTR, image(), GFitsHDU::m_fitsfile, and GFitsHDU::open().

Referenced by append().

void GFits::open ( const GFilename filename,
const bool &  create = false 
)

Open or (optionally) create FITS file.

Parameters
[in]filenameName of FITS file to be opened.
[in]createCreate FITS file if it does not exist (default: false)
Exceptions
GException::invalid_argumentClass instance contains already an opened FITS file. Close file before opening a new one using GFits::close().
GException::fits_open_errorUnable to open the specified file.
GException::fits_hdu_not_foundRequested HDU not found.
GException::fits_errorUnable to determine number of HDUs in the FITS file.

This method opens all HDUs that are found in the specified FITS file. If the file does not exist, and if create=true, a new FITS file is created. For each HDU, a GFitsHDU object is associated to the GFits object. The HDUs can then be accessed using the hdu(const std::string&) or hdu(int extno) method. Any environment variable present in the filename will be expanded.

Definition at line 1023 of file GFits.cpp.

References __ffinit, __ffopen, __ffthdu, FHANDLE, filename(), gammalib::fits_move_to_hdu(), FPTR, G_OPEN, GFitsHDU::HT_ASCII_TABLE, GFitsHDU::HT_BIN_TABLE, GFitsHDU::HT_IMAGE, m_created, m_filename, m_fitsfile, m_hdu, m_readwrite, new_image(), GFitsHDU::open(), GFilename::remove(), gammalib::str(), and GFilename::url().

Referenced by GFits(), and GCaldb::open().

GFits & GFits::operator= ( const GFits fits)

Assignment operator.

Parameters
[in]fitsFITS file.
Returns
FITS file.

Definition at line 165 of file GFits.cpp.

References copy_members(), free_members(), and init_members().

GFitsHDU * GFits::operator[] ( const int &  extno)
inline

Get pointer to HDU.

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to HDU.

Returns a pointer to the HDU with the specified extension number extno. No range checking is performed. If the HDU is not valid, NULL is returned.

Definition at line 173 of file GFits.hpp.

References m_hdu.

const GFitsHDU * GFits::operator[] ( const int &  extno) const
inline

Get pointer to HDU (const version)

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to HDU.

Returns a pointer to the HDU with the specified extension number extno. No range checking is performed. If the HDU is not valid, NULL is returned.

Definition at line 189 of file GFits.hpp.

References m_hdu.

GFitsHDU * GFits::operator[] ( const std::string &  extname)
inline

Get pointer to HDU.

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to HDU.

Returns a pointer to the HDU with the specified extname. No checking for the existence of extname is performed. If the HDU is not valid, NULL is returned.

Definition at line 206 of file GFits.hpp.

References at().

const GFitsHDU * GFits::operator[] ( const std::string &  extname) const
inline

Get pointer to HDU (const version)

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to HDU.

Returns a pointer to the HDU with the specified extname. No checking for the existence of extname is performed. If the HDU is not valid, NULL is returned.

Definition at line 223 of file GFits.hpp.

References at().

std::string GFits::print ( const GChatter chatter = NORMAL) const
virtual

Print FITS information.

Parameters
[in]chatterChattiness.
Returns
String containing FITS information.

Implements GBase.

Definition at line 1427 of file GFits.cpp.

References m_created, m_filename, m_hdu, m_readwrite, NORMAL, gammalib::parformat(), gammalib::reduce(), SILENT, size(), and gammalib::str().

void GFits::publish ( const int &  extno,
const std::string &  name = "" 
) const

Publish FITS HDU on VO Hub.

Parameters
[in]extnoExtension number.
[in]nameOptional name of published ressource.

Publishes FITS HDU with specified extno.

Definition at line 1335 of file GFits.cpp.

References at(), GFitsHDU::extname(), GFitsHDU::HT_IMAGE, image(), GVOClient::publish(), and table().

Referenced by publish().

void GFits::publish ( const std::string &  extname,
const std::string &  name = "" 
) const

Publish FITS HDU on VO Hub.

Parameters
[in]extnameExtension name.
[in]nameOptional name of published ressource.

Publishes FITS HDU with specified extname.

Definition at line 1403 of file GFits.cpp.

References extno(), G_PUBLISH, and publish().

void GFits::remove ( const int &  extno)
virtual
void GFits::remove ( const std::string &  extname)

Remove HDU from FITS file.

Parameters
[in]extnameName of HDU extension.
Exceptions
GException::invalid_argumentSpecified extname not found in FITS file.

Definition at line 892 of file GFits.cpp.

References extno(), and G_REMOVE2.

void GFits::reserve ( const int &  num)
inlinevirtual

Reserves space for HDUs in FITS file.

Parameters
[in]numNumber of HDUs

Reserves space for num HDUs in the FITS file.

Implements GContainer.

Definition at line 265 of file GFits.hpp.

References m_hdu.

Referenced by extend().

void GFits::save ( const bool &  clobber = false)

Saves FITS file.

Parameters
[in]clobberOverwrite existing FITS file? (default: false).
Exceptions
GException::fits_file_existAttemting to overwrite an existing file without having specified clobber=true.
GException::fits_file_not_openFITS file needs to be opened before saving.

Saves all HDUs of an open FITS file to disk. After saving, the FITS file remains open. Invoke the close() method if explicit closing is needed. Note that de-allocation of the GFits object also closes the FITS file.

In the special case that no first HDU exists an empty primary image is created.

Definition at line 1156 of file GFits.cpp.

References __ffcrim, __ffdhdu, __ffflus, __ffmahd, __ffthdu, FPTR, G_SAVE, m_created, m_filename, m_fitsfile, m_hdu, and size().

Referenced by saveto().

void GFits::saveto ( const GFilename filename,
const bool &  clobber = false 
)
GFitsHDU * GFits::set ( const int &  extno,
const GFitsHDU hdu 
)

Set HDU for the specified extension number.

Parameters
[in]extnoExtension number [0,...,size()-1].
[in]hduHDU.
Returns
Pointer to cloned HDU.
Exceptions
GException::out_of_rangeExtension number out of range.
GException::invalid_argumentAttempt to insert non-image HDU in first slot.

Definition at line 585 of file GFits.cpp.

References GFitsHDU::clone(), extno(), GFitsHDU::exttype(), FPTR, G_SET1, __fitsfile::HDUposition, GFitsHDU::HT_IMAGE, m_fitsfile, m_hdu, and size().

Referenced by set().

GFitsHDU * GFits::set ( const std::string &  extname,
const GFitsHDU hdu 
)

Set HDU for the specified extension name.

Parameters
[in]extnameName of HDU extension.
[in]hduHDU.
Returns
Pointer to cloned HDU.
Exceptions
GException::invalid_argumentExtension name not found.

Definition at line 639 of file GFits.cpp.

References extno(), G_SET2, and set().

int GFits::size ( void  ) const
inlinevirtual

Return number of HDUs in FITS file.

Returns
Number of HDUs in FITS file.

Returns the number of Header Data Units (HDUs) in the FITS file.

Implements GContainer.

Definition at line 237 of file GFits.hpp.

References m_hdu.

Referenced by append(), at(), contains(), extend(), extno(), free_members(), gammalib::gadf_hduclas4(), insert(), GSkyMap::load(), print(), GLATEventCube::read(), GMWLSpectrum::read(), GModelSpatialDiffuseCube::read(), remove(), save(), saveto(), set(), gammalib::spi_hdu(), gammalib::spi_num_hdus(), GCTACubeBackground::write(), GCTACubeExposure::write(), GCTACubePsf::write(), and GCTACubeEdisp::write().

GFitsTable * GFits::table ( const int &  extno)

Get pointer to table HDU.

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to FITS table.
Exceptions
GException::fits_hdu_not_tableRequested HDU is not a table.

Returns a pointer to the table HDU with extension number extno.

Definition at line 472 of file GFits.cpp.

References at(), G_TABLE1, and gammalib::str().

Referenced by GCaldb::copy_members(), GCTAEventList::fetch(), GCTAEdisp2D::fetch(), GCOMInstChars::load(), GCOMD1Response::load(), GCOMD2Response::load(), GCTAAeffArf::load(), GCTAPsfVector::load(), GCTABackground3D::load(), GCOMTim::load(), GCTAAeff2D::load(), GCTAPsf2D::load(), GCTAPsfKing::load(), GCTAPsfTable::load(), GCOMOads::load(), GGti::load(), GCTAModelSpatialLookup::load(), GEnergies::load(), GNodeArray::load(), GEbounds::load(), GCTAResponseIrf::load_aeff(), GCTAResponseIrf::load_edisp(), GModelSpectralTable::load_eng(), GModelTemporalLightCurve::load_nodes(), GModelTemporalPhaseCurve::load_nodes(), GModelSpectralTable::load_par(), GCTAResponseIrf::load_psf(), GModelSpectralTable::load_spec(), GCOMStatus::load_status(), GCaldb::open(), publish(), GCOMEventList::read(), GLATEventList::read(), GLATPsf::read(), GLATEventCube::read(), GLATEdisp::read(), GMWLSpectrum::read(), GCTACubeBackground::read(), GCTAEventList::read(), GLATAeff::read(), GLATLtCube::read(), GCTAEventCube::read(), GCTACubeExposure::read(), GRmf::read(), GCTACubePsf::read(), GCTACubeEdisp::read(), GArf::read(), GModelSpatialDiffuseCube::read(), GPha::read(), GSPIResponse::read_detids(), GSPIResponse::read_energies(), GCTACubePsf::write(), and GSPIResponse::write_energies().

const GFitsTable * GFits::table ( const int &  extno) const

Get pointer to table HDU (const version)

Parameters
[in]extnoExtension number [0,...,size()-1].
Returns
Pointer to FITS table.
Exceptions
GException::fits_hdu_not_tableRequested HDU is not a table.

Returns a pointer to the table HDU with extension number extno.

Definition at line 500 of file GFits.cpp.

References at(), G_TABLE1, and gammalib::str().

GFitsTable * GFits::table ( const std::string &  extname)

Get pointer to table HDU.

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to FITS table.
Exceptions
GException::fits_hdu_not_tableRequested HDU is not a table.

Returns a pointer to the table HDU with extension name extname.

Definition at line 528 of file GFits.cpp.

References at(), and G_TABLE2.

const GFitsTable * GFits::table ( const std::string &  extname) const

Get pointer to table HDU.

Parameters
[in]extnameName of HDU extension.
Returns
Pointer to FITS table.
Exceptions
GException::fits_hdu_not_tableRequested HDU is not a table.

Returns a pointer to the table HDU with extension name extname.

Definition at line 556 of file GFits.cpp.

References at(), and G_TABLE2.

Member Data Documentation

bool GFits::m_created
private

FITS file has been created (true/false)

Definition at line 147 of file GFits.hpp.

Referenced by copy_members(), free_members(), init_members(), open(), print(), and save().

GFilename GFits::m_filename
private

FITS file name.

Definition at line 144 of file GFits.hpp.

Referenced by copy_members(), filename(), init_members(), open(), print(), and save().

void* GFits::m_fitsfile
private

FITS file pointer.

Definition at line 145 of file GFits.hpp.

Referenced by append(), copy_members(), extend(), free_members(), init_members(), insert(), new_image(), open(), save(), and set().

std::vector<GFitsHDU*> GFits::m_hdu
private
bool GFits::m_readwrite
private

FITS file is readwrite (true/false)

Definition at line 146 of file GFits.hpp.

Referenced by copy_members(), init_members(), open(), and print().


The documentation for this class was generated from the following files: