GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEnergies.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GEnergies.cpp - Energy container class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-2017 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GEnergies.cpp
23  * @brief Energy container class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GTools.hpp"
32 #include "GException.hpp"
33 #include "GFilename.hpp"
34 #include "GEnergies.hpp"
35 #include "GEbounds.hpp"
36 #include "GFits.hpp"
37 #include "GFitsTable.hpp"
38 #include "GFitsBinTable.hpp"
39 #include "GFitsTableCol.hpp"
40 #include "GFitsTableDoubleCol.hpp"
41 
42 /* __ Method name definitions ____________________________________________ */
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_LIN "GEnergies::set_lin(int&, GEnergy&, GEnergy&)"
47 #define G_SET_LOG "GEnergies::set_log(int&, GEnergy&, GEnergy&)"
48 
49 /* __ Macros _____________________________________________________________ */
50 
51 /* __ Coding definitions _________________________________________________ */
52 
53 /* __ Debug definitions __________________________________________________ */
54 
55 
56 /*==========================================================================
57  = =
58  = Constructors/destructors =
59  = =
60  ==========================================================================*/
61 
62 /***********************************************************************//**
63  * @brief Void constructor
64  *
65  * Constructs empty energy container.
66  ***************************************************************************/
68 {
69  // Initialise members
70  init_members();
71 
72  // Return
73  return;
74 }
75 
76 
77 /***********************************************************************//**
78  * @brief FITS file constructor
79  *
80  * @param[in] filename FITS file name.
81  *
82  * Constructs energy container from a FITS file.
83  ***************************************************************************/
85 {
86  // Initialise members
87  init_members();
88 
89  // Load energies
90  load(filename);
91 
92  // Return
93  return;
94 }
95 
96 
97 /***********************************************************************//**
98  * @brief Energy boundaries constructor
99  *
100  * @param[in] ebounds Energy boundaries.
101  *
102  * Constructs energy container from energy boundaries.
103  ***************************************************************************/
105 {
106  // Initialise members
107  init_members();
108 
109  // Set energies from energy boundaries
110  set(ebounds);
111 
112  // Return
113  return;
114 }
115 
116 
117 /***********************************************************************//**
118  * @brief Copy constructor
119  *
120  * @param energies Energy container.
121  *
122  * Construct energy container by copying from another energy container.
123  ***************************************************************************/
125 {
126  // Initialise members
127  init_members();
128 
129  // Copy members
130  copy_members(energies);
131 
132  // Return
133  return;
134 }
135 
136 
137 /***********************************************************************//**
138  * @brief Interval constructor
139  *
140  * @param[in] num Number of energies.
141  * @param[in] emin Minimum energy.
142  * @param[in] emax Maximum energy.
143  * @param[in] log Use logarithmic spacing? (defaults to true).
144  *
145  * Constructs energy container by defining @p num energies between @p emin
146  * and @p emax. The @p log parameter controls whether the energy spacing is
147  * logarihmic (default) or linear.
148  ***************************************************************************/
149 GEnergies::GEnergies(const int& num, const GEnergy& emin, const GEnergy& emax,
150  const bool& log)
151 {
152  // Initialise members
153  init_members();
154 
155  // Set intervals
156  if (log) {
157  this->set_log(num, emin, emax);
158  }
159  else {
160  this->set_lin(num, emin, emax);
161  }
162 
163  // Return
164  return;
165 }
166 
167 
168 /***********************************************************************//**
169  * @brief Destructor
170  ***************************************************************************/
172 {
173  // Free members
174  free_members();
175 
176  // Return
177  return;
178 }
179 
180 
181 /*==========================================================================
182  = =
183  = Operators =
184  = =
185  ==========================================================================*/
186 
187 /***********************************************************************//**
188  * @brief Assignment operator
189  *
190  * @param[in] energies Energy container.
191  * @return Energy container.
192  ***************************************************************************/
194 {
195  // Execute only if object is not identical
196  if (this != &energies) {
197 
198  // Free members
199  free_members();
200 
201  // Initialise members
202  init_members();
203 
204  // Copy members
205  copy_members(energies);
206 
207  } // endif: object was not identical
208 
209  // Return this object
210  return *this;
211 }
212 
213 
214 /*==========================================================================
215  = =
216  = Public methods =
217  = =
218  ==========================================================================*/
219 
220 /***********************************************************************//**
221  * @brief Clear energy container
222  *
223  * Removes all energies from the container.
224  ***************************************************************************/
226 {
227  // Free members
228  free_members();
229 
230  // Initialise members
231  init_members();
232 
233  // Return
234  return;
235 }
236 
237 
238 /***********************************************************************//**
239  * @brief Clone energy container
240  *
241  * @return Pointer to deep copy of energy container
242  *
243  * Makes a deep copy of the energy container instance.
244  ***************************************************************************/
246 {
247  return new GEnergies(*this);
248 }
249 
250 
251 /***********************************************************************//**
252  * @brief Return reference to energy
253  *
254  * @param[in] index Energy index [0,...,size()-1].
255  *
256  * @exception GException::out_of_range
257  * Energy index is out of range.
258  *
259  * Returns a reference to the energy with the specified @p index.
260  ***************************************************************************/
261 GEnergy& GEnergies::at(const int& index)
262 {
263  // Raise exception if index is out of range
264  if (index < 0 || index >= size()) {
265  throw GException::out_of_range(G_AT, index, 0, size()-1);
266  }
267 
268  // Return reference
269  return m_energies[index];
270 }
271 
272 
273 /***********************************************************************//**
274  * @brief Return reference to energy (const version)
275  *
276  * @param[in] index Energy index [0,...,size()-1].
277  *
278  * @exception GException::out_of_range
279  * Energy index is out of range.
280  *
281  * Returns a reference to the energy with the specified @p index.
282  ***************************************************************************/
283 const GEnergy& GEnergies::at(const int& index) const
284 {
285  // Raise exception if index is out of range
286  if (index < 0 || index >= size()) {
287  throw GException::out_of_range(G_AT, index, 0, size()-1);
288  }
289 
290  // Return reference
291  return m_energies[index];
292 }
293 
294 
295 /***********************************************************************//**
296  * @brief Append energy to container
297  *
298  * @param[in] energy Energy.
299  * @return Reference to appended energy.
300  *
301  * Appends energy to the container by making a deep copy of the energy.
302  ***************************************************************************/
304 {
305  // Append energy to list
306  m_energies.push_back(energy);
307 
308  // Return reference
309  return m_energies[size()-1];
310 }
311 
312 
313 /***********************************************************************//**
314  * @brief Insert energy into container
315  *
316  * @param[in] index Energy index (0,...,size()-1).
317  * @param[in] energy Energy.
318  *
319  * @exception GException::out_of_range
320  * Energy index is out of range.
321  *
322  * Inserts an @p energy into the container before the energy with the
323  * specified @p index.
324  ***************************************************************************/
325 GEnergy& GEnergies::insert(const int& index, const GEnergy& energy)
326 {
327  // Compile option: raise exception if index is out of range
328  #if defined(G_RANGE_CHECK)
329  if (is_empty()) {
330  if (index > 0) {
331  throw GException::out_of_range(G_INSERT, index, 0, size()-1);
332  }
333  }
334  else {
335  if (index < 0 || index >= size()) {
336  throw GException::out_of_range(G_INSERT, index, 0, size()-1);
337  }
338  }
339  #endif
340 
341  // Inserts energy
342  m_energies.insert(m_energies.begin()+index, energy);
343 
344  // Return reference
345  return m_energies[index];
346 }
347 
348 
349 /***********************************************************************//**
350  * @brief Remove energy from container
351  *
352  * @param[in] index Energy index (0,...,size()-1).
353  *
354  * @exception GException::out_of_range
355  * Energy index is out of range.
356  *
357  * Remove energy of specified @p index from container.
358  ***************************************************************************/
359 void GEnergies::remove(const int& index)
360 {
361  // Compile option: raise exception if index is out of range
362  #if defined(G_RANGE_CHECK)
363  if (index < 0 || index >= size()) {
364  throw GException::out_of_range(G_REMOVE, index, 0, size()-1);
365  }
366  #endif
367 
368  // Erase energy from container
369  m_energies.erase(m_energies.begin() + index);
370 
371  // Return
372  return;
373 }
374 
375 
376 /***********************************************************************//**
377  * @brief Append energy container
378  *
379  * @param[in] energies Energy container.
380  *
381  * Append energy container to the container.
382  ***************************************************************************/
383 void GEnergies::extend(const GEnergies& energies)
384 {
385  // Do nothing if energy container is empty
386  if (!energies.is_empty()) {
387 
388  // Get size. Note that we extract the size first to avoid an
389  // endless loop that arises when a container is appended to
390  // itself.
391  int num = energies.size();
392 
393  // Reserve enough space
394  reserve(size() + num);
395 
396  // Loop over all elements and append them to container
397  for (int i = 0; i < num; ++i) {
398  m_energies.push_back(energies[i]);
399  }
400 
401  } // endif: energy container was not empty
402 
403  // Return
404  return;
405 }
406 
407 
408 /***********************************************************************//**
409  * @brief Set energies from energy boundaries
410  *
411  * @param[in] ebounds Energy boundaries.
412  *
413  * Sets the energies from energy boundaries. Each unique minimum and maximum
414  * energy boundary will be appended as energy to the container.
415  ***************************************************************************/
416 void GEnergies::set(const GEbounds& ebounds)
417 {
418  // Initialise members
419  clear();
420 
421  // Get number of energy boundaries
422  int num = ebounds.size();
423 
424  // Append energy boundaries
425  for (int i = 0; i < num; ++i) {
426 
427  // Loop over minimum and maximum boundaries
428  for (int j = 0; j < 2; ++j) {
429 
430  // Get energy
431  GEnergy energy = (j == 0) ? ebounds.emin(i) : ebounds.emax(i);
432 
433  // Append energy if it does not yet exist in the container
434  bool not_found = true;
435  for (int k = 0; k < m_energies.size(); ++k) {
436  if (energy == m_energies[k]) {
437  not_found = false;
438  break;
439  }
440  }
441  if (not_found) {
442  m_energies.push_back(energy);
443  }
444 
445  } // endfor: looped over minimum and maximum boundaries
446 
447  } // endfor: looped over energy boundaries
448 
449  // Return
450  return;
451 }
452 
453 
454 /***********************************************************************//**
455  * @brief Set linearly spaced energies
456  *
457  * @param[in] num Number of energies.
458  * @param[in] emin Minimum energy.
459  * @param[in] emax Maximum energy.
460  *
461  * @exception GException::invalid_argument
462  * Invalid number of energies or minimum and maximum energy
463  * requested.
464  *
465  * Creates @p num linearly spaced energies running from @p emin to @p emax.
466  ***************************************************************************/
467 void GEnergies::set_lin(const int& num,
468  const GEnergy& emin,
469  const GEnergy& emax)
470 {
471  // Initialise members
472  clear();
473 
474  // Check validity of number of energies
475  if (num < 0) {
476  std::string msg = "Negative number of energies "+gammalib::str(num)+
477  " specified. Specify a non-negative number of "
478  "energies.";
480  }
481 
482  // Check validity of energies
483  if (emin > emax) {
484  std::string msg = "Minimum energy "+emin.print()+" is larger than "
485  "maximum energy "+emax.print()+". Specify "
486  "a minimum energy that does not exceed the "
487  "maximum energy.";
489  }
490 
491  // Case A: we have 1 energy
492  if (num == 1) {
493 
494  // Check that emin and emax are equal
495  if (emin != emax) {
496  std::string msg = "Single energy is requested but the minimum "
497  "energy "+emin.print()+" differs from the "
498  "maximum energy "+emax.print()+". Specify "
499  "identical energies.";
501  }
502 
503  // Append energy
504  append(emin);
505 
506  }
507 
508  // Case B: more than 1 energy requested
509  else if (num > 1) {
510 
511  // Compute bin width
512  GEnergy ebin = (emax - emin)/double(num-1);
513 
514  // Append energies
515  GEnergy energy = emin;
516  for (int i = 0; i < num; ++i) {
517  append(energy);
518  energy += ebin;
519  }
520 
521  }
522 
523  // Return
524  return;
525 }
526 
527 
528 /***********************************************************************//**
529  * @brief Set logarithmically spaced energies
530  *
531  * @param[in] num Number of energies.
532  * @param[in] emin Minimum energy.
533  * @param[in] emax Maximum energy.
534  *
535  * @exception GException::invalid_argument
536  * Invalid number of energies or minimum and maximum energy
537  * requested.
538  *
539  * Creates @p num logarithmically spaced energies running from @p emin to
540  * @p emax.
541  ***************************************************************************/
542 void GEnergies::set_log(const int& num,
543  const GEnergy& emin,
544  const GEnergy& emax)
545 {
546  // Initialise members
547  clear();
548 
549  // Check validity of number of energies
550  if (num < 0) {
551  std::string msg = "Negative number of energies "+gammalib::str(num)+
552  " specified. Specify a non-negative number of "
553  "energies.";
555  }
556 
557  // Check validity of energies
558  if (emin > emax) {
559  std::string msg = "Minimum energy "+emin.print()+" is larger than "
560  "maximum energy "+emax.print()+". Specify "
561  "a minimum energy that does not exceed the "
562  "maximum energy.";
564  }
565 
566  // Case A: we have 1 energy
567  if (num == 1) {
568 
569  // Check that emin and emax are equal
570  if (emin != emax) {
571  std::string msg = "Single energy is requested but the minimum "
572  "energy "+emin.print()+" differs from the "
573  "maximum energy "+emax.print()+". Specify "
574  "identical energies.";
576  }
577 
578  // Append energy
579  append(emin);
580 
581  }
582 
583  // Case B: more than 1 energy requested
584  else if (num > 1) {
585 
586  // Compute bin width
587  double elogmin = std::log10(emin.MeV());
588  double elogmax = std::log10(emax.MeV());
589  double elogbin = (elogmax - elogmin)/double(num-1);
590 
591  // Append energies
592  GEnergy energy;
593  for (int i = 0; i < num; ++i) {
594  energy.MeV(std::pow(10.0, double(i)*elogbin + elogmin));
595  append(energy);
596  }
597 
598  }
599 
600  // Return
601  return;
602 }
603 
604 
605 /***********************************************************************//**
606  * @brief Load energies from FITS file
607  *
608  * @param[in] filename FITS file name.
609  *
610  * Loads the energies from FITS file.
611  *
612  * If no extension name is provided, the energies are loaded from the
613  * `ENERGIES` extension.
614  ***************************************************************************/
615 void GEnergies::load(const GFilename& filename)
616 {
617  // Open FITS file
618  GFits fits(filename);
619 
620  // Get energies table
621  const GFitsTable& table = *fits.table(filename.extname(gammalib::extname_energies));
622 
623  // Read energies from table
624  read(table);
625 
626  // Close FITS file
627  fits.close();
628 
629  // Return
630  return;
631 }
632 
633 
634 /***********************************************************************//**
635  * @brief Save energies into FITS file
636  *
637  * @param[in] filename FITS filename.
638  * @param[in] clobber Overwrite an existing energies extension?
639  *
640  * Saves energies into a FITS file. If a file with the given @p filename
641  * does not yet exist it will be created, otherwise the method opens the
642  * existing file. Energies can only be appended to an existing file if the
643  * @p clobber flag is set to `true` (otherwise an exception is thrown).
644  *
645  * The method will append a binary FITS table containing the energies to the
646  * FITS file. The extension name can be specified as part of the
647  * @p filename. For example the @p filename
648  *
649  * myfile.fits[ENERGY VALUES]
650  *
651  * will save the energies in the `ENERGY VALUES` extension of the
652  * `myfile.fits` file. If the extension exists already in the file it will be
653  * replaced, otherwise a new extension will be created. If no extension name
654  * is provided, the method will use `ENERGIES` as the default extension name
655  * for energies.
656  ***************************************************************************/
657 void GEnergies::save(const GFilename& filename, const bool& clobber) const
658 {
659  // Open or create FITS file (without extension name since the requested
660  // extension may not yet exist in the file)
661  GFits fits(filename.url(), true);
662 
663  // Write energies to FITS file
664  write(fits, filename.extname(gammalib::extname_energies));
665 
666  // Save to file
667  fits.save(clobber);
668 
669  // Return
670  return;
671 }
672 
673 
674 /***********************************************************************//**
675  * @brief Read energies from FITS table
676  *
677  * @param[in] table FITS table.
678  *
679  * Reads the energies from a FITS table.
680  ***************************************************************************/
681 void GEnergies::read(const GFitsTable& table)
682 {
683  // Free members
684  free_members();
685 
686  // Initialise attributes
687  init_members();
688 
689  // Extract number of energy bins in FITS file
690  int num = table.integer("NAXIS2");
691 
692  // Continue only if there are energy bins
693  if (num > 0) {
694 
695  // Get the unit of the energies. If no TUNIT1 header keyword is
696  // found then use MeV
697  std::string unit = "MeV";
698  if (table.has_card("TUNIT1")) {
699  unit = table.string("TUNIT1");
700  }
701 
702  // Get the column with the name "Energy"
703  const GFitsTableCol* col_energy = table["Energy"];
704 
705  // Set energies
706  for (int i = 0; i < num; ++i) {
707  append(GEnergy(col_energy->real(i), unit));
708  }
709 
710  } // endif: there were energy bins
711 
712  // Return
713  return;
714 }
715 
716 
717 /***********************************************************************//**
718  * @brief Write energies into FITS object
719  *
720  * @param[in] fits FITS file.
721  * @param[in] extname Energy extension name.
722  *
723  * Writes energies into FITS object.
724  ***************************************************************************/
725 void GEnergies::write(GFits& fits, const std::string& extname) const
726 {
727  // Set number of energies
728  int num = m_energies.size();
729 
730  // Create Energy column
731  GFitsTableDoubleCol col_energy("Energy", num);
732 
733  // Fill energy column in units of MeV
734  for (int i = 0; i < num; ++i) {
735  col_energy(i) = (*this)[i].MeV();
736  }
737  col_energy.unit("MeV");
738 
739  // Create energies table
740  GFitsBinTable table(num);
741  table.append(col_energy);
742  table.extname(extname);
743 
744  // If the FITS object contains already an extension with the same
745  // name then remove now this extension
746  if (fits.contains(extname)) {
747  fits.remove(extname);
748  }
749 
750  // Append energies table to FITS file
751  fits.append(table);
752 
753  // Return
754  return;
755 }
756 
757 
758 /***********************************************************************//**
759  * @brief Print energy container information
760  *
761  * @param[in] chatter Chattiness.
762  * @return String containing energy container information.
763  ***************************************************************************/
764 std::string GEnergies::print(const GChatter& chatter) const
765 {
766  // Initialise result string
767  std::string result;
768 
769  // Continue only if chatter is not silent
770  if (chatter != SILENT) {
771 
772  // Append header
773  result.append("=== GEnergies ===");
774 
775  // Append energy container information
776  result.append("\n"+gammalib::parformat("Number of energies"));
777  result.append(gammalib::str(size()));
778 
779  // EXPLICIT: Append energies
780  if (chatter >= EXPLICIT) {
781  for (int i = 0; i < size(); ++i) {
782  result.append("\n");
783  result.append(gammalib::parformat("Energy "+gammalib::str(i)));
784  result.append(m_energies[i].print(chatter));
785  }
786  }
787 
788  } // endif: chatter was not silent
789 
790  // Return result
791  return result;
792 }
793 
794 
795 /*==========================================================================
796  = =
797  = Private methods =
798  = =
799  ==========================================================================*/
800 
801 /***********************************************************************//**
802  * @brief Initialise class members
803  ***************************************************************************/
805 {
806  // Initialise members
807  m_energies.clear();
808 
809  // Return
810  return;
811 }
812 
813 
814 /***********************************************************************//**
815  * @brief Copy class members
816  *
817  * @param[in] energies Energy container.
818  ***************************************************************************/
819 void GEnergies::copy_members(const GEnergies& energies)
820 {
821  // Copy attributes
822  m_energies = energies.m_energies;
823 
824  // Return
825  return;
826 }
827 
828 
829 /***********************************************************************//**
830  * @brief Delete class members
831  ***************************************************************************/
833 {
834  // Return
835  return;
836 }
std::string print(const GChatter &chatter=NORMAL) const
Print energy container information.
Definition: GEnergies.cpp:764
void unit(const std::string &unit)
Set column unit.
void clear(void)
Clear energy container.
Definition: GEnergies.cpp:225
FITS table double column class interface definition.
void read(const GFitsTable &table)
Read energies from FITS table.
Definition: GEnergies.cpp:681
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Definition: GFits.cpp:472
bool contains(const int &extno) const
Check if HDU exists in FITS file.
Definition: GFits.hpp:282
bool has_card(const int &cardno) const
Check existence of header card.
Definition: GFitsHDU.hpp:233
void write(GFits &file, const std::string &extname=gammalib::extname_energies) const
Write energies into FITS object.
Definition: GEnergies.cpp:725
int size(void) const
Return number of energy boundaries.
Definition: GEbounds.hpp:157
void reserve(const int &num)
Reserves space for energies in container.
Definition: GEnergies.hpp:190
void set_lin(const int &num, const GEnergy &emin, const GEnergy &emax)
Set linearly spaced energies.
Definition: GEnergies.cpp:467
#define G_INSERT
Definition: GEnergies.cpp:44
std::string extname(const std::string &defaultname="") const
Return extension name.
Definition: GFilename.cpp:385
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
Definition: GFitsTable.hpp:147
double MeV(void) const
Return energy in MeV.
Definition: GEnergy.cpp:321
Gammalib tools definition.
FITS file class.
Definition: GFits.hpp:63
FITS file class interface definition.
virtual ~GEnergies(void)
Destructor.
Definition: GEnergies.cpp:171
FITS table column abstract base class definition.
Energy container class.
Definition: GEnergies.hpp:60
#define G_SET_LIN
Definition: GEnergies.cpp:46
void remove(const int &index)
Remove energy from container.
Definition: GEnergies.cpp:359
void free_members(void)
Delete class members.
Definition: GEnergies.cpp:832
GEnergy & insert(const int &index, const GEnergy &energy)
Insert energy into container.
Definition: GEnergies.cpp:325
std::vector< GEnergy > m_energies
List of energies.
Definition: GEnergies.hpp:110
#define G_AT
Definition: GEnergies.cpp:43
#define G_SET_LOG
Definition: GEnergies.cpp:47
GEnergies(void)
Void constructor.
Definition: GEnergies.cpp:67
Energy boundaries container class.
Definition: GEbounds.hpp:60
void remove(const int &extno)
Remove HDU from FITS file.
Definition: GFits.cpp:848
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Definition: GEnergy.cpp:748
Filename class.
Definition: GFilename.hpp:62
Energy container class definition.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Definition: GEbounds.hpp:181
Abstract interface for FITS table column.
GEnergy & at(const int &index)
Return reference to energy.
Definition: GEnergies.cpp:261
int size(void) const
Return number of energies in container.
Definition: GEnergies.hpp:162
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1184
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
int integer(const std::string &keyname) const
Return card value as integer.
Definition: GFitsHDU.hpp:436
void extend(const GEnergies &energies)
Append energy container.
Definition: GEnergies.cpp:383
const std::string & extname(void) const
Return extension name.
Definition: GFitsHDU.hpp:162
void save(const GFilename &filename, const bool &clobber=false) const
Save energies into FITS file.
Definition: GEnergies.cpp:657
bool is_empty(void) const
Signals if there are no energies in container.
Definition: GEnergies.hpp:176
const std::string extname_energies
Definition: GEnergies.hpp:44
void set(const GEbounds &ebounds)
Set energies from energy boundaries.
Definition: GEnergies.cpp:416
GEnergies & operator=(const GEnergies &energies)
Assignment operator.
Definition: GEnergies.cpp:193
std::string url(void) const
Return Uniform Resource Locator (URL)
Definition: GFilename.hpp:189
virtual double real(const int &row, const int &inx=0) const =0
FITS binary table class.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
Definition: GVector.cpp:1332
std::string string(const std::string &keyname) const
Return card value as string.
Definition: GFitsHDU.hpp:410
Energy boundaries class interface definition.
GEnergy & append(const GEnergy &energy)
Append energy to container.
Definition: GEnergies.cpp:303
void copy_members(const GEnergies &energies)
Copy class members.
Definition: GEnergies.cpp:819
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
Definition: GFits.cpp:665
FITS binary table class definition.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
Definition: GEbounds.hpp:193
#define G_REMOVE
Definition: GEnergies.cpp:45
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1022
GEnergies * clone(void) const
Clone energy container.
Definition: GEnergies.cpp:245
void set_log(const int &num, const GEnergy &emin, const GEnergy &emax)
Set logarithmically spaced energies.
Definition: GEnergies.cpp:542
void load(const GFilename &filename)
Load energies from FITS file.
Definition: GEnergies.cpp:615
void close(void)
Close FITS file.
Definition: GFits.cpp:1314
FITS table double column.
void init_members(void)
Initialise class members.
Definition: GEnergies.cpp:804
Filename class interface definition.
GVector log10(const GVector &vector)
Computes base10 logarithm of vector elements.
Definition: GVector.cpp:1205
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413
FITS table abstract base class interface definition.