GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialGauss.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialGauss.cpp - Radial Gaussian source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-2022 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 GModelSpatialRadialGauss.cpp
23  * @brief Radial Gaussian model class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GException.hpp"
32 #include "GTools.hpp"
33 #include "GMath.hpp"
36 
37 /* __ Constants __________________________________________________________ */
38 
39 /* __ Globals ____________________________________________________________ */
41 const GModelSpatialRegistry g_radial_gauss_registry(&g_radial_gauss_seed);
42 #if defined(G_LEGACY_XML_FORMAT)
43 const GModelSpatialRadialGauss g_radial_gauss_legacy_seed(true, "GaussFunction");
44 const GModelSpatialRegistry g_radial_gauss_legacy_registry(&g_radial_gauss_legacy_seed);
45 #endif
46 
47 /* __ Method name definitions ____________________________________________ */
48 #define G_CONSTRUCTOR "GModelSpatialRadialGauss::GModelSpatialRadialGauss("\
49  "GSkyDir&, double&, std::string&)"
50 #define G_EVAL "GModelSpatialRadialGauss::eval(double&, GEnergy&, GTime&, "\
51  "bool&)"
52 #define G_READ "GModelSpatialRadialGauss::read(GXmlElement&)"
53 #define G_WRITE "GModelSpatialRadialGauss::write(GXmlElement&)"
54 
55 /* __ Macros _____________________________________________________________ */
56 
57 /* __ Coding definitions _________________________________________________ */
58 
59 /* __ Debug definitions __________________________________________________ */
60 
61 
62 /*==========================================================================
63  = =
64  = Constructors/destructors =
65  = =
66  ==========================================================================*/
67 
68 /***********************************************************************//**
69  * @brief Void constructor
70  *
71  * Constructs empty radial Gaussian model.
72  ***************************************************************************/
74 {
75  // Initialise members
76  init_members();
77 
78  // Return
79  return;
80 }
81 
82 
83 /***********************************************************************//**
84  * @brief Model type constructor
85  *
86  * @param[in] dummy Dummy flag.
87  * @param[in] type Model type.
88  *
89  * Constructs empty radial Gaussian model by specifying a model @p type.
90  ***************************************************************************/
92  const std::string& type) :
94 {
95  // Initialise members
96  init_members();
97 
98  // Set model type
99  m_type = type;
100 
101  // Return
102  return;
103 }
104 
105 
106 /***********************************************************************//**
107  * @brief Constructor
108  *
109  * @param[in] dir Sky position of Gaussian.
110  * @param[in] sigma Width of Gaussian (in degrees).
111  * @param[in] coordsys Coordinate system (either "CEL" or "GAL")
112  *
113  * @exception GException::invalid_argument
114  * Invalid @p coordsys argument specified.
115  *
116  * Constructs a Gaussian spatial model using a sky direction (@p dir) and
117  * a Gaussian width parameter @p sigma in degrees. The @p coordsys parameter
118  * specifies whether the sky direction should be interpreted in the
119  * celestial or Galactic coordinate system.
120  ***************************************************************************/
122  const double& sigma,
123  const std::string& coordsys) :
125 {
126  // Throw an exception if the coordinate system is invalid
127  if ((coordsys != "CEL") && (coordsys != "GAL")) {
128  std::string msg = "Invalid coordinate system \""+coordsys+"\" "
129  "specified. Please specify either \"CEL\" or "
130  "\"GAL\".";
132  }
133 
134  // Initialise members
135  init_members();
136 
137  // Set parameter names
138  if (coordsys == "CEL") {
139  m_lon.name("RA");
140  m_lat.name("DEC");
141  }
142  else {
143  m_lon.name("GLON");
144  m_lat.name("GLAT");
145  }
146 
147  // Assign direction and sigma
148  this->dir(dir);
149  this->sigma(sigma);
150 
151  // Return
152  return;
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief XML constructor
158  *
159  * @param[in] xml XML element.
160  *
161  * Constructs a Gaussian spatial model by extracting information from an XML
162  * element. See the method read() for more information about the expected
163  * structure of the XML element.
164  ***************************************************************************/
167 {
168  // Initialise members
169  init_members();
170 
171  // Read information from XML element
172  read(xml);
173 
174  // Return
175  return;
176 }
177 
178 
179 /***********************************************************************//**
180  * @brief Copy constructor
181  *
182  * @param[in] model Radial Gaussian model.
183  ***************************************************************************/
185  GModelSpatialRadial(model)
186 {
187  // Initialise members
188  init_members();
189 
190  // Copy members
191  copy_members(model);
192 
193  // Return
194  return;
195 }
196 
197 
198 /***********************************************************************//**
199  * @brief Destructor
200  ***************************************************************************/
202 {
203  // Free members
204  free_members();
205 
206  // Return
207  return;
208 }
209 
210 
211 /*==========================================================================
212  = =
213  = Operators =
214  = =
215  ==========================================================================*/
216 
217 /***********************************************************************//**
218  * @brief Assignment operator
219  *
220  * @param[in] model Radial Gaussian model.
221  * @return Radial Gaussian model.
222  ***************************************************************************/
224 {
225  // Execute only if object is not identical
226  if (this != &model) {
227 
228  // Copy base class members
229  this->GModelSpatialRadial::operator=(model);
230 
231  // Free members
232  free_members();
233 
234  // Initialise members
235  init_members();
236 
237  // Copy members
238  copy_members(model);
239 
240  } // endif: object was not identical
241 
242  // Return
243  return *this;
244 }
245 
246 
247 /*==========================================================================
248  = =
249  = Public methods =
250  = =
251  ==========================================================================*/
252 
253 /***********************************************************************//**
254  * @brief Clear radial Gauss model
255  ***************************************************************************/
257 {
258  // Free class members (base and derived classes, derived class first)
259  free_members();
262 
263  // Initialise members
266  init_members();
267 
268  // Return
269  return;
270 }
271 
272 
273 /***********************************************************************//**
274  * @brief Clone radial Gauss model
275  ***************************************************************************/
277 {
278  // Clone radial Gauss model
279  return new GModelSpatialRadialGauss(*this);
280 }
281 
282 
283 /***********************************************************************//**
284  * @brief Evaluate Gaussian source model
285  *
286  * @param[in] theta Angular distance from Gaussian centre (radians).
287  * @param[in] energy Photon energy (not used).
288  * @param[in] time Photon arrival time (not used).
289  * @param[in] gradients Compute gradients?
290  * @return Model value (\f${\rm sr}^{-1}\f$).
291  *
292  * Evaluates the spatial component for a Gaussian source model using
293  *
294  * \f[
295  * M_{\rm S}({\bf p} | E, t) = M_{\rm S}(\theta) =
296  * \frac{1}{2 \pi \sigma^2} \exp
297  * \left(-\frac{1}{2}\frac{\theta^2}{\sigma^2} \right)
298  * \f]
299  *
300  * where
301  * - \f$\theta\f$ is the angular separation from the centre of the model, and
302  * - \f$\sigma\f$ is the Gaussian width.
303  *
304  * If @p gradients is `true` the method will also compute analytical parameter
305  * gradients
306  *
307  * \f[
308  * \frac{\partial M_{\rm S}}{\partial \alpha_0} =
309  * \frac{\partial M_{\rm S}}{\partial \theta}
310  * \frac{\partial \theta}{\partial \alpha_0}
311  * \f]
312  *
313  * \f[
314  * \frac{\partial M_{\rm S}}{\partial \beta_0} =
315  * \frac{\partial M_{\rm S}}{\partial \theta}
316  * \frac{\partial \theta}{\partial \beta_0}
317  * \f]
318  *
319  * with
320  *
321  * \f[
322  * \frac{\partial M_{\rm S}}{\partial \theta} =
323  * -\frac{\theta}{\sigma^2} M_{\rm S}(\theta)
324  * \f]
325  *
326  * and
327  *
328  * \f[
329  * \frac{\partial M_{\rm S}}{\partial \sigma} =
330  * \left( \frac{\theta^2}{\sigma^3} - \frac{2}{\sigma} \right)
331  * M_{\rm S}(\theta)
332  * \f]
333  *
334  * where
335  * - \f$\alpha_0\f$ is the Right Ascension of the model centre, and
336  * - \f$\beta_0\f$ is the Declination of the model centre.
337  *
338  * The computation of the analytical gradients with respect to the model
339  * centre relies on the computation of the partial derivatives
340  * \f$\frac{\partial \theta}{\partial \alpha_0}\f$ and
341  * \f$\frac{\partial \theta}{\partial \beta_0}\f$ which are assumed to
342  * be stored in `m_lon.factor_gradient()` and `m_lat.factor_gradient()`
343  * when the method is entered. No check is performed whether these values
344  * are actually available and valid.
345  *
346  * Note that the model normalisation is only correct in the small angle
347  * approximation.
348  ***************************************************************************/
349 double GModelSpatialRadialGauss::eval(const double& theta,
350  const GEnergy& energy,
351  const GTime& time,
352  const bool& gradients) const
353 {
354  // Update
355  update(gradients);
356 
357  // Compute value
358  double theta2 = theta * theta;
359  double arg2 = m_inv_sigma2_rad * theta2;
360  double value = m_value_norm * std::exp(-0.5 * arg2);
361 
362  // Optionally compute gradients
363  if (gradients) {
364 
365  // Evaluate position gradients. Note that this requires that the
366  // partial derivatives of theta with respect to longitude and
367  // latitude are preset in the m_lon.factor_gradient() and
368  // m_lat.factor_gradient() members. An example where these values
369  // are set is the cta_psf_radial_kerns_phi::eval() method.
370  double g_lon = 0.0;
371  double g_lat = 0.0;
372  if (m_lon.is_free() || m_lat.is_free()) {
373  double g_theta = -theta * m_g_theta_norm * value;
374  if (m_lon.is_free()) {
375  g_lon = g_theta * m_lon.factor_gradient() * m_lon.scale();
376  }
377  if (m_lat.is_free()) {
378  g_lat = g_theta * m_lat.factor_gradient() * m_lat.scale();
379  }
380  }
381  m_lon.factor_gradient(g_lon);
382  m_lat.factor_gradient(g_lat);
383 
384  // Evaluate sigma gradient
385  double g_sigma = 0.0;
386  if (m_sigma.is_free()) {
387  g_sigma = (arg2 - 2.0) * value * m_g_sigma_norm;
388  }
389  m_sigma.factor_gradient(g_sigma);
390 
391  } // endif: gradient computation was requested
392 
393  // Compile option: Check for NaN/Inf
394  #if defined(G_NAN_CHECK)
395  if (gammalib::is_notanumber(value) || gammalib::is_infinite(value)) {
396  std::string msg = "Model value not a number:";
397  for (int i = 0; i < m_pars.size(); ++i) {
398  msg += " " + m_pars[i]->name() + "=";
399  msg += gammalib::str(m_pars[i]->value());
400  }
401  msg += " energy=" + energy.print();
402  msg += " time=" + time.print();
404  }
405  #endif
406 
407  // Return value
408  return value;
409 }
410 
411 
412 /***********************************************************************//**
413  * @brief Returns MC sky direction
414  *
415  * @param[in] energy Photon energy.
416  * @param[in] time Photon arrival time.
417  * @param[in,out] ran Random number generator.
418  * @return Sky direction.
419  *
420  * Draws an arbitrary sky direction from the 2D Gaussian distribution as
421  * function of the photon @p energy and arrival @p time.
422  *
423  * @todo This method is only valid in the small angle approximation.
424  ***************************************************************************/
426  const GTime& time,
427  GRan& ran) const
428 {
429  // Simulate offset from photon arrival direction
430  double theta = sigma() * ran.chisq2();
431  double phi = 360.0 * ran.uniform();
432 
433  // Rotate sky direction by offset
434  GSkyDir sky_dir = dir();
435  sky_dir.rotate_deg(phi, theta);
436 
437  // Return sky direction
438  return sky_dir;
439 }
440 
441 
442 /***********************************************************************//**
443  * @brief Checks where model contains specified sky direction
444  *
445  * @param[in] dir Sky direction.
446  * @param[in] margin Margin to be added to sky direction (degrees)
447  * @return True if the model contains the sky direction.
448  *
449  * Signals whether a sky direction is contained in the radial gauss model.
450  ***************************************************************************/
452  const double& margin) const
453 {
454  // Compute distance to centre (radians)
455  double distance = dir.dist(this->dir());
456 
457  // Return flag
458  return (distance <= theta_max() + margin*gammalib::deg2rad);
459 }
460 
461 
462 /***********************************************************************//**
463  * @brief Return maximum model radius (in radians)
464  *
465  * Returns \f$5 \sigma\f$ as approximate edge of the Gaussian. This limit
466  * is of course arbitrary, but allows to limit the integration region for
467  * response computation.
468  ***************************************************************************/
470 {
471  // Return value
472  return (sigma() * gammalib::deg2rad * 5.0);
473 }
474 
475 
476 /***********************************************************************//**
477  * @brief Read model from XML element
478  *
479  * @param[in] xml XML element.
480  *
481  * Reads the radial Gauss model information from an XML element. The XML
482  * element shall have either the format
483  *
484  * <spatialModel type="RadialGaussian">
485  * <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
486  * <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
487  * <parameter name="Sigma" scale="1.0" value="0.45" min="0.01" max="10" free="1"/>
488  * </spatialModel>
489  *
490  * or
491  *
492  * <spatialModel type="RadialGaussian">
493  * <parameter name="GLON" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
494  * <parameter name="GLAT" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
495  * <parameter name="Sigma" scale="1.0" value="0.45" min="0.01" max="10" free="1"/>
496  * </spatialModel>
497  *
498  * @todo Implement a test of the sigma and sigma boundary. The sigma
499  * and sigma minimum should be >0.
500  ***************************************************************************/
502 {
503  // Verify number of model parameters
505 
506  // Read Gaussian location
508 
509  // Get parameters
511 
512  // Read parameters
513  m_sigma.read(*sigma);
514 
515  // Return
516  return;
517 }
518 
519 
520 /***********************************************************************//**
521  * @brief Write model into XML element
522  *
523  * @param[in] xml XML element into which model information is written.
524  *
525  * Writes the radial disk model information into an XML element. The XML
526  * element will have the format
527  *
528  * <spatialModel type="RadialGaussian">
529  * <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
530  * <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
531  * <parameter name="Sigma" scale="1.0" value="0.45" min="0.01" max="10" free="1"/>
532  * </spatialModel>
533  *
534  ***************************************************************************/
536 {
537  // Write Gaussian location
539 
540  // Get or create parameters
542 
543  // Write parameters
544  m_sigma.write(*sigma);
545 
546  // Return
547  return;
548 }
549 
550 
551 /***********************************************************************//**
552  * @brief Print Gaussian source information
553  *
554  * @param[in] chatter Chattiness.
555  * @return String containing model information.
556  ***************************************************************************/
557 std::string GModelSpatialRadialGauss::print(const GChatter& chatter) const
558 {
559  // Initialise result string
560  std::string result;
561 
562  // Continue only if chatter is not silent
563  if (chatter != SILENT) {
564 
565  // Append header
566  result.append("=== GModelSpatialRadialGauss ===");
567 
568  // Append parameters
569  result.append("\n"+gammalib::parformat("Number of parameters"));
570  result.append(gammalib::str(size()));
571  for (int i = 0; i < size(); ++i) {
572  result.append("\n"+m_pars[i]->print(chatter));
573  }
574 
575  } // endif: chatter was not silent
576 
577  // Return result
578  return result;
579 }
580 
581 
582 /*==========================================================================
583  = =
584  = Private methods =
585  = =
586  ==========================================================================*/
587 
588 /***********************************************************************//**
589  * @brief Initialise class members
590  *
591  * Note that the minimum Gaussian width is set to 1 arcsec.
592  ***************************************************************************/
594 {
595  // Initialise model type
596  m_type = "RadialGaussian";
597 
598  // Initialise Gaussian sigma
599  m_sigma.clear();
600  m_sigma.name("Sigma");
601  m_sigma.unit("deg");
602  m_sigma.value(2.778e-4); // 1 arcsec
603  m_sigma.min(2.778e-4); // 1 arcsec
604  m_sigma.free();
605  m_sigma.scale(1.0);
606  m_sigma.gradient(0.0);
607 
608  // Signal that this model provides analytical parameter gradients
609  m_lon.has_grad(true);
610  m_lat.has_grad(true);
611  m_sigma.has_grad(true);
612 
613  // Set parameter pointer(s)
614  m_pars.push_back(&m_sigma);
615 
616  // Initialise pre-computation cache
617  m_last_sigma = 0.0;
618  m_inv_sigma2_rad = 0.0;
619  m_value_norm = 0.0;
620  m_g_theta_norm = 0.0;
621  m_g_sigma_norm = 0.0;
622 
623  // Return
624  return;
625 }
626 
627 
628 /***********************************************************************//**
629  * @brief Copy class members
630  *
631  * @param[in] model Gaussian spatial model.
632  *
633  * We do not have to push back the members on the parameter stack as this
634  * should have been done by init_members() that was called before. Otherwise
635  * we would have sigma twice on the stack.
636  ***************************************************************************/
638 {
639  // Copy members
640  m_type = model.m_type; // Needed to conserve model type
641  m_sigma = model.m_sigma;
642 
643  // Copy pre-computation cache
644  m_last_sigma = model.m_last_sigma;
646  m_value_norm = model.m_value_norm;
649 
650  // Return
651  return;
652 }
653 
654 
655 /***********************************************************************//**
656  * @brief Delete class members
657  ***************************************************************************/
659 {
660  // Return
661  return;
662 }
663 
664 
665 /***********************************************************************//**
666  * @brief Update precomputation cache
667  *
668  * @param[in] gradients Gradient computation requested?
669  ***************************************************************************/
670 void GModelSpatialRadialGauss::update(const bool& gradients) const
671 {
672  // Update if radius has changed
673  if (m_last_sigma != sigma()) {
674 
675  // Store last values
676  m_last_sigma = sigma();
677 
678  // Compute Gaussian sigma in radians
679  double sigma_rad = sigma() * gammalib::deg2rad;
680  double sigma2_rad = sigma_rad * sigma_rad;
681  if (sigma2_rad > 0.0) {
682  m_inv_sigma2_rad = 1.0 / sigma2_rad;
683  m_value_norm = 1.0 / (gammalib::twopi * sigma2_rad);
684  }
685  else {
686  m_inv_sigma2_rad = 0.0;
687  m_value_norm = 0.0;
688  }
689 
690  // Pre-compute gradient stuff
691  if (gradients) {
693  m_g_sigma_norm = m_sigma.scale() * gammalib::deg2rad / sigma_rad;
694  }
695 
696  } // endif: update required
697 
698  // Return
699  return;
700 }
701 
702 
703 /***********************************************************************//**
704  * @brief Set boundary sky region
705  ***************************************************************************/
707 {
708  // Set sky region circle (5 times Gaussian sigma)
710 
711  // Set region (circumvent const correctness)
712  const_cast<GModelSpatialRadialGauss*>(this)->m_region = region;
713 
714  // Return
715  return;
716 }
double chisq2(void)
Returns Chi2 deviates for 2 degrees of freedom.
Definition: GRan.cpp:370
const double & factor_gradient(void) const
Return parameter factor gradient.
double sigma(void) const
Return Gaussian sigma.
const std::string & name(void) const
Return parameter name.
void warning(const std::string &origin, const std::string &message)
Emits warning.
Definition: GTools.cpp:1386
virtual double theta_max(void) const
Return maximum model radius (in radians)
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
Definition: GModelPar.cpp:351
XML element node class.
Definition: GXmlElement.hpp:48
Random number generator class.
Definition: GRan.hpp:44
#define G_WRITE
Time class.
Definition: GTime.hpp:55
Gammalib tools definition.
Interface for the circular sky region class.
Interface definition for the spatial model registry class.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double min(void) const
Return parameter minimum boundary.
bool is_free(void) const
Signal if parameter is free.
void init_members(void)
Initialise class members.
GModelPar m_sigma
Gaussian width (deg)
GSkyRegionCircle m_region
Bounding circle.
void copy_members(const GModelSpatialRadialGauss &model)
Copy class members.
virtual GModelSpatialRadialGauss * clone(void) const
Clone radial Gauss model.
bool is_notanumber(const double &x)
Signal if argument is not a number.
Definition: GTools.hpp:201
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
Definition: GTools.hpp:184
const double deg2rad
Definition: GMath.hpp:43
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
const GSkyDir & dir(void) const
Return position of radial spatial model.
GModelSpatialRadialGauss(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Definition: GEnergy.cpp:748
void free_members(void)
Delete class members.
void free(void)
Free a parameter.
#define G_EVAL
std::vector< GModelPar * > m_pars
Parameter pointers.
double m_g_theta_norm
sigma(rad)^-2 deg2rad
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
Definition: GSkyDir.cpp:424
double m_value_norm
(2pi sigma(rad))^-2
double m_g_sigma_norm
sigma(rad)^-1 sigma_scale deg2rad
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Definition: GTools.cpp:1637
virtual void read(const GXmlElement &xml)
Read model from XML element.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
Definition: GRan.cpp:242
void clear(void)
Clear parameter.
Spatial model registry class definition.
virtual void read(const GXmlElement &xml)
Read model from XML element.
GChatter
Definition: GTypemaps.hpp:33
virtual void set_region(void) const
Set boundary sky region.
std::string print(const GChatter &chatter=NORMAL) const
Print time.
Definition: GTime.cpp:1188
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate Gaussian source model.
std::string type(void) const
Return model type.
#define G_CONSTRUCTOR
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
Definition: GTools.cpp:1777
virtual void write(GXmlElement &xml) const
Write model into XML element.
const GSkyRegion * region(void) const
Return boundary sky region.
#define G_READ
virtual GModelSpatialRadial & operator=(const GModelSpatialRadial &model)
Assignment operator.
void free_members(void)
Delete class members.
std::string m_type
Spatial model type.
GModelPar m_lat
Declination or Galactic latitude (deg)
void init_members(void)
Initialise class members.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
Definition: GModelPar.cpp:229
double value(void) const
Return parameter value.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
const std::string & unit(void) const
Return parameter unit.
double m_last_sigma
Last Gaussian sigma.
Exception handler interface definition.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Definition: GSkyDir.hpp:271
GVector exp(const GVector &vector)
Computes exponential of vector elements.
Definition: GVector.cpp:1232
virtual GModelSpatialRadialGauss & operator=(const GModelSpatialRadialGauss &model)
Assignment operator.
Abstract radial spatial model base class.
void init_members(void)
Initialise class members.
const double twopi
Definition: GMath.hpp:36
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1143
void free_members(void)
Delete class members.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
Radial Gaussian model class.
void update(const bool &gradients) const
Update precomputation cache.
Sky direction class.
Definition: GSkyDir.hpp:62
virtual void clear(void)
Clear radial Gauss model.
Radial Gaussian model class interface definition.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Definition: GTools.cpp:1689
const GModelSpatialRadialGauss g_radial_gauss_seed
Mathematical function definitions.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Gaussian source information.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual ~GModelSpatialRadialGauss(void)
Destructor.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:489