GammaLib 2.0.0
Loading...
Searching...
No Matches
GModelSpatialDiffuseCube.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpatialDiffuseCube.hpp - Spatial map cube model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2021 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 GModelSpatialDiffuseCube.hpp
23 * @brief Spatial map cube model class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMODELSPATIALDIFFUSECUBE_HPP
28#define GMODELSPATIALDIFFUSECUBE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
33#include "GModelSpectral.hpp"
35#include "GModelPar.hpp"
36#include "GSkyDir.hpp"
37#include "GSkyMap.hpp"
38#include "GSkyRegionCircle.hpp"
39#include "GNodeArray.hpp"
40#include "GEbounds.hpp"
41#include "GFilename.hpp"
42
43/* __ Forward declarations _______________________________________________ */
44class GFits;
45class GEnergies;
46class GXmlElement;
47
48
49/***********************************************************************//**
50 * @class GModelSpatialDiffuseCube
51 *
52 * @brief Spatial map cube model
53 *
54 * This class implements the spatial component of the factorised source
55 * model for a map cube. A map cube is a set of sky maps for different
56 * energies. It is assumed that the pixels of the sky map are given in the
57 * units ph/cm2/s/sr/MeV.
58 ***************************************************************************/
60
61public:
62 // Constructors and destructors
64 GModelSpatialDiffuseCube(const bool& dummy, const std::string& type);
65 explicit GModelSpatialDiffuseCube(const GXmlElement& xml);
67 const double& value = 1.0);
69 const GEnergies& energies,
70 const double& value = 1.0);
72 virtual ~GModelSpatialDiffuseCube(void);
73
74 // Operators
76
77 // Implemented pure virtual methods
78 virtual void clear(void);
79 virtual GModelSpatialDiffuseCube* clone(void) const;
80 virtual std::string classname(void) const;
81 virtual double eval(const GPhoton& photon,
82 const bool& gradients = false) const;
83 virtual GSkyDir mc(const GEnergy& energy,
84 const GTime& time,
85 GRan& ran) const;
86 virtual double mc_norm(const GSkyDir& dir,
87 const double& radius) const;
88 virtual bool contains(const GSkyDir& dir,
89 const double& margin = 0.0) const;
90 virtual void read(const GXmlElement& xml);
91 virtual void write(GXmlElement& xml) const;
92 virtual std::string print(const GChatter& chatter = NORMAL) const;
93
94 // Overloaded base class methods
95 virtual double flux(const GSkyRegion& region,
96 const GEnergy& srcEng = GEnergy(),
97 const GTime& srcTime = GTime()) const;
98
99 // Other methods
100 double value(void) const;
101 void value(const double& value);
102 const GFilename& filename(void) const;
103 void filename(const GFilename& filename);
104 const GSkyMap& cube(void) const;
105 void cube(const GSkyMap& cube);
106 GEnergies energies(void);
107 void energies(const GEnergies& energies);
108 const GModelSpectralNodes& spectrum(void) const;
109 void mc_cone(const GSkyRegionCircle& cone) const;
110 const GSkyRegionCircle& mc_cone(void) const;
111 void load(const GFilename& filename);
112 void save(const GFilename& filename,
113 const bool& clobber = false) const;
114 void read(const GFits& fits);
115 void write(GFits& fits) const;
116
117protected:
118 // Protected methods
119 void init_members(void);
120 void copy_members(const GModelSpatialDiffuseCube& model);
121 void free_members(void);
122 void fetch_cube(void) const;
123 void load_cube(const GFilename& filename);
124 void set_energy_boundaries(void);
125 void update_mc_cache(void);
126 double cube_intensity(const GPhoton& photon) const;
127 virtual void set_region(void) const;
128
129 // Protected members
130 GModelPar m_value; //!< Value
131 GFilename m_filename; //!< Name of map cube
132 bool m_loaded; //!< Signals if map cube has been loaded
133 GSkyMap m_cube; //!< Map cube
134 GNodeArray m_logE; //!< Log10(energy) values of the maps
135 GEbounds m_ebounds; //!< Energy bounds of the maps
136
137 // Monte Carlo cache
138 mutable GSkyRegionCircle m_mc_cone; //!< MC cone
139 mutable double m_mc_one_minus_cosrad; //!< 1-cosine of radius
140 mutable std::vector<double> m_mc_max; //!< Maximum values for MC
141 mutable GModelSpectralNodes m_mc_spectrum; //!< Map cube spectrum
142};
143
144
145/***********************************************************************//**
146 * @brief Return class name
147 *
148 * @return String containing the class name ("GModelSpatialDiffuseCube").
149 ***************************************************************************/
150inline
152{
153 return ("GModelSpatialDiffuseCube");
154}
155
156
157/***********************************************************************//**
158 * @brief Get model value
159 *
160 * @return Model value.
161 *
162 * Returns the value of the spatial map cube model.
163 ***************************************************************************/
164inline
166{
167 return (m_value.value());
168}
169
170
171/***********************************************************************//**
172 * @brief Set model value
173 *
174 * @param[in] value Model value.
175 *
176 * Set the value of the spatial map cube model.
177 ***************************************************************************/
178inline
179void GModelSpatialDiffuseCube::value(const double& value)
180{
182 return;
183}
184
185
186/***********************************************************************//**
187 * @brief Get file name
188 *
189 * @return File name.
190 *
191 * Returns the file name of the spatial map cube model.
192 ***************************************************************************/
193inline
195{
196 return (m_filename);
197}
198
199
200/***********************************************************************//**
201 * @brief Set file name
202 *
203 * @param[in] filename File name.
204 *
205 * Set the file name of the spatial map cube model.
206 ***************************************************************************/
207inline
209{
211 return;
212}
213
214
215/***********************************************************************//**
216 * @brief Get map cube
217 *
218 * @return Map cube.
219 *
220 * Returns the map cube.
221 ***************************************************************************/
222inline
224{
225 fetch_cube();
226 return (m_cube);
227}
228
229
230/***********************************************************************//**
231 * @brief Get map cube spectrum
232 *
233 * @return Map cube spectrum.
234 *
235 * Returns the map cube spectrum.
236 ***************************************************************************/
237inline
239{
240 fetch_cube();
241 return (m_mc_spectrum);
242}
243
244
245/***********************************************************************//**
246 * @brief Return normalization of diffuse cube for Monte Carlo simulations
247 *
248 * @param[in] dir Centre of simulation cone.
249 * @param[in] radius Radius of simulation cone (degrees).
250 * @return Normalization.
251 *
252 * Returns the normalization of a diffuse cube. The normalization is given
253 * by the model value. The @p dir and @p radius parameters are not used.
254 ***************************************************************************/
255inline
257 const double& radius) const
258{
259 return (value());
260}
261
262
263/***********************************************************************//**
264 * @brief Get Monte Carlo simulation cone
265 *
266 * @return Monte Carlo simulation sky region circle.
267 *
268 * Returns the sky region circle used for Monte Carlo simulations.
269 ***************************************************************************/
270inline
272{
273 return (m_mc_cone);
274}
275
276#endif /* GMODELSPATIALDIFFUSECUBE_HPP */
Energy boundaries class interface definition.
Filename class interface definition.
Model parameter class interface definition.
Abstract diffuse spatial model base class interface definition.
Spectral nodes model class definition.
Abstract spectral model base class interface definition.
Node array class interface definition.
Sky direction class interface definition.
Sky map class definition.
Circular sky region class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Energy boundaries container class.
Definition GEbounds.hpp:60
Energy container class.
Definition GEnergies.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
FITS file class.
Definition GFits.hpp:63
Model parameter class.
Definition GModelPar.hpp:87
void set_energy_boundaries(void)
Set energy boundaries.
const GFilename & filename(void) const
Get file name.
void load_cube(const GFilename &filename)
Load map cube.
void update_mc_cache(void)
Update Monte Carlo cache.
double m_mc_one_minus_cosrad
1-cosine of radius
GModelSpatialDiffuseCube(void)
Void constructor.
const GSkyMap & cube(void) const
Get map cube.
void load(const GFilename &filename)
Load cube into the model class.
std::vector< double > m_mc_max
Maximum values for MC.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of diffuse cube for Monte Carlo simulations.
virtual std::string classname(void) const
Return class name.
const GSkyRegionCircle & mc_cone(void) const
Get Monte Carlo simulation cone.
double cube_intensity(const GPhoton &photon) const
Compute cube intensity by log-log interpolation.
const GModelSpectralNodes & spectrum(void) const
Get map cube spectrum.
bool m_loaded
Signals if map cube has been loaded.
void copy_members(const GModelSpatialDiffuseCube &model)
Copy class members.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print map cube information.
virtual double flux(const GSkyRegion &region, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns diffuse cube flux integrated in sky region.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelSpectralNodes m_mc_spectrum
Map cube spectrum.
virtual void read(const GXmlElement &xml)
Read model from XML element.
GFilename m_filename
Name of map cube.
double value(void) const
Get model value.
GNodeArray m_logE
Log10(energy) values of the maps.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate function.
void save(const GFilename &filename, const bool &clobber=false) const
Save cube into FITS file.
GEbounds m_ebounds
Energy bounds of the maps.
void fetch_cube(void) const
Fetch cube.
GEnergies energies(void)
Returns map cube energies.
virtual GModelSpatialDiffuseCube & operator=(const GModelSpatialDiffuseCube &model)
Assignment operator.
GSkyRegionCircle m_mc_cone
MC cone.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Signals whether model contains sky direction.
virtual void clear(void)
Clear map cube model.
virtual ~GModelSpatialDiffuseCube(void)
Destructor.
virtual GModelSpatialDiffuseCube * clone(void) const
Clone map cube model.
virtual void set_region(void) const
Set boundary sky region.
Abstract diffuse spatial model base class.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
Spectral nodes model class.
Node array class.
double value(void) const
Return parameter value.
Class that handles photons.
Definition GPhoton.hpp:47
Random number generator class.
Definition GRan.hpp:44
Sky direction class.
Definition GSkyDir.hpp:62
Sky map class.
Definition GSkyMap.hpp:89
Interface for the circular sky region class.
Abstract interface for the sky region class.
Time class.
Definition GTime.hpp:55
XML element node class.