42#define G_REMOVE_INX "GBounds::remove(int&)"
43#define G_SET "GBounds::set(int&, double&, double&, std::string&, double&)"
44#define G_MIN_SET "GBounds::min(int&, double&)"
45#define G_MAX_SET "GBounds::max(int&, double&)"
46#define G_MIN_GET "GBounds::min(int&)"
47#define G_MAX_GET "GBounds::max(int&)"
48#define G_MEAN "GBounds::mean(int&)"
49#define G_LOGMEAN "GBounds::logmean(int&)"
50#define G_WIDTH "GBounds::width(int&)"
51#define G_INSERT_VALUE "GBounds::insert_value(int&, double&, double&)"
189 const std::string& method,
190 const std::string& unit,
235 if (
this != &bounds) {
318 for (; inx <
size(); ++inx) {
341 #if defined(G_RANGE_CHECK)
389 int num = bounds.
size();
395 for (
int i = 0; i < num; ++i) {
440 int num = array.size();
445 append(array[0], array[0]);
451 for (
int i = 0; i < num-1; ++i) {
452 append(array[i], array[i+1]);
487 const std::string& method,
504 std::string msg =
"Negative number of values "+
gammalib::str(num)+
505 " specified. Please specify a non-negative number "
511 if ((umethod ==
"LOG") || (umethod ==
"POW")) {
514 "positive. \""+method+
"\" method requires a "
515 "positive minimum value. Please specify a "
516 "positive minimum value.";
525 "a minimum value that does not exceed the "
534 if (umethod ==
"LIN") {
535 double bin = (
max -
min)/
double(num);
537 for (
int i = 0; i < num; ++i) {
544 else if (umethod ==
"LOG") {
545 double logmin = std::log10(
min);
546 double logmax = std::log10(
max);
547 double logbin = (logmax - logmin)/
double(num);
549 for (
int i = 0; i < num; ++i) {
550 double vmax = std::pow(10.0,
double(i+1)*logbin + logmin);
557 else if (umethod ==
"POW") {
558 double a = 1.0 - gamma;
559 double c = (a == 0.0) ? 1.0 / (std::log(
max) - std::log(
min))
560 : a / (std::pow(
max,a) - std::pow(
min,a));
561 double b = double(c*(num));
563 for (
int i = 0; i < num; ++i) {
564 double logvmax = (a == 0.0) ? 1.0/b + std::log(vmin)
565 : std::log(a/b + std::pow(vmin,a)) / a;
566 double vmax = std::exp(logvmax);
574 std::string msg =
"Invalid spacing method \""+umethod+
"\" "
575 "specified. Please provide one of \"LIN\", \"LOG\""
598 GFits fits(filename);
638 const bool& clobber)
const
668 int num = table.
nrows();
684 for (
int i = 0; i < num; ++i) {
710 for (
int i = 0; i <
size(); ++i) {
711 col_min(i) =
m_min[i];
712 col_max(i) =
m_max[i];
764 for (
int i = 0; i <
size(); ++i) {
789 for (
int i = 1; i <
size(); ++i) {
814 for (
int i = 1; i <
size(); ++i) {
839 #if defined(G_RANGE_CHECK)
868 #if defined(G_RANGE_CHECK)
895 #if defined(G_RANGE_CHECK)
919 #if defined(G_RANGE_CHECK)
945 #if defined(G_RANGE_CHECK)
974 #if defined(G_RANGE_CHECK)
1001 #if defined(G_RANGE_CHECK)
1026 bool contained =
false;
1029 for (
int i = 0; i <
size(); ++i) {
1030 if (value >=
m_min[i] && value <=
m_max[i]) {
1054 bool contained =
false;
1057 for (
int i = 0; i <
size(); ++i) {
1084 result.append(
"=== GBounds ===");
1091 result.append(
" - ");
1093 if (
unit().length() > 0) {
1095 result.append(
unit());
1101 for (
int i = 0; i <
size(); ++i) {
1102 result.append(
"\n");
1106 result.append(
" - ");
1192 std::string msg =
"Invalid interval specified. Minimum"
1194 " larger than maximum value "+
1224 bool identity =
true;
1233 for (
int i = 0; i < a.
size(); ++i) {
1234 if ((a.
min(i) != b.
min(i)) || (a.
max(i) != b.
max(i))) {
bool operator==(const GBounds &a, const GBounds &b)
Boundaries equality operator friend.
Boundaries class interface 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.
Boundaries container class.
void insert(const double &min, const double &max)
Insert interval.
void extend(const GBounds &bounds)
Append boundaries.
void read(const GFitsTable &table)
Read boundaries from FITS table.
void remove(const int &index)
Remove interval.
void clear(void)
Clear boundaries.
GBounds(void)
Void constructor.
bool is_empty(void) const
Signal if there are no boundaries.
GBounds * clone(void) const
Clone boundaries.
void init_members(void)
Initialise class members.
const std::string & unit(void) const
Return boundary units.
void free_members(void)
Delete class members.
void append(const double &min, const double &max)
Append interval.
void reserve(const int &num)
Reserve space for intervals.
void copy_members(const GBounds &bounds)
Copy class members.
std::string m_unit
Unit of values.
std::vector< double > m_max
Array of interval maximum values.
void save(const GFilename &filename, const bool &clobber=false) const
Save boundaries into FITS file.
double max(void) const
Return maximum value of all intervals.
GBounds & operator=(const GBounds &bounds)
Assignment operator.
std::string print(const GChatter &chatter=NORMAL) const
Print boundaries.
double mean(const int &index) const
Returns mean value for a given interval.
double min(void) const
Return minimum value of all intervals.
virtual ~GBounds(void)
Destructor.
void insert_interval(const int &index, const double &min, const double &max)
Insert interval.
void write(GFits &file, const std::string &extname=gammalib::extname_bounds) const
Write boundaries into FITS object.
std::vector< double > m_min
Array of interval minimum values.
int size(void) const
Return number of boundaries.
void set(const std::vector< double > &array)
Set boundaries from array.
bool contains(const double &value) const
Checks whether boundaries contain value.
double logmean(const int &index) const
Returns logarithmic mean value for a given interval.
void load(const GFilename &filename)
Load boundaries from FITS file.
double width(const int &index) const
Returns interval width.
int index(const double &value) const
Returns bin index for a value.
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.
Abstract interface for FITS table column.
virtual double real(const int &row, const int &inx=0) const =0
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.
const int & nrows(void) const
Return number of rows in 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.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const std::string extname_bounds
std::string toupper(const std::string &s)
Convert string to upper case.