GammaLib
2.1.0.dev
|
Energy boundaries container class. More...
#include <GEbounds.hpp>
Public Member Functions | |
GEbounds (void) | |
Constructor. More... | |
GEbounds (const GFilename &filename) | |
FITS file constructor. More... | |
GEbounds (const GXmlElement &xml) | |
XML element constructor. More... | |
GEbounds (const GEnergies &energies) | |
Energy container constructor. More... | |
GEbounds (const GEbounds &ebds) | |
Copy constructor. More... | |
GEbounds (const GEnergy &emin, const GEnergy &emax) | |
Single energy band constructor. More... | |
GEbounds (const int &num, const GEnergy &emin, const GEnergy &emax, const std::string &method="LOG", const double &gamma=1.0) | |
Interval constructor. More... | |
virtual | ~GEbounds (void) |
Destructor. More... | |
GEbounds & | operator= (const GEbounds &ebds) |
Assignment operator. More... | |
void | clear (void) |
Clear energy boundaries. More... | |
GEbounds * | clone (void) const |
Clone energy boundaries. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Return number of energy boundaries. More... | |
bool | is_empty (void) const |
Signal if there are no energy boundaries. More... | |
void | append (const GEnergy &emin, const GEnergy &emax) |
Append energy interval. More... | |
void | insert (const GEnergy &emin, const GEnergy &emax) |
Insert energy interval. More... | |
void | merge (void) |
Merge all overlapping or connecting successive energy intervals. More... | |
void | merge (const GEnergy &emin, const GEnergy &emax) |
Merge energy interval into energy boundaries. More... | |
void | remove (const int &index) |
Remove energy interval. More... | |
void | remove (const GEnergy &emin, const GEnergy &emax) |
Remove energy interval from energy boundaries. More... | |
void | reserve (const int &num) |
Reserve space for energy intervals. More... | |
void | extend (const GEbounds &ebds) |
Append energy boundaries. More... | |
void | set (const GEnergies &energies) |
Set energy boundaries from energy container. More... | |
void | set (const int &num, const GEnergy &emin, const GEnergy &emax, const std::string &method="LOG", const double &gamma=1.0) |
Set energy intervals. More... | |
void | load (const GFilename &filename) |
Load energy boundaries from FITS file. More... | |
void | save (const GFilename &filename, const bool &clobber=false, const std::string &unit="keV") const |
Save energy boundaries into FITS file. More... | |
void | read (const GFitsTable &table) |
Read energy boundaries from FITS table. More... | |
void | write (GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const |
Write energy boundaries into FITS object. More... | |
void | read (const GXmlElement &xml) |
Read energy boundaries from XML element. More... | |
void | write (GXmlElement &xml) const |
Write energy boundaries into XML element. More... | |
int | index (const GEnergy &eng) const |
Returns energy bin index for a given energy. More... | |
const GEnergy & | emin (void) const |
Return minimum energy of all intervals. More... | |
const GEnergy & | emax (void) const |
Return maximum energy of all intervals. More... | |
void | emin (const int &index, const GEnergy &energy) |
Set minimum energy for a given energy interval. More... | |
void | emax (const int &index, const GEnergy &energy) |
Set maximum energy for a given energy interval. More... | |
GEnergy | emin (const int &index) const |
Returns minimum energy for a given energy interval. More... | |
GEnergy | emax (const int &index) const |
Returns maximum energy for a given energy interval. More... | |
GEnergy | emean (const int &index) const |
Returns mean energy for a given energy interval. More... | |
GEnergy | elogmean (const int &index) const |
Returns logarithmic mean energy for a given energy interval. More... | |
GEnergy | ewidth (const int &index) const |
Returns energy interval width. More... | |
bool | contains (const GEnergy &eng) const |
Checks whether energy boundaries contain energy. More... | |
bool | contains (const GEnergy &emin, const GEnergy &emax) const |
Checks whether energy boundaries contain and energy bin. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print energy boundaries. More... | |
Public Member Functions inherited from GContainer | |
virtual | ~GContainer (void) |
Destructor. 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 GEbounds &ebds) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | set_attributes (void) |
Set class attributes. More... | |
void | insert_eng (const int &index, const GEnergy &emin, const GEnergy &emax) |
Insert energy interval. More... | |
Protected Attributes | |
int | m_num |
Number of energy boundaries. More... | |
GEnergy | m_emin |
Minimum energy of all intervals. More... | |
GEnergy | m_emax |
Maximum energy of all intervals. More... | |
GEnergy * | m_min |
Array of interval minimum energies. More... | |
GEnergy * | m_max |
Array of interval maximum energies. More... | |
Friends | |
bool | operator== (const GEbounds &a, const GEbounds &b) |
Energy boundaries equality operator friend. More... | |
bool | operator!= (const GEbounds &a, const GEbounds &b) |
Energy boundaries inequality operator friend. More... | |
Energy boundaries container class.
This class holds a list of energy intervals that are defined by a minimum and maximum energy. Energies are implement using the GEnergy class which holds unit independent energy information.
The class has no method for sorting of the energy boundaries; it is expected that the energy boundaries are correctly set by the client.
Definition at line 60 of file GEbounds.hpp.
GEbounds::GEbounds | ( | void | ) |
Constructor.
Definition at line 73 of file GEbounds.cpp.
References init_members().
Referenced by clone().
|
explicit |
FITS file constructor.
[in] | filename | FITS file name. |
Constructs energy boundaries from a FITS file.
Definition at line 90 of file GEbounds.cpp.
References init_members(), and load().
|
explicit |
XML element constructor.
[in] | xml | XML element. |
Constructs energy boundaries from an XML element.
Definition at line 110 of file GEbounds.cpp.
References init_members(), and read().
|
explicit |
Energy container constructor.
[in] | energies | Energy container. |
Constructs energy boundaries from an energy container.
Definition at line 130 of file GEbounds.cpp.
References init_members(), and set().
GEbounds::GEbounds | ( | const GEbounds & | ebds | ) |
Copy constructor.
[in] | ebds | Energy boundaries. |
Definition at line 148 of file GEbounds.cpp.
References copy_members(), and init_members().
Single energy band constructor.
[in] | emin | Minimum energy of the interval. |
[in] | emax | Maximum energy of the interval. |
Constructs energy boundaries for one (emin, emax) energy band.
Definition at line 169 of file GEbounds.cpp.
References append(), and init_members().
GEbounds::GEbounds | ( | const int & | num, |
const GEnergy & | emin, | ||
const GEnergy & | emax, | ||
const std::string & | method = "LOG" , |
||
const double & | gamma = 1.0 |
||
) |
Interval constructor.
[in] | num | Number of energy intervals. |
[in] | emin | Minimum energy of first interval. |
[in] | emax | Maximum energy of last interval. |
[in] | method | Energy spacing method (one of "LIN", "LOG" or "POW"). |
[in] | gamma | Power law index for POW method. |
Constructs energy boundaries by defining num
successive energy intervals between emin
and emax
. The method
parameter controls the energy spacing of the energy boundaries. See the set() method for more information.
Definition at line 196 of file GEbounds.cpp.
References init_members(), and set().
|
virtual |
Append energy interval.
[in] | emin | Minimum energy of interval. |
[in] | emax | Maximum energy of interval. |
Appends an energy interval to the end of the energy boundaries container.
Definition at line 301 of file GEbounds.cpp.
References insert_eng(), and m_num.
Referenced by GResponse::ebounds_model(), GEbounds(), GModelSpectralTable::load_eng(), GCTAAeffArf::read(), GRmf::read(), GArf::read(), read(), gammalib::read_ds_ebounds(), GSPIResponse::set(), set(), GCTAAeffPerfTable::set_boundaries(), GCTAAeff2D::set_boundaries(), GMWLSpectrum::set_ebounds(), and GModelSpatialDiffuseCube::set_energy_boundaries().
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 151 of file GEbounds.hpp.
|
virtual |
Clear energy boundaries.
Implements GBase.
Definition at line 268 of file GEbounds.cpp.
References free_members(), and init_members().
Referenced by GCOMDri::compute_drg(), GCOMDri::compute_drx(), GCOMIaq::init_members(), GCTAAeffPerfTable::init_members(), GCTACubeBackground::init_members(), GCTAAeffArf::init_members(), GCTAAeff2D::init_members(), GCTAModelSkyCube::init_members(), GEvents::init_members(), GModelSpectralTable::init_members(), GRmf::init_members(), GSPIResponse::init_members(), GArf::init_members(), GModelSpatialDiffuseCube::init_members(), GCOMDri::init_members(), GPha::init_members(), GCTAAeffArf::read(), GRmf::read(), read(), GCOMDri::read_attributes(), GSPIResponse::read_energies(), GSPIResponse::set(), set(), GCTAAeffPerfTable::set_boundaries(), GCTAAeff2D::set_boundaries(), GMWLSpectrum::set_ebounds(), and GModelSpatialDiffuseCube::set_energy_boundaries().
|
virtual |
Clone energy boundaries.
Implements GBase.
Definition at line 286 of file GEbounds.cpp.
References GEbounds().
bool GEbounds::contains | ( | const GEnergy & | eng | ) | const |
Checks whether energy boundaries contain energy.
[in] | eng | Energy to be checked. |
Checks if the energy eng
falls in at least one of the energy intervals. The method exits when the first matching interval has been found.
Definition at line 1180 of file GEbounds.cpp.
References m_max, m_min, and m_num.
Referenced by GCTAOnOffObservation::apply_ebounds(), and GCTACubeBackground::fill().
Checks whether energy boundaries contain and energy bin.
[in] | emin | Minimum energy of bin to be checked. |
[in] | emax | Maximum energy of bin to be checked. |
Checks if the energy interval [emin
, emax
] falls is fully contained by energy boundaries
Definition at line 1211 of file GEbounds.cpp.
|
protected |
Copy class members.
[in] | ebds | Energy boundaries. |
Definition at line 1300 of file GEbounds.cpp.
References m_emax, m_emin, m_max, m_min, and m_num.
Referenced by GEbounds(), and operator=().
GEnergy GEbounds::elogmean | ( | const int & | index | ) | const |
Returns logarithmic mean energy for a given energy interval.
[in] | index | Energy interval index [0,...,size()[. |
GException::out_of_range | Specified index is out of range. |
Computes the logarithmic mean energy \(10^{0.5 * (\log E_{\rm min} + \log E_{\rm max})}\) for the energy interval index
.
Definition at line 1126 of file GEbounds.cpp.
References G_ELOGMEAN, m_max, m_min, m_num, GEnergy::MeV(), and sqrt().
Referenced by GCTAOnOffObservation::compute_alpha(), GCTAOnOffObservation::compute_arf(), GCTAOnOffObservation::compute_arf_cut(), GCTAOnOffObservation::compute_bgd(), GCTAEdispRmf::compute_ereco_bounds(), GCTAEdispRmf::compute_etrue_bounds(), GCTAOnOffObservation::compute_rmf(), GCTACubeBackground::fill(), GModelSpectralBins::GModelSpectralBins(), GCTAModelSkyCube::load(), GCTAOnOffObservation::N_bgd(), GCTAOnOffObservation::N_gamma(), GCOMIaq::set(), GCTAEdispRmf::set_cache(), GCOMEventCube::set_energies(), GModelSpectralTable::set_energy_nodes(), GCTACubeBackground::set_eng_axis(), GArf::set_logetrue(), and GCTAEdispRmf::set_matrix().
|
inline |
Return maximum energy of all intervals.
Definition at line 199 of file GEbounds.hpp.
References m_emax.
Referenced by GCTAOnOffObservation::apply_ebounds(), GCTAOnOffObservation::arf_stacked(), GCOMDri::compute_dre(), GCOMIaq::compute_iaq_bin(), GCTAOnOffObservation::compute_rmf(), GCOMDri::compute_tof_correction(), GResponse::convolve(), GModelSpectralTable::create_eng_table(), GEvents::emax(), GRmf::emeasured(), GRmf::etrue(), GCTACubeBackground::fill(), GPha::fill(), GCTAModelSpatialLookup::GCTAModelSpatialLookup(), GModelSpectralBins::GModelSpectralBins(), insert_eng(), GCTAModelIrfBackground::mc(), GCTAModelAeffBackground::mc(), GCTAModelBackground::mc(), GCTAEdispRmf::mc(), GCTAEdisp2D::mc(), GCTAOnOffObservation::N_gamma(), GCTAEdisp2D::normalize_table(), GObservation::npred_spec(), GCTAResponseIrf::nroi(), operator==(), GCOMIaq::print(), GCTAAeffPerfTable::print(), GCTAAeffArf::print(), GModelSpectralTable::print(), GModelSpatialDiffuseCube::print(), GCTAEdispRmf::print(), GRmf::print(), GArf::print(), print(), GPha::print(), read(), remove(), GCTAOnOffObservation::rmf_stacked(), GCOMIaq::save(), GLATMeanPsf::set(), GCOMIaq::set(), GEnergies::set(), GCTAOnOffObservation::set(), GCOMEventCube::set_energies(), GCTAEdispRmf::set_matrix(), GRmf::write(), GArf::write(), write(), and GCOMDri::write_attributes().
void GEbounds::emax | ( | const int & | index, |
const GEnergy & | energy | ||
) |
Set maximum energy for a given energy interval.
[in] | index | Energy interval index (0,...,size()-1). |
[in] | energy | Maximum energy of interval. |
GException::out_of_range | Specified index is out of range. |
Sets the maximum energy for the energy interval index
.
Definition at line 1010 of file GEbounds.cpp.
References G_EMAX_SET, index(), m_max, m_num, and set_attributes().
GEnergy GEbounds::emax | ( | const int & | index | ) | const |
Returns maximum energy for a given energy interval.
[in] | index | Energy interval index (0,...,size()-1). |
GException::out_of_range | Specified index is out of range. |
Definition at line 1066 of file GEbounds.cpp.
References G_EMAX_GET, m_max, and m_num.
GEnergy GEbounds::emean | ( | const int & | index | ) | const |
Returns mean energy for a given energy interval.
[in] | index | Energy interval index [0,...,size()[. |
GException::out_of_range | Specified index is out of range. |
Computes the mean energy \(0.5 * (E_{\rm min} + E_{\rm max})\) for the energy interval index
.
Definition at line 1095 of file GEbounds.cpp.
References G_EMEAN, index(), m_max, m_min, and m_num.
Referenced by GCTAOnOffObservation::model_background(), GCTAOnOffObservation::model_gamma(), and GSPIEventCube::read_ebds().
|
inline |
Return minimum energy of all intervals.
Definition at line 187 of file GEbounds.hpp.
References m_emin.
Referenced by GCTAOnOffObservation::apply_ebounds(), GCTAOnOffObservation::arf_stacked(), GCOMDri::compute_dre(), GCOMIaq::compute_iaq_bin(), GCTAOnOffObservation::compute_rmf(), GCOMDri::compute_tof_correction(), GResponse::convolve(), GModelSpectralTable::create_eng_table(), GRmf::emeasured(), GEvents::emin(), GCTAEdispRmf::ereco_bounds(), GRmf::etrue(), GCTAEdispRmf::etrue_bounds(), GCTACubeBackground::fill(), GPha::fill(), GCTAModelSpatialLookup::GCTAModelSpatialLookup(), GModelSpectralBins::GModelSpectralBins(), insert_eng(), GCTAModelIrfBackground::mc(), GCTAModelAeffBackground::mc(), GCTAModelBackground::mc(), GCTAEdispRmf::mc(), GCTAEdisp2D::mc(), GCTAOnOffObservation::N_gamma(), GCTAEdisp2D::normalize_table(), GObservation::npred_spec(), GCTAResponseIrf::nroi(), operator==(), GCOMIaq::print(), GCTAAeffPerfTable::print(), GCTAAeffArf::print(), GModelSpectralTable::print(), GModelSpatialDiffuseCube::print(), GCTAEdispRmf::print(), GRmf::print(), GArf::print(), print(), GPha::print(), read(), remove(), GCTAOnOffObservation::rmf_stacked(), GCOMIaq::save(), GLATMeanPsf::set(), GCOMIaq::set(), GEnergies::set(), GCTAOnOffObservation::set(), GCOMEventCube::set_energies(), GCTAEdispRmf::set_matrix(), GRmf::write(), GArf::write(), write(), and GCOMDri::write_attributes().
void GEbounds::emin | ( | const int & | index, |
const GEnergy & | energy | ||
) |
Set minimum energy for a given energy interval.
[in] | index | Energy interval index (0,...,size()-1). |
[in] | energy | Minimum energy of interval. |
GException::out_of_range | Specified index is out of range. |
Sets the minimum energy for the energy interval index
.
Definition at line 977 of file GEbounds.cpp.
References G_EMIN_SET, index(), m_min, m_num, and set_attributes().
GEnergy GEbounds::emin | ( | const int & | index | ) | const |
Returns minimum energy for a given energy interval.
[in] | index | Energy interval index (0,...,size()-1). |
GException::out_of_range | Specified index is out of range. |
Definition at line 1041 of file GEbounds.cpp.
References G_EMIN_GET, m_min, and m_num.
GEnergy GEbounds::ewidth | ( | const int & | index | ) | const |
Returns energy interval width.
[in] | index | Energy interval index [0,...,size()[. |
GException::out_of_range | Specified index is out of range. |
Definition at line 1154 of file GEbounds.cpp.
References G_EWIDTH, m_max, m_min, and m_num.
Referenced by GCTAOnOffObservation::N_bgd(), GCTAOnOffObservation::N_gamma(), and GSPIEventCube::read_ebds().
void GEbounds::extend | ( | const GEbounds & | ebds | ) |
Append energy boundaries.
[in] | ebds | Energy boundaries. |
Append energy boundaries to the container.
Definition at line 552 of file GEbounds.cpp.
References is_empty(), m_max, m_min, m_num, max(), min(), set_attributes(), and size().
|
protected |
Delete class members.
Definition at line 1325 of file GEbounds.cpp.
Referenced by clear(), operator=(), read(), and ~GEbounds().
int GEbounds::index | ( | const GEnergy & | eng | ) | const |
Returns energy bin index for a given energy.
[in] | eng | Energy. |
Returns the energy boundary bin index for a given energy. By convention, the limits for an energy bin are defined as
min <= energy < max
i.e. and energy equals to max falls above the largest energy.
If the energy falls outside all boundaries, -1 is returned.
Definition at line 948 of file GEbounds.cpp.
References m_max, m_min, and m_num.
Referenced by emax(), emean(), GRmf::emeasured(), emin(), GRmf::etrue(), GPha::fill(), and insert_eng().
|
protected |
Initialise class members.
Definition at line 1281 of file GEbounds.cpp.
References GEnergy::clear(), m_emax, m_emin, m_max, m_min, and m_num.
Referenced by clear(), GEbounds(), operator=(), and read().
Insert energy interval.
[in] | emin | Minimum energy of interval. |
[in] | emax | Maximum energy of interval. |
Inserts an energy interval into the energy boundaries after the first boundary that has a minimum energy smaller than emin
. The method implicitely assumes that the intervals are ordered by increasing minimum energy.
Definition at line 322 of file GEbounds.cpp.
References insert_eng(), m_min, and m_num.
Referenced by remove().
|
protected |
Insert energy interval.
[in] | index | Index after with interval is inserted. |
[in] | emin | Minimum energy of interval. |
[in] | emax | Maximum energy of interval. |
GException::invalid_argument | Minimum energy larger than maximum energy |
Inserts an energy interval after the specified index
in the energy boundaries. The method does not reorder the intervals by energy, instead the client needs to determine the approriate index
.
Invalid parameters do not produce any exception, but are handled transparently. If the interval is invalid (i.e. emin
> emax
) an exception is thrown. If the index
is out of the valid range, the index will be adjusted to either the first or the last element.
Definition at line 1389 of file GEbounds.cpp.
References emax(), emin(), G_INSERT_ENG, index(), m_max, m_min, m_num, max(), min(), NORMAL, GEnergy::print(), and set_attributes().
|
inlinevirtual |
Signal if there are no energy boundaries.
Implements GContainer.
Definition at line 175 of file GEbounds.hpp.
References m_num.
Referenced by extend(), GSPIResponse::is_precomputed(), write(), and GSPIResponse::write_energies().
void GEbounds::load | ( | const GFilename & | filename | ) |
Load energy boundaries from FITS file.
[in] | filename | FITS file name. |
Loads the energy boundaries from a FITS file.
If no extension name is provided, the energy boundaries are loaded from the EBOUNDS
extension.
Definition at line 689 of file GEbounds.cpp.
References GFits::close(), GFilename::extname(), gammalib::extname_ebounds, read(), and GFits::table().
Referenced by GEbounds().
void GEbounds::merge | ( | void | ) |
Merge all overlapping or connecting successive energy intervals.
Merges all overlapping or connecting successive energy intervals. The method implicitely assumes that the intervals are ordered by increasing minimum energy.
Note that the method does not actually reduce the memory size but just updates the information on the number of elements in the array.
Definition at line 349 of file GEbounds.cpp.
References m_max, m_min, and m_num.
Referenced by merge().
Merge energy interval into energy boundaries.
[in] | emin | Minimum energy of interval. |
[in] | emax | Maximum energy of interval. |
Inserts an energy interval into the energy boundaries after the first boundary that has a minimum energy smaller than emin
and then merges any overlapping or connecting energy boundaries. The method implicitely assumes that the intervals are ordered by increasing minimum energy.
Definition at line 395 of file GEbounds.cpp.
References insert_eng(), m_min, m_num, and merge().
Assignment operator.
[in] | ebds | Energy boundaries to be assigned. |
Definition at line 238 of file GEbounds.cpp.
References copy_members(), free_members(), and init_members().
Print energy boundaries.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GBase.
Definition at line 1232 of file GEbounds.cpp.
References emax(), emin(), EXPLICIT, gammalib::parformat(), SILENT, size(), and gammalib::str().
Referenced by GCOMDri::print(), and GCTACubeBackground::print().
void GEbounds::read | ( | const GFitsTable & | table | ) |
Read energy boundaries from FITS table.
[in] | table | FITS table. |
Reads the energy boundaries from a FITS table. The method interprets the energy units provide in the FITS header. If no energy units are found it is assumed that the energies are stored in units of keV.
Definition at line 761 of file GEbounds.cpp.
References free_members(), init_members(), GFitsHDU::integer(), m_max, m_min, m_num, GFitsHDU::real(), and set_attributes().
Referenced by GEbounds(), GCTAModelSkyCube::load(), load(), GCTACubeBackground::read(), GCTAObservation::read(), GRmf::read(), GPha::read(), GSPIEventCube::read_ebds(), GLATEventCube::read_ebds(), GCTAEventCube::read_ebds(), and GSPIResponse::read_energies().
void GEbounds::read | ( | const GXmlElement & | xml | ) |
Read energy boundaries from XML element.
[in] | xml | XML element. |
GException::invalid_value | Invalid XML format encountered. |
Read energy boundaries from an XML element. The format of the energy boundaries is
<parameter name="EnergyBoundaries" emin="0.1" emax="10.0"/>
The units of the emin and emax parameters are MeV.
Definition at line 869 of file GEbounds.cpp.
References append(), GXmlElement::attribute(), clear(), emax(), emin(), G_READ_XML, GXmlElement::has_attribute(), set_attributes(), gammalib::todouble(), and gammalib::xml_get_par().
|
virtual |
Remove energy interval.
[in] | index | Energy interval index [0,...,size()[. |
Removes energy interval at index
from the energy boundaries container. All intervals after the specified index
are moved forward by one position.
Note that the method does not actually reduce the memory size but just updates the information on the number of elements in the array.
Implements GContainer.
Definition at line 427 of file GEbounds.cpp.
References G_REMOVE_INX, m_max, m_min, m_num, and set_attributes().
Remove energy interval from energy boundaries.
[in] | emin | Minimum energy of interval. |
[in] | emax | Maximum energy of interval. |
GException::invalid_argument | Minimum energy larger than maximum energy |
Removes an energy interval from the energy boundaries. If the energy interval is fully enclosed in an existing energy boundary, the energy boundary will be split into two, excluding the specified energy interval. If the energy interval corresponds exactly to an existing energy boundary the corresponding energy boundary will be removed. Otherwise the existing energy boundaries will be adjusted to exclude the specified energy interval.
Definition at line 471 of file GEbounds.cpp.
References emax(), emin(), G_REMOVE_ENG, insert(), m_max, m_min, m_num, NORMAL, GEnergy::print(), and set_attributes().
|
virtual |
Reserve space for energy intervals.
[in] | num | Number of elements. |
This method does nothing (it is needed to satisfy the GContainer interface).
Implements GContainer.
Definition at line 538 of file GEbounds.cpp.
void GEbounds::save | ( | const GFilename & | filename, |
const bool & | clobber = false , |
||
const std::string & | unit = "keV" |
||
) | const |
Save energy boundaries into FITS file.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite an existing energy boundaries extension? |
[in] | unit | Energy unit |
Saves energy boundaries into a FITS file. If a file with the given filename
does not yet exist it will be created, otherwise the method opens the existing file. Energy boundaries can only be appended to an existing file if the clobber
flag is set to "true" (otherwise an exception is thrown).
The method will append a binary FITS table containing the energy boundaries to the FITS file. The extension name can be specified as part of the filename
. For example the filename
myfile.fits[ENERGY BOUNDARIES]
will save the energy boundaries in the ENERGY BOUNDARIES
extension of the "myfile.fits" file. If the extension exists already in the file it will be replaced, otherwise a new extension will be created. If no extension name is provided, the method will use EBOUNDS
as the default extension name for energy boundaries.
Definition at line 733 of file GEbounds.cpp.
References GFilename::extname(), gammalib::extname_ebounds, GFilename::url(), and write().
void GEbounds::set | ( | const GEnergies & | energies | ) |
Set energy boundaries from energy container.
[in] | energies | Energy container. |
Sets the energy boundaries from an energy container. Each two subsequent energies in the energy container will form an energy boundary. This means that n energies will lead to n-1 energy boundaries with the following mapping:
[energies[0], energies[1]] [energies[1], energies[2]] ... [energies[n-2], energies[n-1]]
If there is only one energy in the container the following empty energy boundary will be appended:
[energies[0], energies[0]]
Definition at line 618 of file GEbounds.cpp.
References append(), clear(), set_attributes(), and GEnergies::size().
Referenced by GEbounds(), and set().
void GEbounds::set | ( | const int & | num, |
const GEnergy & | emin, | ||
const GEnergy & | emax, | ||
const std::string & | method = "LOG" , |
||
const double & | gamma = 1.0 |
||
) |
Set energy intervals.
[in] | num | Number of energy intervals. |
[in] | emin | Minimum energy of first interval. |
[in] | emax | Maximum energy of last interval. |
[in] | method | Energy spacing method (one of "LIN", "LOG" or "POW"). |
[in] | gamma | Power law index for POW method. |
Sets energy boundaries by defining num
successive energy intervals between emin
and emax
. The method
parameter controls the energy spacing of the energy boundaries. See the GEnergies::set() method for more information.
Definition at line 662 of file GEbounds.cpp.
References set().
|
protected |
Set class attributes.
Determines the minimum and maximum energy from all intervals. If no interval is present the minimum and maximum energies are cleared.
Definition at line 1346 of file GEbounds.cpp.
References GEnergy::clear(), m_emax, m_emin, m_max, m_min, and m_num.
Referenced by emax(), emin(), extend(), insert_eng(), read(), remove(), and set().
|
inlinevirtual |
Return number of energy boundaries.
Implements GContainer.
Definition at line 163 of file GEbounds.hpp.
References m_num.
Referenced by GCTAOnOffObservation::apply_ebounds(), GCTAOnOffObservation::arf_stacked(), GCTAOnOffObservation::compute_alpha(), GCTAOnOffObservation::compute_arf(), GCTAOnOffObservation::compute_arf_cut(), GCTAOnOffObservation::compute_bgd(), GCTAOnOffObservation::compute_rmf(), GResponse::convolve(), GModelSpectralTable::create_eng_table(), GModelSpectralTable::create_spec_table(), extend(), GCTACubeBackground::fill(), GArf::GArf(), GCTACubeBackground::GCTACubeBackground(), GCTAModelSpatialLookup::GCTAModelSpatialLookup(), GModelSpectralBins::GModelSpectralBins(), GModelSpectralTable::GModelSpectralTable(), GPha::GPha(), GRmf::GRmf(), GCTAModelSkyCube::load(), GCTAModelIrfBackground::mc(), GCTAModelAeffBackground::mc(), GCTAModelBackground::mc(), GModelSpatialDiffuseCube::mc(), GCTAEdisp2D::normalize_table(), GObservation::npred_spec(), GCTAResponseIrf::nroi(), operator==(), GMWLSpectrum::print(), GCTACubeBackground::print(), GModelSpectralTable::print(), GModelSpatialDiffuseCube::print(), GCTAEdispRmf::print(), GRmf::print(), GArf::print(), print(), GPha::print(), GRmf::read(), GPha::read(), GSPIEventCube::read_ebds(), GCTAOnOffObservation::rmf_stacked(), GModelSpectralTable::scale_energy(), GLATMeanPsf::set(), GCOMIaq::set(), GEnergies::set(), GCOMEventCube::set_energies(), GCTAEventCube::set_energies(), GModelSpectralTable::set_energy_nodes(), GCTACubeBackground::set_eng_axis(), GArf::set_logetrue(), GCTAEdispRmf::set_matrix(), GModelSpectralTable::update(), GPha::write(), and GCOMDri::write_attributes().
void GEbounds::write | ( | GFits & | fits, |
const std::string & | extname = gammalib::extname_ebounds , |
||
const std::string & | unit = "keV" |
||
) | const |
Write energy boundaries into FITS object.
[in] | fits | FITS file. |
[in] | extname | Energy boundary extension name. |
[in] | unit | Energy units. |
Writes the energy boundaries into a FITS object. The unit
parameter specifies in which unit the energies are written. By default, the energy units are keV.
Definition at line 816 of file GEbounds.cpp.
References GFitsTable::append(), GFits::append(), GFits::contains(), GFitsHDU::extname(), m_max, m_min, m_num, GFits::remove(), and GFitsTableCol::unit().
Referenced by save(), GLATEventCube::write(), GCTACubeBackground::write(), GCTAEventCube::write(), GRmf::write(), GPha::write(), and GSPIResponse::write_energies().
void GEbounds::write | ( | GXmlElement & | xml | ) | const |
Write energy boundaries into XML element.
[in] | xml | XML element. |
Writes energy boundaries into an XML element. The format of the energy boundaries is
<parameter name="EnergyBoundaries" emin="0.1" emax="10.0"/>
The units of the emin and emax parameters are MeV.
This method does nothing if the energy boundaries are empty.
Definition at line 913 of file GEbounds.cpp.
References GXmlElement::attribute(), emax(), emin(), G_WRITE_XML, is_empty(), gammalib::str(), and gammalib::xml_need_par().
Energy boundaries inequality operator friend.
[in] | a | First energy boundaries. |
[in] | b | Second energy boundaries. |
Definition at line 213 of file GEbounds.hpp.
Energy boundaries equality operator friend.
[in] | a | First energy boundaries. |
[in] | b | Second energy boundaries. |
Definition at line 1462 of file GEbounds.cpp.
|
protected |
Maximum energy of all intervals.
Definition at line 139 of file GEbounds.hpp.
Referenced by contains(), copy_members(), emax(), init_members(), and set_attributes().
|
protected |
Minimum energy of all intervals.
Definition at line 138 of file GEbounds.hpp.
Referenced by contains(), copy_members(), emin(), init_members(), and set_attributes().
|
protected |
Array of interval maximum energies.
Definition at line 141 of file GEbounds.hpp.
Referenced by contains(), copy_members(), elogmean(), emax(), emean(), ewidth(), extend(), free_members(), index(), init_members(), insert_eng(), merge(), read(), remove(), set_attributes(), and write().
|
protected |
Array of interval minimum energies.
Definition at line 140 of file GEbounds.hpp.
Referenced by contains(), copy_members(), elogmean(), emean(), emin(), ewidth(), extend(), free_members(), index(), init_members(), insert(), insert_eng(), merge(), read(), remove(), set_attributes(), and write().
|
protected |
Number of energy boundaries.
Definition at line 137 of file GEbounds.hpp.
Referenced by append(), contains(), copy_members(), elogmean(), emax(), emean(), emin(), ewidth(), extend(), index(), init_members(), insert(), insert_eng(), is_empty(), merge(), read(), remove(), set_attributes(), size(), and write().