GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GModelTemporalLightCurve.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelTemporalLightCurve.hpp - Temporal light curve model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 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 GModelTemporalLightCurve.hpp
23 * @brief Light curve model class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMODELTEMPORALLIGHTCURVE_HPP
28#define GMODELTEMPORALLIGHTCURVE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <vector>
32#include <string>
33#include "GModelPar.hpp"
34#include "GModelTemporal.hpp"
35#include "GNodeArray.hpp"
36#include "GFilename.hpp"
37#include "GTimeReference.hpp"
38#include "GTime.hpp"
39
40/* __ Forward declarations _______________________________________________ */
41class GRan;
42class GXmlElement;
43
44
45/***********************************************************************//**
46 * @class GModelTemporalLightCurve
47 *
48 * @brief Light curve model class
49 *
50 * This class implements a light curve defined by nodes given specified in
51 * a FITS file. The model is defined by
52 *
53 * \f[
54 * S_{\rm t}(t) = r(t) \times {\tt m\_norm}
55 * \f]
56 *
57 * where
58 * \f$r(t)\f$ is the rate defined by linear interpolation between the nodes
59 * in a FITS file, and
60 * \f${\tt m\_norm}\f$ is a normalisation constant.
61 ***************************************************************************/
63
64public:
65 // Constructors and destructors
67 explicit GModelTemporalLightCurve(const GXmlElement& xml);
69 const double& norm = 1.0);
71 virtual ~GModelTemporalLightCurve(void);
72
73 // Operators
75
76 // Implemented virtual base class methods
77 virtual void clear(void);
78 virtual GModelTemporalLightCurve* clone(void) const;
79 virtual std::string classname(void) const;
80 virtual std::string type(void) const;
81 virtual double eval(const GTime& srcTime,
82 const bool& gradients = false) const;
83 virtual GTimes mc(const double& rate, const GTime& tmin,
84 const GTime& tmax, GRan& ran) const;
85 virtual void read(const GXmlElement& xml);
86 virtual void write(GXmlElement& xml) const;
87 virtual std::string print(const GChatter& chatter = NORMAL) const;
88
89 // Other methods
90 const GFilename& filename(void) const;
91 void filename(const GFilename& filename);
92 double norm(void) const;
93 void norm(const double& norm);
94
95protected:
96 // Protected methods
97 void init_members(void);
98 void copy_members(const GModelTemporalLightCurve& model);
99 void free_members(void);
100 void load_nodes(const GFilename& filename);
101 void mc_update(const GTime& tmin, const GTime& tmax) const;
102
103 // Protected members
104 GModelPar m_norm; //!< Normalization factor
105 mutable GNodeArray m_nodes; //!< Time nodes of function
106 std::vector<double> m_values; //!< Function values at nodes
107 GFilename m_filename; //!< Name of file function
108 GTimeReference m_timeref; //!< Time reference
109 GTime m_tmin; //!< Minimum time of model
110 GTime m_tmax; //!< Maximum time of model
111
112 // Cached members for MC
113 mutable GTime m_mc_tmin; //!< Minimum time
114 mutable GTime m_mc_tmax; //!< Maximum time
115 mutable double m_mc_norm; //!< Light curve normalisation
116 mutable double m_mc_eff_duration; //!< Effective duration
117 mutable std::vector<double> m_mc_cum; //!< Cumulative distribution
118 mutable std::vector<double> m_mc_slope; //!< Slope of interval
119 mutable std::vector<double> m_mc_offset; //!< Offset of interval
120 mutable std::vector<double> m_mc_time; //!< Start time of interval
121 mutable std::vector<double> m_mc_dt; //!< Length of interval
122};
123
124
125/***********************************************************************//**
126 * @brief Return class name
127 *
128 * @return String containing the class name ("GModelTemporalLightCurve").
129 ***************************************************************************/
130inline
132{
133 return ("GModelTemporalLightCurve");
134}
135
136
137/***********************************************************************//**
138 * @brief Return model type
139 *
140 * @return "LightCurve".
141 *
142 * Returns the type of the temporal model.
143 ***************************************************************************/
144inline
145std::string GModelTemporalLightCurve::type(void) const
146{
147 return "LightCurve";
148}
149
150
151/***********************************************************************//**
152 * @brief Return normalization factor
153 *
154 * @return Normalization factor.
155 *
156 * Returns the normalization factor.
157 ***************************************************************************/
158inline
160{
161 return (m_norm.value());
162}
163
164
165/***********************************************************************//**
166 * @brief Set normalization factor
167 *
168 * @param[in] norm Normalization factor.
169 *
170 * Sets the normalization factor.
171 ***************************************************************************/
172inline
174{
176 return;
177}
178
179
180/***********************************************************************//**
181 * @brief Return file name
182 *
183 * @return Name of node file.
184 *
185 * Returns the name of the file function node file.
186 ***************************************************************************/
187inline
189{
190 return (m_filename);
191}
192
193
194/***********************************************************************//**
195 * @brief Loads nodes from node file and set filename
196 *
197 * @param[in] filename Node file name.
198 *
199 * Loads the nodes from a file function node file and sets the filename.
200 ***************************************************************************/
201inline
203{
205 return;
206}
207
208#endif /* GMODELTEMPORALLIGHTCURVE_HPP */
Filename class interface definition.
Model parameter class interface definition.
Abstract temporal model base class interface definition.
Node array class interface definition.
Time reference class interface definition.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
double norm(const GVector &vector)
Computes vector norm.
Definition GVector.cpp:932
Filename class.
Definition GFilename.hpp:62
Model parameter class.
Definition GModelPar.hpp:87
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual GModelTemporalLightCurve & operator=(const GModelTemporalLightCurve &model)
Assignment operator.
virtual std::string type(void) const
Return model type.
std::vector< double > m_mc_time
Start time of interval.
void copy_members(const GModelTemporalLightCurve &model)
Copy class members.
std::vector< double > m_mc_dt
Length of interval.
std::vector< double > m_mc_cum
Cumulative distribution.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual std::string classname(void) const
Return class name.
virtual GModelTemporalLightCurve * clone(void) const
Clone light curve model.
virtual ~GModelTemporalLightCurve(void)
Destructor.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const
Evaluate function.
virtual void clear(void)
Clear light curve model.
GFilename m_filename
Name of file function.
std::vector< double > m_mc_slope
Slope of interval.
GTime m_tmin
Minimum time of model.
GModelPar m_norm
Normalization factor.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
std::vector< double > m_values
Function values at nodes.
const GFilename & filename(void) const
Return file name.
double m_mc_norm
Light curve normalisation.
GTime m_tmax
Maximum time of model.
double norm(void) const
Return normalization factor.
GNodeArray m_nodes
Time nodes of function.
void load_nodes(const GFilename &filename)
Load nodes from file.
virtual GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const
Returns vector of random event times.
void mc_update(const GTime &tmin, const GTime &tmax) const
Set MC pre-computation cache.
std::vector< double > m_mc_offset
Offset of interval.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print light curve information.
GTimeReference m_timeref
Time reference.
double m_mc_eff_duration
Effective duration.
GModelTemporalLightCurve(void)
Void constructor.
Abstract temporal model base class.
Node array class.
double value(void) const
Return parameter value.
Random number generator class.
Definition GRan.hpp:44
Implements a time reference.
Time class.
Definition GTime.hpp:55
Time container class.
Definition GTimes.hpp:45
XML element node class.