44#define G_READ_XML "GEbounds::read(GXmlElement&)"
45#define G_WRITE_XML "GEbounds::write(GXmlElement&)"
46#define G_REMOVE_INX "GEbounds::remove(int&)"
47#define G_REMOVE_ENG "GEbounds::remove(GEnergy&, GEnergy&)"
48#define G_EMIN_SET "GEbounds::emin(int&, GEnergy&)"
49#define G_EMAX_SET "GEbounds::emax(int&, GEnergy&)"
50#define G_EMIN_GET "GEbounds::emin(int&)"
51#define G_EMAX_GET "GEbounds::emax(int&)"
52#define G_EMEAN "GEbounds::emean(int&)"
53#define G_ELOGMEAN "GEbounds::elogmean(int&)"
54#define G_EWIDTH "GEbounds::ewidth(int&)"
55#define G_INSERT_ENG "GEbounds::insert_eng(int&, GEnergy&, GEnergy&)"
199 const std::string& method,
326 for (; inx <
m_num; ++inx) {
362 for (
int k = i+2; k < num; ++k) {
399 for (; inx <
m_num; ++inx) {
429 #if defined(G_RANGE_CHECK)
475 std::string msg =
"Invalid energy interval specified. Minimum"
477 " larger than maximum energy "+
483 for (
int inx = 0; inx <
m_num; ++inx) {
499 this->
insert(emax, emax_old);
566 for (; inx <
m_num; ++inx) {
572 for (
int i = 0; i < ebds.
size(); ++i, ++inx) {
624 int num = energies.
size();
629 append(energies[0], energies[0]);
635 for (
int i = 0; i < num-1; ++i) {
636 append(energies[i], energies[i+1]);
665 const std::string& method,
692 GFits fits(filename);
735 const std::string& unit)
const
778 std::string emin_unit = table[
"E_MIN"]->unit();
779 std::string emax_unit = table[
"E_MAX"]->unit();
780 if (emin_unit.empty()) {
783 if (emax_unit.empty()) {
788 for (
int i = 0; i <
m_num; ++i) {
789 m_min[i](table[
"E_MIN"]->
real(i), emin_unit);
790 m_max[i](table[
"E_MAX"]->
real(i), emax_unit);
817 const std::string& extname,
818 const std::string& unit)
const
825 for (
int i = 0; i <
m_num; ++i) {
826 cemin(i) =
m_min[i](unit);
827 cemax(i) =
m_max[i](unit);
885 std::string msg =
"Attributes \"emin\" and/or \"emax\" not found"
886 " in XML parameter \"EnergyBoundaries\"."
887 " Please verify the XML format.";
954 for (
int i = 0; i <
m_num; ++i) {
979 #if defined(G_RANGE_CHECK)
983 "Minimum energy of interval",
1012 #if defined(G_RANGE_CHECK)
1016 "Maximum energy of interval",
1043 #if defined(G_RANGE_CHECK)
1047 "Minimum energy of interval",
1068 #if defined(G_RANGE_CHECK)
1072 "Maximum energy of interval",
1097 #if defined(G_RANGE_CHECK)
1128 #if defined(G_RANGE_CHECK)
1156 #if defined(G_RANGE_CHECK)
1186 for (
int i = 0; i <
m_num; ++i) {
1214 bool contained =
false;
1241 result.append(
"=== GEbounds ===");
1248 result.append(
" - ");
1254 for (
int i = 0; i <
size(); ++i) {
1255 result.append(
"\n");
1259 result.append(
" - ");
1311 for (
int i = 0; i <
m_num; ++i) {
1353 for (
int i = 1; i <
m_num; ++i) {
1395 std::string msg =
"Invalid energy interval specified. Minimum"
1397 " larger than maximum energy "+
1406 if (inx < 0) inx = 0;
1415 for (
int i = 0; i < inx; ++i) {
1425 for (
int i = inx+1; i < num; ++i) {
1465 bool identity =
true;
1474 for (
int i = 0; i < a.
size(); ++i) {
bool operator==(const GEbounds &a, const GEbounds &b)
Energy boundaries equality operator friend.
Energy boundaries class interface definition.
Energy container class definition.
Exception handler interface definition.
Filename class interface definition.
FITS binary table class definition.
FITS table double column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
double min(const GVector &vector)
Computes minimum vector element.
double max(const GVector &vector)
Computes maximum vector element.
XML element node class interface definition.
Energy boundaries container class.
GEnergy * m_max
Array of interval maximum energies.
int index(const GEnergy &eng) const
Returns energy bin index for a given energy.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
void remove(const int &index)
Remove energy interval.
void reserve(const int &num)
Reserve space for energy intervals.
bool contains(const GEnergy &eng) const
Checks whether energy boundaries contain energy.
void merge(void)
Merge all overlapping or connecting successive energy intervals.
void set(const GEnergies &energies)
Set energy boundaries from energy container.
GEbounds(void)
Constructor.
void free_members(void)
Delete class members.
GEnergy ewidth(const int &index) const
Returns energy interval width.
void copy_members(const GEbounds &ebds)
Copy class members.
void save(const GFilename &filename, const bool &clobber=false, const std::string &unit="keV") const
Save energy boundaries into FITS file.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
GEbounds * clone(void) const
Clone energy boundaries.
void init_members(void)
Initialise class members.
GEnergy emean(const int &index) const
Returns mean energy for a given energy interval.
int m_num
Number of energy boundaries.
void insert(const GEnergy &emin, const GEnergy &emax)
Insert energy interval.
std::string print(const GChatter &chatter=NORMAL) const
Print energy boundaries.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
virtual ~GEbounds(void)
Destructor.
GEnergy * m_min
Array of interval minimum energies.
GEnergy m_emin
Minimum energy of all intervals.
int size(void) const
Return number of energy boundaries.
void clear(void)
Clear energy boundaries.
void load(const GFilename &filename)
Load energy boundaries from FITS file.
GEbounds & operator=(const GEbounds &ebds)
Assignment operator.
void insert_eng(const int &index, const GEnergy &emin, const GEnergy &emax)
Insert energy interval.
void extend(const GEbounds &ebds)
Append energy boundaries.
bool is_empty(void) const
Signal if there are no energy boundaries.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
GEnergy m_emax
Maximum energy of all intervals.
void write(GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const
Write energy boundaries into FITS object.
void set_attributes(void)
Set class attributes.
int size(void) const
Return number of energies in container.
Class that handles energies in a unit independent way.
double MeV(void) const
Return energy in MeV.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
void clear(void)
Clear instance.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
const std::string & extname(void) const
Return extension name.
double real(const std::string &keyname) const
Return card value as double precision.
int integer(const std::string &keyname) const
Return card value as integer.
void unit(const std::string &unit)
Set column unit.
FITS table double column.
Abstract interface for FITS table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
void save(const bool &clobber=false)
Saves FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const std::string extname_ebounds
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double todouble(const std::string &arg)
Convert string into double precision value.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.