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,
206 set(num, emin, emax, method, gamma);
326 for (; inx <
m_num; ++inx) {
327 if (emin <
m_min[inx])
362 for (
int k = i+2; k < num; ++k) {
399 for (; inx <
m_num; ++inx) {
400 if (emin <
m_min[inx])
429 #if defined(G_RANGE_CHECK)
431 if (index < 0 || index >=
m_num) {
438 for (
int i = index+1; i <
m_num; ++i) {
475 std::string msg =
"Invalid energy interval specified. Minimum"
477 " larger than maximum energy "+
483 for (
int inx = 0; inx <
m_num; ++inx) {
487 if ((
m_min[inx] == emin) && (
m_max[inx] == emax)) {
498 this->
insert(emin_old, emin);
499 this->
insert(emax, emax_old);
508 if ((
m_min[inx] <= emin) && (
m_max[inx] >= emin)) {
514 if ((
m_min[inx] <= emax) && (
m_max[inx] >= emax)) {
566 for (; inx <
m_num; ++inx) {
567 min[inx] =
m_min[inx];
568 max[inx] =
m_max[inx];
572 for (
int i = 0; i < ebds.
size(); ++i, ++inx) {
573 min[inx] = ebds.
m_min[i];
574 max[inx] = ebds.
m_max[i];
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,
669 GEnergies energies(num+1, emin, emax, method, gamma);
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)
981 if (index < 0 || index >=
m_num) {
983 "Minimum energy of interval",
1012 #if defined(G_RANGE_CHECK)
1014 if (index < 0 || index >=
m_num) {
1016 "Maximum energy of interval",
1043 #if defined(G_RANGE_CHECK)
1045 if (index < 0 || index >=
m_num) {
1047 "Minimum energy of interval",
1053 return (
m_min[index]);
1068 #if defined(G_RANGE_CHECK)
1070 if (index < 0 || index >=
m_num) {
1072 "Maximum energy of interval",
1078 return (
m_max[index]);
1097 #if defined(G_RANGE_CHECK)
1099 if (index < 0 || index >=
m_num) {
1128 #if defined(G_RANGE_CHECK)
1130 if (index < 0 || index >=
m_num) {
1156 #if defined(G_RANGE_CHECK)
1158 if (index < 0 || index >=
m_num) {
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) {
1426 min[i] =
m_min[i-1];
1427 max[i] =
m_max[i-1];
1465 bool identity =
true;
1474 for (
int i = 0; i < a.
size(); ++i) {
GEnergy * m_max
Array of interval maximum energies.
void unit(const std::string &unit)
Set column unit.
void init_members(void)
Initialise class members.
FITS table double column class interface definition.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
void copy_members(const GEbounds &ebds)
Copy class members.
GEnergy m_emin
Minimum energy of all intervals.
XML element node class interface definition.
GEbounds(void)
Constructor.
int size(void) const
Return number of energy boundaries.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
GEbounds * clone(void) const
Clone energy boundaries.
bool contains(const GEnergy &eng) const
Checks whether energy boundaries contain energy.
void set_attributes(void)
Set class attributes.
std::string extname(const std::string &defaultname="") const
Return extension name.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
double MeV(void) const
Return energy in MeV.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
GEnergy emean(const int &index) const
Returns mean energy for a given energy interval.
FITS file class interface definition.
double min(const GVector &vector)
Computes minimum vector element.
GEnergy ewidth(const int &index) const
Returns energy interval width.
void write(GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const
Write energy boundaries into FITS object.
int index(const GEnergy &eng) const
Returns energy bin index for a given energy.
double real(const std::string &keyname) const
Return card value as double precision.
int m_num
Number of energy boundaries.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
void extend(const GEbounds &ebds)
Append energy boundaries.
void insert_eng(const int &index, const GEnergy &emin, const GEnergy &emax)
Insert energy interval.
void insert(const GEnergy &emin, const GEnergy &emax)
Insert energy interval.
Energy boundaries container class.
void remove(const int &extno)
Remove HDU from FITS file.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
void set(const GEnergies &energies)
Set energy boundaries from energy container.
Energy container class definition.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
int size(void) const
Return number of energies in container.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
bool is_empty(void) const
Signal if there are no energy boundaries.
const std::string extname_ebounds
Abstract interface for FITS table.
std::string print(const GChatter &chatter=NORMAL) const
Print energy boundaries.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
int integer(const std::string &keyname) const
Return card value as integer.
void reserve(const int &num)
Reserve space for energy intervals.
const std::string & extname(void) const
Return extension name.
void clear(void)
Clear energy boundaries.
double max(const GVector &vector)
Computes maximum vector element.
GEnergy * m_min
Array of interval minimum energies.
void free_members(void)
Delete class members.
std::string url(void) const
Return Uniform Resource Locator (URL)
GEnergy m_emax
Maximum energy of all intervals.
virtual ~GEbounds(void)
Destructor.
Energy boundaries class interface definition.
void remove(const int &index)
Remove energy interval.
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
FITS binary table class definition.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
bool operator==(const GEnergy &a, const GEnergy &b)
Energy equality operator friend.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void close(void)
Close FITS file.
void save(const GFilename &filename, const bool &clobber=false, const std::string &unit="keV") const
Save energy boundaries into FITS file.
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.
GEbounds & operator=(const GEbounds &ebds)
Assignment operator.
void clear(void)
Clear instance.
FITS table double column.
void merge(void)
Merge all overlapping or connecting successive energy intervals.
Filename class interface definition.
double todouble(const std::string &arg)
Convert string into double precision value.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.
void load(const GFilename &filename)
Load energy boundaries from FITS file.