GammaLib
2.0.0
|
Interface for FITS header class. More...
#include <GFitsHeader.hpp>
Public Member Functions | |
GFitsHeader (void) | |
Constructor. More... | |
GFitsHeader (const GFitsHeader &header) | |
Copy constructor. More... | |
virtual | ~GFitsHeader (void) |
Destructor. More... | |
GFitsHeader & | operator= (const GFitsHeader &header) |
Assignment operator. More... | |
GFitsHeaderCard & | operator[] (const int &cardno) |
Return header card. More... | |
const GFitsHeaderCard & | operator[] (const int &cardno) const |
Return pointer to model (const version) More... | |
GFitsHeaderCard & | operator[] (const std::string &keyname) |
Return header card. More... | |
const GFitsHeaderCard & | operator[] (const std::string &keyname) const |
Return header card (const version) More... | |
void | clear (void) |
Clear header. More... | |
GFitsHeader * | clone (void) const |
Clone header. More... | |
std::string | classname (void) const |
Return class name. More... | |
GFitsHeaderCard & | at (const int &cardno) |
Return header card. More... | |
const GFitsHeaderCard & | at (const int &cardno) const |
Return header card (const version) More... | |
GFitsHeaderCard & | at (const std::string &keyname) |
Return header card. More... | |
const GFitsHeaderCard & | at (const std::string &keyname) const |
Return header card (const version) More... | |
std::string | string (const int &cardno) const |
Return header card value as string value. More... | |
std::string | string (const std::string &keyname) const |
Return header card value as string value. More... | |
double | real (const int &cardno) const |
Return header card value as double precision value. More... | |
double | real (const std::string &keyname) const |
Return header card value as double precision value. More... | |
int | integer (const int &cardno) const |
Return header card value as integer value. More... | |
int | integer (const std::string &keyname) const |
Return header card value as integer value. More... | |
int | size (void) const |
Return number of cards in header. More... | |
bool | is_empty (void) const |
Signals if there are no cards in the FITS header. More... | |
GFitsHeaderCard & | append (const GFitsHeaderCard &card) |
Append or update header card. More... | |
GFitsHeaderCard & | insert (const int &cardno, const GFitsHeaderCard &card) |
Insert card into header. More... | |
GFitsHeaderCard & | insert (const std::string &keyname, const GFitsHeaderCard &card) |
Insert card into header. More... | |
void | remove (const int &cardno) |
Remove card from header. More... | |
void | remove (const std::string &keyname) |
Remove card from header. More... | |
void | reserve (const int &num) |
Reserves space for cards in FITS header. More... | |
void | extend (const GFitsHeader &header) |
Append header. More... | |
bool | contains (const int &cardno) const |
Check if card is present in header. More... | |
bool | contains (const std::string &keyname) const |
Check if card is present in header. More... | |
void | load (void *vptr) |
Load header from FITS file. More... | |
void | save (void *vptr) const |
Save header to FITS file. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print FITS header 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 GFitsHeader &header) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
int | get_index (const std::string &keyname) const |
Get index of header card. More... | |
void | update_keyname_map (void) |
Update the header card pointers. More... | |
Private Attributes | |
std::vector< GFitsHeaderCard > | m_cards |
Header cards. More... | |
std::map< std::string, GFitsHeaderCard * > | m_keyname_map |
Header pointers. More... | |
Interface for FITS header class.
The FITS header class is a container class for header cards.
All cards of a FITS file extension will be held in memory, so no link to a FITS file is required. Cards are read from a file using the load() method, and cards are saved into a file using the save() method.
Definition at line 49 of file GFitsHeader.hpp.
GFitsHeader::GFitsHeader | ( | void | ) |
Constructor.
Definition at line 70 of file GFitsHeader.cpp.
References init_members().
Referenced by clone().
GFitsHeader::GFitsHeader | ( | const GFitsHeader & | header | ) |
Copy constructor.
header | FITS header. |
Definition at line 85 of file GFitsHeader.cpp.
References copy_members(), and init_members().
|
virtual |
GFitsHeaderCard & GFitsHeader::append | ( | const GFitsHeaderCard & | card | ) |
Append or update header card.
[in] | card | Header card. |
If the keyname of the header card
does not yet exist in the header (or if the keyname is COMMENT or HISTORY) then append the header card to the header. If the keyname exists already, the header card is updated.
Definition at line 427 of file GFitsHeader.cpp.
References get_index(), GFitsHeaderCard::keyname(), m_cards, m_keyname_map, size(), and update_keyname_map().
Referenced by GFitsHDU::card(), GFitsHDU::extname(), GFitsImage::init_image_header(), GFitsBinTable::init_table_header(), GFitsAsciiTable::init_table_header(), and GCTAOnOffObservation::set().
GFitsHeaderCard & GFitsHeader::at | ( | const int & | cardno | ) |
Return header card.
[in] | cardno | Number of card in header [0,...,size()-1] |
GException::out_of_range | Card number out of range. |
Definition at line 186 of file GFitsHeader.cpp.
References contains(), G_AT1, m_cards, and size().
Referenced by GFitsHDU::card(), GFitsHDU::integer(), operator[](), GFitsHDU::real(), and GFitsHDU::string().
const GFitsHeaderCard & GFitsHeader::at | ( | const int & | cardno | ) | const |
Return header card (const version)
[in] | cardno | Number of card in header [0,...,size()-1] |
GException::out_of_range | Card number out of range. |
Definition at line 209 of file GFitsHeader.cpp.
References contains(), G_AT1, m_cards, and size().
GFitsHeaderCard & GFitsHeader::at | ( | const std::string & | keyname | ) |
Return header card.
[in] | keyname | Name of header card |
GException::invalid_argument | Key name not found. |
Definition at line 232 of file GFitsHeader.cpp.
References G_AT2, get_index(), and m_cards.
const GFitsHeaderCard & GFitsHeader::at | ( | const std::string & | keyname | ) | const |
Return header card (const version)
[in] | keyname | Name of header card |
GException::invalid_argument | Key name not found. |
Definition at line 257 of file GFitsHeader.cpp.
References G_AT2, get_index(), and m_cards.
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 113 of file GFitsHeader.hpp.
|
virtual |
Clear header.
Implements GBase.
Definition at line 153 of file GFitsHeader.cpp.
References free_members(), and init_members().
Referenced by GRmf::init_members(), GArf::init_members(), and GPha::init_members().
|
virtual |
Clone header.
Implements GBase.
Definition at line 171 of file GFitsHeader.cpp.
References GFitsHeader().
|
inline |
Check if card is present in header.
[in] | cardno | Number of card in header. |
Signals whether a card with specified card number exists in header.
Definition at line 223 of file GFitsHeader.hpp.
References size().
Referenced by at(), GFitsHDU::has_card(), integer(), GFitsHDU::open(), real(), remove(), string(), and GFitsTable::update_header().
|
inline |
Check if card is present in header.
[in] | keyname | Name of header card. |
Signals whether a card with specified keyname
exists in header.
Definition at line 238 of file GFitsHeader.hpp.
References get_index().
|
private |
Copy class members.
[in] | header | FITS header. |
Definition at line 765 of file GFitsHeader.cpp.
References m_cards, and update_keyname_map().
Referenced by GFitsHeader(), and operator=().
void GFitsHeader::extend | ( | const GFitsHeader & | header | ) |
Append header.
[in] | header | FITS header. |
Append all cards from a FITS header to the actual header.
Definition at line 600 of file GFitsHeader.cpp.
References is_empty(), m_cards, reserve(), size(), and update_keyname_map().
|
private |
Delete class members.
Definition at line 781 of file GFitsHeader.cpp.
Referenced by clear(), operator=(), and ~GFitsHeader().
|
private |
Get index of header card.
[in] | keyname | Header card key name. |
keyname
is not found)Returns index of header card based on the keyname
. If no header card is found, -1 is returned.
Definition at line 797 of file GFitsHeader.cpp.
References m_cards, and m_keyname_map.
Referenced by append(), at(), contains(), insert(), integer(), real(), remove(), and string().
|
private |
Initialise class members.
Definition at line 749 of file GFitsHeader.cpp.
References m_cards, and m_keyname_map.
Referenced by clear(), GFitsHeader(), and operator=().
GFitsHeaderCard & GFitsHeader::insert | ( | const int & | cardno, |
const GFitsHeaderCard & | card | ||
) |
Insert card into header.
[in] | cardno | Header card number [0,...,size()-1]. |
[in] | card | Header card. |
GException::out_of_range | Card number out of range. |
Inserts a card
into the header before the card with the specified card number cardno
.
Definition at line 465 of file GFitsHeader.cpp.
References G_INSERT1, is_empty(), m_cards, size(), and update_keyname_map().
GFitsHeaderCard & GFitsHeader::insert | ( | const std::string & | keyname, |
const GFitsHeaderCard & | card | ||
) |
Insert card into header.
[in] | keyname | Header card key name. |
[in] | card | Header card. |
GException::invalid_argument | Key name not found. |
Inserts a card
into the header before the card with the specified keyname
.
Definition at line 508 of file GFitsHeader.cpp.
References G_INSERT2, get_index(), m_cards, and update_keyname_map().
int GFitsHeader::integer | ( | const int & | cardno | ) | const |
Return header card value as integer value.
[in] | cardno | Header card number [0,...,size()-1]. |
GException::out_of_range | Card number out of range. |
Definition at line 378 of file GFitsHeader.cpp.
References contains(), G_INTEGER1, m_cards, and size().
Referenced by integer().
int GFitsHeader::integer | ( | const std::string & | keyname | ) | const |
Return header card value as integer value.
[in] | keyname | Header card key name. |
GException::invalid_argument | Key name not found. |
Definition at line 401 of file GFitsHeader.cpp.
References G_INTEGER2, get_index(), integer(), and m_cards.
|
inlinevirtual |
Signals if there are no cards in the FITS header.
Signals if there are no cards in the FITS header.
Implements GContainer.
Definition at line 193 of file GFitsHeader.hpp.
References m_cards.
void GFitsHeader::load | ( | void * | vptr | ) |
Load header from FITS file.
[in] | vptr | FITS file void pointer. |
GException::fits_error | FITS error occured. |
Loads all header cards into memory. Any header cards that existed before will be dropped.
Definition at line 639 of file GFitsHeader.cpp.
References __ffghsp, gammalib::fits_move_to_hdu(), FPTR, G_OPEN, m_cards, GFitsHeaderCard::read(), reserve(), and update_keyname_map().
Referenced by GFitsHDU::open().
GFitsHeader & GFitsHeader::operator= | ( | const GFitsHeader & | header | ) |
Assignment operator.
header | FITS header. |
Definition at line 123 of file GFitsHeader.cpp.
References copy_members(), free_members(), and init_members().
|
inline |
Return header card.
[in] | cardno | Number of card in header [0,...,size()-1] |
Definition at line 126 of file GFitsHeader.hpp.
References m_cards.
|
inline |
Return pointer to model (const version)
[in] | cardno | Number of card in header [0,...,size()-1] |
Definition at line 139 of file GFitsHeader.hpp.
References m_cards.
|
inline |
Return header card.
[in] | keyname | Name of header card |
Definition at line 152 of file GFitsHeader.hpp.
References at().
|
inline |
Return header card (const version)
[in] | keyname | Name of header card |
Definition at line 165 of file GFitsHeader.hpp.
References at().
Print FITS header information.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 715 of file GFitsHeader.cpp.
References m_cards, NORMAL, SILENT, size(), and gammalib::str().
Referenced by GFitsTable::print(), and GFitsImage::print().
double GFitsHeader::real | ( | const int & | cardno | ) | const |
Return header card value as double precision value.
[in] | cardno | Header card number [0,...,size()-1]. |
GException::out_of_range | Card number out of range. |
Definition at line 330 of file GFitsHeader.cpp.
References contains(), G_REAL1, m_cards, and size().
Referenced by real().
double GFitsHeader::real | ( | const std::string & | keyname | ) | const |
Return header card value as double precision value.
[in] | keyname | Header card key name. |
GException::invalid_argument | Key name not found. |
Definition at line 353 of file GFitsHeader.cpp.
References G_REAL2, get_index(), m_cards, and real().
|
virtual |
Remove card from header.
[in] | cardno | Header card number [0,...,size()-1]. |
GException::out_of_range | Card number out of range. |
Remove header card of specified card number from container.
Implements GContainer.
Definition at line 541 of file GFitsHeader.cpp.
References contains(), G_REMOVE1, m_cards, size(), and update_keyname_map().
Referenced by GFitsTable::update_header().
void GFitsHeader::remove | ( | const std::string & | keyname | ) |
Remove card from header.
[in] | keyname | Header card key name. |
GException::invalid_argument | Key name not found. |
Remove card with specified keyname
from header.
Definition at line 571 of file GFitsHeader.cpp.
References G_REMOVE2, get_index(), m_cards, and update_keyname_map().
|
inlinevirtual |
Reserves space for cards in FITS header.
[in] | num | Number of cards |
Reserves space for num
cards in the FITS header.
Implements GContainer.
Definition at line 207 of file GFitsHeader.hpp.
References m_cards.
void GFitsHeader::save | ( | void * | vptr | ) | const |
Save header to FITS file.
[in] | vptr | FITS file void pointer. |
GException::fits_error | FITS error occured. |
Saves all header cards into HDU. This method does not write the following mandatory keywords to the HDU (those will be written by methods handling the data of the HDU): 'SIMPLE' 'BITPIX' 'NAXIS', 'NAXIS1', 'NAXIS2', etc. 'EXTEND' 'PCOUNT' 'GCOUNT'
Definition at line 689 of file GFitsHeader.cpp.
References FPTR, m_cards, and size().
Referenced by GFitsHDU::save().
|
inlinevirtual |
Return number of cards in header.
Returns the number of cards in the extension header.
Implements GContainer.
Definition at line 179 of file GFitsHeader.hpp.
References m_cards.
Referenced by append(), at(), GFitsHDU::cards(), contains(), extend(), insert(), integer(), print(), real(), remove(), save(), string(), GRmf::write(), GArf::write(), and GPha::write().
std::string GFitsHeader::string | ( | const int & | cardno | ) | const |
Return header card value as string value.
[in] | cardno | Header card number [0,...,size()-1]. |
GException::out_of_range | Card number out of range. |
Definition at line 282 of file GFitsHeader.cpp.
References contains(), G_STRING1, m_cards, and size().
Referenced by GFitsHDU::open().
std::string GFitsHeader::string | ( | const std::string & | keyname | ) | const |
Return header card value as string value.
[in] | keyname | Header card key name. |
GException::invalid_argument | Key name not found. |
Definition at line 305 of file GFitsHeader.cpp.
References G_STRING2, get_index(), and m_cards.
|
private |
Update the header card pointers.
Sets up a map between header card keywords and pointers to header cards. This enables fast access of header cards in a FITS header.
This method needs to be called whenever the list of header cards is modified.
Definition at line 828 of file GFitsHeader.cpp.
References m_cards, and m_keyname_map.
Referenced by append(), copy_members(), extend(), insert(), load(), and remove().
|
private |
Header cards.
Definition at line 102 of file GFitsHeader.hpp.
Referenced by append(), at(), copy_members(), extend(), get_index(), init_members(), insert(), integer(), is_empty(), load(), operator[](), print(), real(), remove(), reserve(), save(), size(), string(), and update_keyname_map().
|
private |
Header pointers.
Definition at line 103 of file GFitsHeader.hpp.
Referenced by append(), get_index(), init_members(), and update_keyname_map().