GammaLib
2.1.0.dev
|
Auxiliary Response File class. More...
#include <GArf.hpp>
Public Member Functions | |
GArf (void) | |
Void constructor. More... | |
GArf (const GFilename &filename) | |
File constructor. More... | |
GArf (const GEbounds &ebds) | |
Energy boundary constructor. More... | |
GArf (const GArf &arf) | |
Copy constructor. More... | |
virtual | ~GArf (void) |
Destructor. More... | |
GArf & | operator= (const GArf &arf) |
Assignment operator. More... | |
GArf & | operator+= (const GArf &arf) |
Add Auxiliary Response File. More... | |
GArf & | operator-= (const GArf &arf) |
Subtract Auxiliary Response File. More... | |
GArf & | operator*= (const double &scale) |
Scale Auxiliary Response File values. More... | |
GArf & | operator/= (const double &scale) |
Divide Auxiliary Response File values. More... | |
double & | operator[] (const int &index) |
Return content of spectral bin. More... | |
const double & | operator[] (const int &index) const |
Return content of spectral bin (const version) More... | |
double & | operator() (const int &index, const int &col) |
Return content of additional columns. More... | |
const double & | operator() (const int &index, const int &col) const |
Return content of additional columns (const version) More... | |
std::vector< double > & | operator[] (const std::string &colname) |
Return additional vector column. More... | |
const std::vector< double > & | operator[] (const std::string &colname) const |
Return additional vector column (const version) More... | |
double | operator() (const std::string &colname, const GEnergy &energy) const |
Return vector column content as function of energy. More... | |
void | clear (void) |
Clear object. More... | |
GArf * | clone (void) const |
Clone object. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Return number of spectral bins. More... | |
int | columns (void) const |
Return number of additional columns. More... | |
double & | at (const int &index) |
Return content of spectral bin. More... | |
const double & | at (const int &index) const |
Return content of spectral bin (const version) More... | |
double & | at (const int &index, const int &col) |
Return content of additional columns. More... | |
const double & | at (const int &index, const int &col) const |
Return content of additional columns (const version) More... | |
void | append (const std::string &name, const std::vector< double > &column) |
Append additional column to spectrum. More... | |
const GEbounds & | ebounds (void) const |
Return energy boundaries. More... | |
void | load (const GFilename &filename) |
Load Auxiliary Response File. More... | |
void | save (const GFilename &filename, const bool &clobber=false) const |
Save Auxiliary Response File. More... | |
void | read (const GFits &fits) |
Read Auxiliary Response File. More... | |
void | read (const GFitsTable &table) |
Read Auxiliary Response File. More... | |
void | write (GFits &fits) const |
Write Auxiliary Response File. More... | |
const GFilename & | filename (void) const |
Return file name. More... | |
const GFitsHeader & | header (void) const |
Return FITS header. More... | |
void | header (const GFitsHeader &header) |
Set FITS header. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print Auxiliary Response File. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GArf &pha) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | set_logetrue (void) |
Set true energy node array. More... | |
int | column_index (const std::string &colname) const |
Returns index of additional vector column. More... | |
Protected Attributes | |
GFilename | m_filename |
Filename of origin. More... | |
GEbounds | m_ebounds |
Energy boundaries. More... | |
GNodeArray | m_logetrue |
Log10 energies in TeV. More... | |
std::vector< double > | m_specresp |
Spectral response. More... | |
std::vector< std::string > | m_colnames |
Additional column names. More... | |
std::vector< std::vector < double > > | m_coldata |
Additional column data. More... | |
GFitsHeader | m_header |
FITS header cards. More... | |
Friends | |
GArf | operator+ (const GArf &a, const GArf &b) |
Auxiliary Response File addition operator friend. More... | |
GArf | operator- (const GArf &a, const GArf &b) |
Auxiliary Response File subtraction operator friend. More... | |
GArf | operator* (const GArf &arf, const double &scale) |
Auxiliary Response File scaling operator friend. More... | |
GArf | operator* (const double &scale, const GArf &arf) |
Auxiliary Response File scaling operator friend. More... | |
GArf | operator/ (const GArf &arf, const double &scale) |
Auxiliary Response File vision operator friend. More... | |
GArf::GArf | ( | void | ) |
Void constructor.
Definition at line 66 of file GArf.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | File name. |
Definition at line 81 of file GArf.cpp.
References init_members(), and load().
|
explicit |
Energy boundary constructor.
[in] | ebds | Energy boundaries. |
Definition at line 99 of file GArf.cpp.
References init_members(), m_ebounds, m_specresp, set_logetrue(), and GEbounds::size().
GArf::GArf | ( | const GArf & | arf | ) |
Copy constructor.
[in] | arf | Auxiliary Response File. |
Definition at line 123 of file GArf.cpp.
References copy_members(), and init_members().
|
virtual |
void GArf::append | ( | const std::string & | name, |
const std::vector< double > & | column | ||
) |
Append additional column to spectrum.
[in] | name | Additional column name. |
[in] | column | Additional column data. |
Definition at line 522 of file GArf.cpp.
References G_APPEND, m_coldata, m_colnames, size(), and gammalib::str().
Referenced by read().
double & GArf::at | ( | const int & | index | ) |
Return content of spectral bin.
[in] | index | Spectral bin index [0,...,size()[. |
GException::out_of_range | Spectral bin index is out of range. |
Returns reference to content of spectral bin with specified index
.
Definition at line 428 of file GArf.cpp.
References G_AT1, m_specresp, and size().
const double & GArf::at | ( | const int & | index | ) | const |
Return content of spectral bin (const version)
[in] | index | Spectral bin index [0,...,size()[. |
GException::out_of_range | Spectral bin index is out of range.
|
Definition at line 451 of file GArf.cpp.
References G_AT1, m_specresp, and size().
double & GArf::at | ( | const int & | index, |
const int & | col | ||
) |
Return content of additional columns.
GException::out_of_range | Spectral bin or column index is out of range. |
Returns reference to content of additional columns.
const double & GArf::at | ( | const int & | index, |
const int & | col | ||
) | const |
Return content of additional columns (const version)
GException::out_of_range | Spectral bin or column index is out of range. |
Returns reference to content of additional columns.
|
inlinevirtual |
|
virtual |
Clear object.
Reset object to a clean initial state.
Implements GBase.
Definition at line 395 of file GArf.cpp.
References free_members(), and init_members().
Referenced by GCTAOnOffObservation::init_members(), load(), and read().
|
virtual |
|
protected |
Returns index of additional vector column.
[in] | colname | Vector column name. |
Returns index of additional vector column. Returns -1 if the vector column has not found.
Definition at line 958 of file GArf.cpp.
References columns(), and m_colnames.
Referenced by operator()(), and operator[]().
|
inline |
Return number of additional columns.
Returns the number of additional columns.
Definition at line 223 of file GArf.hpp.
References m_colnames.
Referenced by at(), column_index(), and write().
|
protected |
Copy class members.
[in] | arf | Auxiliary Response File. |
Definition at line 890 of file GArf.cpp.
References m_coldata, m_colnames, m_ebounds, m_filename, m_header, m_logetrue, and m_specresp.
Referenced by GArf(), and operator=().
|
inline |
Return energy boundaries.
Returns the energy boundaries for all spectral bins.
Definition at line 237 of file GArf.hpp.
References m_ebounds.
Referenced by GCTAOnOffObservation::arf_stacked(), GCTAOnOffObservation::check_consistency(), GCTAOnOffObservation::compute_arf(), GCTAOnOffObservation::compute_arf_cut(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::N_gamma(), operator+=(), and operator-=().
|
inline |
Return file name.
Returns the file name from which the ARF information has been read or into which ARF information has been saved. The returned string will be empty if no load() or save() method has been called before.
Definition at line 254 of file GArf.hpp.
References m_filename.
Referenced by GCTAOnOffObservation::write().
|
protected |
Delete class members.
Definition at line 909 of file GArf.cpp.
Referenced by clear(), operator=(), and ~GArf().
|
inline |
Return FITS header.
Definition at line 266 of file GArf.hpp.
References m_header.
Referenced by header(), and GCTAOnOffObservation::set().
|
inline |
|
protected |
Initialise class members.
Definition at line 869 of file GArf.cpp.
References GFitsHeader::clear(), GNodeArray::clear(), GEbounds::clear(), GFilename::clear(), m_coldata, m_colnames, m_ebounds, m_filename, m_header, m_logetrue, and m_specresp.
Referenced by clear(), GArf(), and operator=().
void GArf::load | ( | const GFilename & | filename | ) |
Load Auxiliary Response File.
[in] | filename | File name. |
Loads the Auxiliary Response File from the SPECRESP
extension of the FITS file.
Definition at line 552 of file GArf.cpp.
References clear(), m_filename, read(), and GFilename::url().
Referenced by GArf(), and GCTAOnOffObservation::read().
|
inline |
|
inline |
double GArf::operator() | ( | const std::string & | colname, |
const GEnergy & | energy | ||
) | const |
Return vector column content as function of energy.
[in] | colname | Vector column name. |
[in] | energy | Energy. |
Returns content of additional vector column as function of energy
.
Definition at line 348 of file GArf.cpp.
References column_index(), exp(), G_OPERATOR2, GNodeArray::inx_left(), GNodeArray::inx_right(), log(), GEnergy::log10TeV(), m_coldata, m_logetrue, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().
GArf & GArf::operator*= | ( | const double & | scale | ) |
Scale Auxiliary Response File values.
[in] | scale | Scale factor. |
Multiplies the values of the Auxiliary Response File with a scale factor.
Definition at line 257 of file GArf.cpp.
References m_specresp, and size().
Add Auxiliary Response File.
[in] | arf | Auxiliary Response File. |
GException::invalid_value | Incompatible Auxiliary Response Files. |
Adds the ARF values of an Auxiliary Response File to the current values.
The operator only works if the provide Auxiliary Response File has the same energy binning than the current Auxiliary Response File.
Definition at line 196 of file GArf.cpp.
References ebounds(), G_OPERATOR_PLUS, m_specresp, and size().
Subtract Auxiliary Response File.
[in] | arf | Auxiliary Response File. |
GException::invalid_value | Incompatible Auxiliary Response Files. |
Subtracts the ARF values of an Auxiliary Response File from the current values.
The operator only works if the provide Auxiliary Response File has the same energy binning than the current Auxiliary Response File.
Definition at line 230 of file GArf.cpp.
References ebounds(), G_OPERATOR_MINUS, m_specresp, and size().
GArf & GArf::operator/= | ( | const double & | scale | ) |
Divide Auxiliary Response File values.
[in] | scale | Division factor. |
Divides the values of the Auxiliary Response File by a division factor.
Definition at line 277 of file GArf.cpp.
References m_specresp, and size().
Assignment operator.
[in] | arf | Auxiliary Response File. |
Definition at line 161 of file GArf.cpp.
References copy_members(), free_members(), and init_members().
|
inline |
Return content of spectral bin.
[in] | index | Bin index [0,...,size()-1]. |
Returns reference to content of spectral bin with specified index
.
Definition at line 151 of file GArf.hpp.
References m_specresp.
|
inline |
Return content of spectral bin (const version)
[in] | index | Bin index [0,...,size()-1]. |
Returns reference to content of spectral bin with specified index
.
Definition at line 165 of file GArf.hpp.
References m_specresp.
std::vector< double > & GArf::operator[] | ( | const std::string & | colname | ) |
Return additional vector column.
[in] | colname | Vector column name. |
Returns reference to additional vector column.
Definition at line 297 of file GArf.cpp.
References column_index(), G_OPERATOR, and m_coldata.
const std::vector< double > & GArf::operator[] | ( | const std::string & | colname | ) | const |
Return additional vector column (const version)
[in] | colname | Vector column name. |
Returns reference to additional vector column.
Definition at line 322 of file GArf.cpp.
References column_index(), G_OPERATOR, and m_coldata.
Print Auxiliary Response File.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 834 of file GArf.cpp.
References GEbounds::emax(), GEbounds::emin(), m_ebounds, gammalib::parformat(), GEnergy::print(), SILENT, GEbounds::size(), and gammalib::str().
Referenced by GCTAOnOffObservation::print().
void GArf::read | ( | const GFits & | fits | ) |
Read Auxiliary Response File.
[in] | fits | FITS file. |
Loads the Auxiliary Response File from the SPECRESP
extension of the FITS file.
Definition at line 617 of file GArf.cpp.
References clear(), gammalib::extname_arf, and GFits::table().
Referenced by load().
void GArf::read | ( | const GFitsTable & | table | ) |
Read Auxiliary Response File.
[in] | table | ARF FITS table. |
Reads the Auxiliary Response File from a FITS table. The true energy boundaries are expected in the ENERG_LO
and ENERG_HI
columns, the response information is expected in the SPECRESP
column.
The method will analyze the unit of the SPECRESP
column, and if either m**2
, m^2
or m2
are encountered, multiply the values of the column by \(10^4\) to convert the response into units of \(cm^2\). Units of the ENERG_LO
and ENERG_HI
columns are also interpreted for conversion.
See http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc4 for details about the Auxiliary Response File format.
Definition at line 651 of file GArf.cpp.
References GEbounds::append(), append(), clear(), GFitsHDU::header(), m_ebounds, m_header, m_specresp, GFitsTable::ncols(), GFitsTableCol::nrows(), GFitsTableCol::real(), set_logetrue(), gammalib::strip_whitespace(), gammalib::tolower(), and GFitsTableCol::unit().
void GArf::save | ( | const GFilename & | filename, |
const bool & | clobber = false |
||
) | const |
Save Auxiliary Response File.
[in] | filename | File name. |
[in] | clobber | Overwrite existing file? |
Saves the Auxiliary Response File into a FITS file. If a file with the given filename
does not yet exist it will be created. If the file exists it can be overwritten if the clobber
flag is set to true
. Otherwise an exception is thrown.
The method will save the SPECRESP
binary FITS table into the FITS file that contains the values of the Auxiliary Response File.
Definition at line 589 of file GArf.cpp.
References m_filename, GFits::saveto(), GFilename::url(), and write().
|
protected |
Set true energy node array.
Definition at line 919 of file GArf.cpp.
References GNodeArray::append(), GNodeArray::clear(), GEbounds::elogmean(), GEnergy::log10TeV(), m_ebounds, m_logetrue, GNodeArray::reserve(), and GEbounds::size().
|
inline |
Return number of spectral bins.
Returns the number of spectral bins.
Definition at line 209 of file GArf.hpp.
References m_specresp.
Referenced by append(), at(), GCTAOnOffObservation::N_gamma(), operator*=(), operator+=(), operator-=(), operator/=(), and write().
void GArf::write | ( | GFits & | fits | ) | const |
Write Auxiliary Response File.
[in] | fits | FITS file. |
Writes the Auxiliary Response File into the SPECRESP
extension of the FITS file. An existing extension with the same name will be removed from the FITS file before writing.
The method writes the boundaries of the true energy bins into the ENERG_LO
and ENERG_HI
columns, response information will be written into the SPECRESP
column.
See http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc4 for details about the Auxiliary Response File format.
Definition at line 740 of file GArf.cpp.
References GFitsTable::append(), GFits::append(), GFitsHDU::card(), columns(), GFitsTable::contains(), GFits::contains(), GEbounds::emax(), GEbounds::emin(), GFitsHDU::extname(), gammalib::extname_arf, GEnergy::keV(), m_coldata, m_colnames, m_ebounds, m_header, m_specresp, GFits::remove(), GFitsHeader::size(), size(), and GFitsTableCol::unit().
Referenced by save().
|
protected |
Additional column data.
Definition at line 126 of file GArf.hpp.
Referenced by append(), at(), copy_members(), init_members(), operator()(), operator[](), and write().
|
protected |
Additional column names.
Definition at line 125 of file GArf.hpp.
Referenced by append(), column_index(), columns(), copy_members(), init_members(), and write().
|
protected |
Energy boundaries.
Definition at line 122 of file GArf.hpp.
Referenced by copy_members(), ebounds(), GArf(), init_members(), print(), read(), set_logetrue(), and write().
|
mutableprotected |
Filename of origin.
Definition at line 121 of file GArf.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and save().
|
protected |
FITS header cards.
Definition at line 127 of file GArf.hpp.
Referenced by copy_members(), header(), init_members(), read(), and write().
|
protected |
Log10 energies in TeV.
Definition at line 123 of file GArf.hpp.
Referenced by copy_members(), init_members(), operator()(), and set_logetrue().
|
protected |
Spectral response.
Definition at line 124 of file GArf.hpp.
Referenced by at(), copy_members(), GArf(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), operator[](), read(), size(), and write().