ctools 2.1.0.dev
Loading...
Searching...
No Matches
ctbutterfly.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * ctbutterfly - butterfly calculation tool *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014-2022 by Michael Mayer *
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 ctbutterfly.hpp
23 * @brief Butterfly calculation tool interface definition
24 * @author Michael Mayer
25 */
26
27#ifndef CTBUTTERFLY_HPP
28#define CTBUTTERFLY_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include "GammaLib.hpp"
32#include "GCTALib.hpp"
33#include "ctlikelihood.hpp"
34
35/* __Definitions _________________________________________________________ */
36#define CTBUTTERFLY_NAME "ctbutterfly"
37
38
39/***********************************************************************//**
40 * @class ctbutterfly
41 *
42 * @brief Butterfly calculation tool
43 *
44 * This class computes the confidence interval of a fitted spectrum
45 * (butterfly) for a given set of observations.
46 *
47 * The class operates on predefined observation containers, an individual
48 * event list or an observation definition XML file.
49 *
50 * During the computation the covariance matrix of the fit is used to
51 * propagate uncertainties and their correlations through the entire energy
52 * range. The output is saved as an ascii files containing the confidence
53 * band boundaries
54 ***************************************************************************/
55class ctbutterfly : public ctlikelihood {
56
57public:
58 // Constructors and destructors
59 ctbutterfly(void);
60 explicit ctbutterfly(const GObservations& obs);
61 ctbutterfly(int argc, char *argv[]);
62 ctbutterfly(const ctbutterfly& app);
63 virtual ~ctbutterfly(void);
64
65 // Operators
67
68 // Methods
69 void clear(void);
70 void process(void);
71 void save(void);
72 const GFits& butterfly(void) const;
73
74protected:
75 // Protected methods
76 void init_members(void);
77 void copy_members(const ctbutterfly& app);
78 void free_members(void);
79 void get_parameters(void);
80 void gaussian_error_propagation(GModels& models);
81 void ellipsoid_boundary(GModels& models);
82 void check_model(void);
83 void eigenvectors(const double& a,
84 const double& b,
85 const double& c,
86 const double& d,
87 double* lambda1,
88 double* lambda2,
89 GVector* vector1,
90 GVector* vector2);
91 void create_fits(void);
92
93 // User parameters
94 std::string m_srcname; //!< Name of source to compute butterfly
95 std::string m_method; //!< Computation method
96 double m_confidence; //!< Confidence level
97 int m_max_iter; //!< Maximum number of iterations
98 bool m_apply_edisp; //!< Apply energy dispersion?
99 bool m_fit; //!< Do fit?
100 GEbounds m_ebounds; //!< Energy binning definition
101 GFilename m_outfile; //!< Output ASCII file name
102 GChatter m_chatter; //!< Chattiness
103
104 // Protected members
105 GMatrixSparse m_covariance; //!< Covariance matrix
106 std::vector<double> m_energies; //!< Energy values
107 std::vector<double> m_intensities; //!< Power law intensity
108 std::vector<double> m_min_intensities; //!< Minimum intensities
109 std::vector<double> m_max_intensities; //!< Maximum intensities
110 GFits m_fits; //!< FITS file holding butterfly
111};
112
113
114/***********************************************************************//**
115 * @brief Return butterfly FITS file
116 *
117 * @return Butterfly FITS file.
118 ***************************************************************************/
119inline
120const GFits& ctbutterfly::butterfly(void) const
121{
122 return (m_fits);
123}
124
125#endif /* CTBUTTERFLY_HPP */
Butterfly calculation tool.
void copy_members(const ctbutterfly &app)
Copy class members.
void get_parameters(void)
Get application parameters.
bool m_apply_edisp
Apply energy dispersion?
void save(void)
Save butterfly diagram.
ctbutterfly & operator=(const ctbutterfly &app)
Assignment operator.
GChatter m_chatter
Chattiness.
GMatrixSparse m_covariance
Covariance matrix.
void create_fits(void)
Set result FITS file.
std::vector< double > m_energies
Energy values.
const GFits & butterfly(void) const
Return butterfly FITS file.
void eigenvectors(const double &a, const double &b, const double &c, const double &d, double *lambda1, double *lambda2, GVector *vector1, GVector *vector2)
Compute normalized eigenvectors and eigenvalues.
std::vector< double > m_intensities
Power law intensity.
std::vector< double > m_max_intensities
Maximum intensities.
std::string m_method
Computation method.
void init_members(void)
Initialise class members.
bool m_fit
Do fit?
GFilename m_outfile
Output ASCII file name.
GFits m_fits
FITS file holding butterfly.
int m_max_iter
Maximum number of iterations.
void process(void)
Computes the butterfly.
void gaussian_error_propagation(GModels &models)
Compute butterfly using Gaussian error propagation.
void free_members(void)
Delete class members.
void clear(void)
Clear ctbutterfly tool.
void ellipsoid_boundary(GModels &models)
Compute butterfly using the ellipsoid boundary method.
ctbutterfly(void)
Void constructor.
virtual ~ctbutterfly(void)
Destructor.
double m_confidence
Confidence level.
void check_model(void)
Check if sky model is valid.
std::vector< double > m_min_intensities
Minimum intensities.
std::string m_srcname
Name of source to compute butterfly.
GEbounds m_ebounds
Energy binning definition.
Base class for likelihood tools.
const GObservations & obs(void) const
Return observation container.
Likelihood tool base class interface definition.