43 #define G_AT "GEnergies::at(int&)"
44 #define G_INSERT "GEnergies::insert(int&, GEnergy&)"
45 #define G_REMOVE "GEnergies::remove(int&)"
46 #define G_SET "GEnergies::set(int&, GEnergy&, GEnergy&, std::string&, "\
48 #define G_SET_LIN "GEnergies::set_lin(int&, GEnergy&, GEnergy&)"
49 #define G_SET_LOG "GEnergies::set_log(int&, GEnergy&, GEnergy&)"
50 #define G_SET_POW "GEnergies::set_pow(int&, GEnergy&, GEnergy&, double&)"
156 const std::string& method,
163 set(num, emin, emax, method, gamma);
198 if (
this != &energies) {
266 if (index < 0 || index >=
size()) {
288 if (index < 0 || index >=
size()) {
330 #if defined(G_RANGE_CHECK)
338 if (index < 0 || index >=
size()) {
366 #if defined(G_RANGE_CHECK)
367 if (index < 0 || index >=
size()) {
396 int num = energies.
size();
402 for (
int i = 0; i < num; ++i) {
427 int num = ebounds.
size();
430 for (
int i = 0; i < num; ++i) {
433 for (
int j = 0; j < 2; ++j) {
439 bool not_found =
true;
479 const std::string& method,
484 std::string msg =
"Negative number of energies "+
gammalib::str(num)+
485 " specified. Please specify a non-negative number "
492 std::string msg =
"Minimum energy "+emin.
print()+
" is larger than "
493 "maximum energy "+emax.
print()+
". Please specify "
494 "a minimum energy that does not exceed the "
504 std::string msg =
"Single energy is requested but the minimum "
505 "energy "+emin.
print()+
" differs from the "
506 "maximum energy "+emax.
print()+
". Please "
507 "specify identical energies.";
517 if (umethod ==
"LIN") {
520 else if (umethod ==
"LOG") {
523 else if (umethod ==
"POW") {
524 set_pow(num, emin, emax, gamma);
527 std::string msg =
"Invalid energy spacing method \""+umethod+
"\" "
528 "specified. Please provide one of \"LIN\", \"LOG\""
551 GFits fits(filename);
624 int num = table.
integer(
"NAXIS2");
631 std::string unit =
"MeV";
633 unit = table.
string(
"TUNIT1");
640 for (
int i = 0; i < num; ++i) {
668 for (
int i = 0; i < num; ++i) {
669 col_energy(i) = (*this)[i].MeV();
671 col_energy.
unit(
"MeV");
707 result.append(
"=== GEnergies ===");
715 for (
int i = 0; i <
size(); ++i) {
807 GEnergy ebin = (emax - emin)/
double(num-1);
811 for (
int i = 0; i < num; ++i) {
853 if (emin.
MeV() <= 0.0) {
854 std::string msg =
"Non-positive minimum energy "+emin.
print()+
855 " specified. Please provide a positive minimum "
859 if (emax.
MeV() <= 0.0) {
860 std::string msg =
"Non-positive maximum energy "+emax.
print()+
861 " specified. Please provide a positive minimum "
877 double elogbin = (elogmax - elogmin)/
double(num-1);
881 for (
int i = 0; i < num; ++i) {
882 energy.
MeV(
std::pow(10.0,
double(i)*elogbin + elogmin));
935 if (emin.
MeV() <= 0.0) {
936 std::string msg =
"Non-positive minimum energy "+emin.
print()+
937 " specified. Please provide a positive minimum "
941 if (emax.
MeV() <= 0.0) {
942 std::string msg =
"Non-positive maximum energy "+emax.
print()+
943 " specified. Please provide a positive minimum "
960 double a = 1.0 - gamma;
963 double b = double(c*(num-1.0));
966 double e = emin.
MeV();
969 for (
int i = 0; i < num-1; ++i) {
972 double log_e_next = (a == 0.0)
975 double e_next =
std::exp(log_e_next);
std::string print(const GChatter &chatter=NORMAL) const
Print energy container information.
void unit(const std::string &unit)
Set column unit.
void clear(void)
Clear energy container.
FITS table double column class interface definition.
void read(const GFitsTable &table)
Read energies from FITS table.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
bool has_card(const int &cardno) const
Check existence of header card.
void write(GFits &file, const std::string &extname=gammalib::extname_energies) const
Write energies into FITS object.
int size(void) const
Return number of energy boundaries.
void set_pow(const int &num, const GEnergy &emin, const GEnergy &emax, const double &gamma)
Set power-law spaced energy intervals.
void reserve(const int &num)
Reserves space for energies in container.
void set_lin(const int &num, const GEnergy &emin, const GEnergy &emax)
Set linearly spaced energies.
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.
FITS file class interface definition.
virtual ~GEnergies(void)
Destructor.
FITS table column abstract base class definition.
void remove(const int &index)
Remove energy from container.
void free_members(void)
Delete class members.
GEnergy & insert(const int &index, const GEnergy &energy)
Insert energy into container.
std::vector< GEnergy > m_energies
List of energies.
GEnergies(void)
Void constructor.
Energy boundaries container class.
void remove(const int &extno)
Remove HDU from FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Energy container class definition.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Abstract interface for FITS table column.
GEnergy & at(const int &index)
Return reference to energy.
int size(void) const
Return number of energies in container.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Abstract interface for FITS table.
int integer(const std::string &keyname) const
Return card value as integer.
void extend(const GEnergies &energies)
Append energy container.
const std::string & extname(void) const
Return extension name.
void save(const GFilename &filename, const bool &clobber=false) const
Save energies into FITS file.
bool is_empty(void) const
Signals if there are no energies in container.
const std::string extname_energies
void set(const GEbounds &ebounds)
Set energies from energy boundaries.
GEnergies & operator=(const GEnergies &energies)
Assignment operator.
std::string url(void) const
Return Uniform Resource Locator (URL)
virtual double real(const int &row, const int &inx=0) const =0
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
std::string string(const std::string &keyname) const
Return card value as string.
Energy boundaries class interface definition.
GEnergy & append(const GEnergy &energy)
Append energy to container.
void copy_members(const GEnergies &energies)
Copy class members.
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
std::string toupper(const std::string &s)
Convert string to upper case.
FITS binary table class definition.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GEnergies * clone(void) const
Clone energy container.
void set_log(const int &num, const GEnergy &emin, const GEnergy &emax)
Set logarithmically spaced energies.
void load(const GFilename &filename)
Load energies from FITS file.
void close(void)
Close FITS file.
FITS table double column.
void init_members(void)
Initialise class members.
Filename class interface definition.
GVector log10(const GVector &vector)
Computes base10 logarithm of vector elements.
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.