GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GModelSpatialEllipticalGauss.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpatialEllipticalGauss.cpp - Elliptical gauss source model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2015-2024 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 GModelSpatialEllipticalGauss.cpp
23 * @brief Elliptical gauss model class implementation
24 * @author Michael Mayer
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"
37
38/* __ Constants __________________________________________________________ */
39namespace {
40 const double c_theta_max = 5.0; //!< semiaxis multiplied for theta_max()
41 const double c_max_exponent = 0.5 * c_theta_max * c_theta_max;
42 const double c_fraction = 1.0 - std::exp(-c_max_exponent);
43}
44
45/* __ Globals ____________________________________________________________ */
47const GModelSpatialRegistry g_elliptical_gauss_registry(&g_elliptical_gauss_seed);
48#if defined(G_LEGACY_XML_FORMAT)
49const GModelSpatialEllipticalGauss g_elliptical_gauss_legacy_seed(true, "EllipticalGauss");
50const GModelSpatialRegistry g_elliptical_gauss_legacy_registry(&g_elliptical_gauss_legacy_seed);
51#endif
52
53/* __ Method name definitions ____________________________________________ */
54#define G_CONSTRUCTOR "GModelSpatialEllipticalGauss::"\
55 "GModelSpatialEllipticalGauss(GSkyDir&, double&, double&, "\
56 "double&, std::string&)"
57#define G_READ "GModelSpatialEllipticalGauss::read(GXmlElement&)"
58#define G_WRITE "GModelSpatialEllipticalGauss::write(GXmlElement&)"
59
60/* __ Macros _____________________________________________________________ */
61
62/* __ Coding definitions _________________________________________________ */
63
64/* __ Debug definitions __________________________________________________ */
65
66
67/*==========================================================================
68 = =
69 = Constructors/destructors =
70 = =
71 ==========================================================================*/
72
73/***********************************************************************//**
74 * @brief Void constructor
75 ***************************************************************************/
78{
79 // Initialise members
81
82 // Return
83 return;
84}
85
86
87/***********************************************************************//**
88 * @brief Model type constructor
89 *
90 * @param[in] dummy Dummy flag.
91 * @param[in] type Model type.
92 *
93 * Constructs empty elliptical Gaussian model by specifying a model @p type.
94 ***************************************************************************/
96 const std::string& type) :
98{
99 // Initialise members
100 init_members();
101
102 // Set model type
103 m_type = type;
104
105 // Return
106 return;
107}
108
109
110/***********************************************************************//**
111 * @brief Elliptical Gaussian constructor
112 *
113 * @param[in] dir Centre of elliptical Gaussian.
114 * @param[in] semimajor Semi-major axis (degrees).
115 * @param[in] semiminor Semi-minor axis (degrees).
116 * @param[in] posangle Position angle of semi-major axis (degrees).
117 * @param[in] coordsys Coordinate system (either "CEL" or "GAL")
118 *
119 * @exception GException::invalid_argument
120 * Invalid @p coordsys argument specified.
121 *
122 * Construct an elliptical Gaussian model from the ellipse centre direction
123 * (@p dir), the @p semimajor and @p semiminor axes, and the position
124 * angle (@p posangle). The @p coordsys parameter specifies whether the sky
125 * direction and the position angle should be interpreted in the celestial
126 * or Galactic coordinates.
127 ***************************************************************************/
129 const double& semimajor,
130 const double& semiminor,
131 const double& posangle,
132 const std::string& coordsys) :
134{
135 // Throw an exception if the coordinate system is invalid
136 if ((coordsys != "CEL") && (coordsys != "GAL")) {
137 std::string msg = "Invalid coordinate system \""+coordsys+"\" "
138 "specified. Please specify either \"CEL\" or "
139 "\"GAL\".";
141 }
142
143 // Initialise members
144 init_members();
145
146 // Set parameter names
147 if (coordsys == "CEL") {
148 m_lon.name("RA");
149 m_lat.name("DEC");
150 }
151 else {
152 m_lon.name("GLON");
153 m_lat.name("GLAT");
154 }
155
156 // Assign parameters
157 this->dir(dir);
158 this->semiminor(semiminor);
159 this->semimajor(semimajor);
160 this->posangle(posangle);
161
162 // Return
163 return;
164}
165
166
167/***********************************************************************//**
168 * @brief XML constructor
169 *
170 * @param[in] xml XML element.
171 *
172 * Constructs elliptical Gaussian model by extracting information from an XML
173 * element. See the read() method for more information about the expected
174 * structure of the XML element.
175 ***************************************************************************/
178{
179 // Initialise members
180 init_members();
181
182 // Read information from XML element
183 read(xml);
184
185 // Return
186 return;
187}
188
189
190/***********************************************************************//**
191 * @brief Copy constructor
192 *
193 * @param[in] model Elliptical Gaussian model.
194 ***************************************************************************/
197{
198 // Initialise members
199 init_members();
200
201 // Copy members
202 copy_members(model);
203
204 // Return
205 return;
206}
207
208
209/***********************************************************************//**
210 * @brief Destructor
211 ***************************************************************************/
213{
214 // Free members
215 free_members();
216
217 // Return
218 return;
219}
220
221
222/*==========================================================================
223 = =
224 = Operators =
225 = =
226 ==========================================================================*/
227
228/***********************************************************************//**
229 * @brief Assignment operator
230 *
231 * @param[in] model Elliptical gauss model.
232 * @return Elliptical Gaussian model.
233 ***************************************************************************/
235{
236 // Execute only if object is not identical
237 if (this != &model) {
238
239 // Copy base class members
241
242 // Free members
243 free_members();
244
245 // Initialise members
246 init_members();
247
248 // Copy members
249 copy_members(model);
250
251 } // endif: object was not identical
252
253 // Return
254 return *this;
255}
256
257
258/*==========================================================================
259 = =
260 = Public methods =
261 = =
262 ==========================================================================*/
263
264/***********************************************************************//**
265 * @brief Clear elliptical Gaussian model
266 ***************************************************************************/
268{
269 // Free class members (base and derived classes, derived class first)
270 free_members();
273
274 // Initialise members
277 init_members();
278
279 // Return
280 return;
281}
282
283
284/***********************************************************************//**
285 * @brief Clone elliptical Gaussian model
286 *
287 * @return Pointer to deep copy of elliptical Gaussian model.
288 ***************************************************************************/
290{
291 // Clone elliptical Gaussian model
292 return new GModelSpatialEllipticalGauss(*this);
293}
294
295
296/***********************************************************************//**
297 * @brief Evaluate function (in units of sr\f$^{-1}\f$)
298 *
299 * @param[in] theta Angular distance from disk centre (radians)
300 * @param[in] posangle Position angle (counterclockwise from North) (radians)
301 * @param[in] energy Photon energy (not used)
302 * @param[in] time Photon arrival time (not used)
303 * @param[in] gradients Compute gradients? (not used)
304 * @return Model value (sr\f$^{-1}\f$)
305 *
306 * Evaluates the spatial component for an elliptical Gaussian source model.
307 *
308 * The elliptical Gaussian function is energy and time independent, and
309 * defined by
310 *
311 * \f[
312 * S_{\rm p}(\theta, \phi | E, t) = S_{\rm p}(\theta, \phi)
313 * \f]
314 *
315 * where \f$\theta\f$ is the angular separation from the centre of the
316 * elliptical Gaussian and \f$\phi\f$ the position angle with respect to
317 * the model centre, counted counterclockwise from North. The coordinate
318 * system in which the position angle \f$\phi\f$ is given is defined by the
319 * coordinate system in which the centre of elliptical Gaussian model is
320 * specified. The coordsys() method may be used to retrieve a string of the
321 * coordinate system.
322 *
323 * The function \f$S_{\rm p}(\theta, \phi)\f$ is given by
324 *
325 * \f[
326 * S_{\rm p}(\theta, \phi) = {\tt m\_norm} \times
327 * \exp \left( -\frac{\theta^2}{2} \left[
328 * \left( \frac{\sin^2 \phi_0}{b^2} + \frac{\cos^2 \phi_0}{a^2} \right) \cos^2 \phi +
329 * \left( \frac{\sin^2 \phi_0}{a^2} + \frac{\cos^2 \phi_0}{b^2} \right) \sin^2 \phi +
330 * \left( \frac{\sin 2\phi_0}{a^2} - \frac{\sin 2\phi_0}{b^2} \right) \sin \phi \cos \phi
331 * \right] \right)
332 * \f]
333 *
334 * where
335 * \f$a\f$ is the semi-major axis of the ellipse,
336 * \f$b\f$ is the semi-minor axis, and
337 * \f$\phi_0\f$ is the position angle of the ellipse, counted counterclockwise
338 * from North.
339 *
340 * \f${\tt m\_norm}\f$ is a normalization constant that is approximated by
341 *
342 * \f[
343 * {\tt m\_norm} = \frac{1}{2 \pi \times a \times b}
344 * \f]
345 *
346 * which is only accurate for values of \f$a\f$ and \f$b\f$ that do not
347 * exceed a few degrees. For larger ellipse sizes it is recommended to
348 * spatially integrate \f$S_{\rm p}(\theta, \phi)\f$ in order to obtain a
349 * proper normalisation.
350 *
351 * The method will not compute analytical parameter gradients, even if the
352 * @p gradients argument is set to true. Elliptical Gaussian parameter
353 * gradients need to be computed numerically.
354 ***************************************************************************/
355double GModelSpatialEllipticalGauss::eval(const double& theta,
356 const double& posangle,
357 const GEnergy& energy,
358 const GTime& time,
359 const bool& gradients) const
360{
361 // Initialise value
362 double value = 0.0;
363
364 // Continue only if we're inside circle enclosing the ellipse
365 if (theta <= theta_max()) {
366
367 // Update precomputation cache
368 update();
369
370 // Compute exponent
371 double sinphi = std::sin(posangle);
372 double cosphi = std::cos(posangle);
373 double term1 = m_term1 * cosphi * cosphi;
374 double term2 = m_term2 * sinphi * sinphi;
375 double term3 = m_term3 * sinphi * cosphi;
376 double exponent = theta * theta * (term1 + term2 + term3);
377
378 // Compute value
379 value = m_norm * std::exp(-exponent);
380
381 // Compile option: Check for NaN/Inf
382 #if defined(G_NAN_CHECK)
383 if (gammalib::is_notanumber(value) || gammalib::is_infinite(value)) {
384 std::cout << "*** ERROR: GModelSpatialEllipticalGauss::eval";
385 std::cout << "(theta=" << theta << "): NaN/Inf encountered";
386 std::cout << "(posangle=" << posangle << "): NaN/Inf encountered";
387 std::cout << " (value=" << value;
388 std::cout << ", m_term1=" << m_term1;
389 std::cout << ", m_term2=" << m_term2;
390 std::cout << ", m_term3=" << m_term3;
391 std::cout << ", m_norm=" << m_norm;
392 std::cout << ")" << std::endl;
393 }
394 #endif
395
396 } // endif: position was inside enclosing circle
397
398 // Return value
399 return value;
400}
401
402
403/***********************************************************************//**
404 * @brief Returns MC sky direction
405 *
406 * @param[in] energy Photon energy.
407 * @param[in] time Photon arrival time.
408 * @param[in,out] ran Random number generator.
409 * @return Sky direction.
410 *
411 * Draws an arbitrary sky direction from the elliptical Gaussian model.
412 *
413 * @warning
414 * For numerical reasons the elliptical Gaussian will be truncated for
415 * \f$\theta\f$ angles larger than 5 times the effective ellipse
416 * radius.
417 *
418 * @warning
419 * The method uses a small angle approximation.
420 ***************************************************************************/
422 const GTime& time,
423 GRan& ran) const
424{
425 // Update precomputation cache
426 update();
427
428 // Initialise photon
429 GPhoton photon;
430 photon.energy(energy);
431 photon.time(time);
432
433 // Draw gaussian offset from each axis
434 double ran_major;
435 double ran_minor;
436 do {
437 ran_major = ran.normal();
438 } while (ran_major > c_theta_max);
439 do {
440 ran_minor = ran.normal();
441 } while (ran_minor > c_theta_max);
442 double theta1 = semimajor() * ran_major;
443 double theta2 = semiminor() * ran_minor;
444
445 // Compute total offset from model centre in small angle approximation
446 double theta = std::sqrt(theta1 * theta1 + theta2 * theta2);
447
448 // Compute rotation angle, taking into account given position angle
449 double phi = gammalib::atan2d(theta2, theta1) + posangle();
450
451 // Rotate sky direction by offset
452 GSkyDir sky_dir = dir();
453 sky_dir.rotate_deg(phi , theta);
454
455 // Set photon sky direction
456 photon.dir(sky_dir);
457
458 // Return photon direction
459 return (photon.dir());
460}
461
462
463/***********************************************************************//**
464 * @brief Checks whether model contains specified sky direction
465 *
466 * @param[in] dir Sky direction.
467 * @param[in] margin Margin to be added to sky direction (degrees)
468 * @return True if the model contains the sky direction.
469 *
470 * Signals whether a sky direction is contained in the elliptical gauss
471 * model.
472 *
473 * @todo Implement correct evaluation of effective ellipse radius.
474 ***************************************************************************/
476 const double& margin) const
477{
478 // Compute distance to centre (radian)
479 double distance = dir.dist(this->dir());
480
481 // Return flag
482 return (distance <= theta_max() + margin*gammalib::deg2rad);
483}
484
485
486/***********************************************************************//**
487 * @brief Return maximum model radius (in radians)
488 *
489 * @return Returns maximum model radius.
490 *
491 * Returns the maximum model radius which is defined as the maximum of
492 * 5 semimajor() and 5 semiminor().
493 ***************************************************************************/
495{
496 // Set maximum model radius
497 double theta_max = (semimajor() > semiminor())
498 ? semimajor() * gammalib::deg2rad * c_theta_max
499 : semiminor() * gammalib::deg2rad * c_theta_max;
500
501 // Return value
502 return theta_max;
503}
504
505
506/***********************************************************************//**
507 * @brief Read model from XML element
508 *
509 * @param[in] xml XML element.
510 *
511 * Reads the elliptical gauss model information from an XML element. The XML
512 * element shall have either the format
513 *
514 * <spatialModel type="EllipticalGaussian">
515 * <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
516 * <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
517 * <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
518 * <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/>
519 * <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/>
520 * </spatialModel>
521 *
522 * or
523 *
524 * <spatialModel type="EllipticalGaussian">
525 * <parameter name="GLON" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
526 * <parameter name="GLAT" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
527 * <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
528 * <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/>
529 * <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/>
530 * </spatialModel>
531 *
532 * @todo Implement a test of the ellipse boundary. The axes
533 * and axes minimum should be >0.
534 ***************************************************************************/
536{
537 // Verify number of model parameters
539
540 // Read gauss location
542
543 // Get parameters
546
547 // Read parameters
548 m_semiminor.read(*minor);
549 m_semimajor.read(*major);
550
551 // Return
552 return;
553}
554
555
556/***********************************************************************//**
557 * @brief Write model into XML element
558 *
559 * @param[in] xml XML element into which model information is written.
560 *
561 * Write the elliptical gauss model information into an XML element. The XML
562 * element will have the format
563 *
564 * <spatialModel type="EllipticalGaussian">
565 * <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
566 * <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
567 * <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
568 * <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/>
569 * <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/>
570 * </spatialModel>
571 *
572 ***************************************************************************/
574{
575 // Verify model type
577
578 // Write disk location
580
581 // Get or create parameters
584
585 // Write parameters
586 m_semiminor.write(*minor);
587 m_semimajor.write(*major);
588
589 // Return
590 return;
591}
592
593
594/***********************************************************************//**
595 * @brief Print information
596 *
597 * @param[in] chatter Chattiness.
598 * @return String containing model information.
599 ***************************************************************************/
600std::string GModelSpatialEllipticalGauss::print(const GChatter& chatter) const
601{
602 // Initialise result string
603 std::string result;
604
605 // Continue only if chatter is not silent
606 if (chatter != SILENT) {
607
608 // Append header
609 result.append("=== GModelSpatialEllipticalGauss ===");
610
611 // Append parameters
612 result.append("\n"+gammalib::parformat("Number of parameters"));
613 result.append(gammalib::str(size()));
614 for (int i = 0; i < size(); ++i) {
615 result.append("\n"+m_pars[i]->print(chatter));
616 }
617
618 } // endif: chatter was not silent
619
620 // Return result
621 return result;
622}
623
624
625/*==========================================================================
626 = =
627 = Private methods =
628 = =
629 ==========================================================================*/
630
631/***********************************************************************//**
632 * @brief Initialise class members
633 ***************************************************************************/
635{
636 // Initialise model type
637 m_type = "EllipticalGaussian";
638
639 // Initialise precomputation cache. Note that zero values flag
640 // uninitialised as a zero radius is not meaningful
641 m_last_minor = 0.0;
642 m_last_major = 0.0;
643 m_minor_rad = 0.0;
644 m_major_rad = 0.0;
645 m_norm = 0.0;
646 m_last_posangle = 9999.0; // Signals that has not been initialised
647 m_sin2pos = 0.0;
648 m_cospos2 = 0.0;
649 m_sinpos2 = 0.0;
650 m_minor2 = 0.0;
651 m_major2 = 0.0;
652 m_term1 = 0.0;
653 m_term2 = 0.0;
654 m_term3 = 0.0;
655
656 // Return
657 return;
658}
659
660
661/***********************************************************************//**
662 * @brief Copy class members
663 *
664 * @param[in] model Elliptical Gaussian model.
665 ***************************************************************************/
667{
668 // Copy members
669 m_type = model.m_type; // Needed to conserve model type
670
671 // Copy precomputation cache
674 m_minor_rad = model.m_minor_rad;
675 m_major_rad = model.m_major_rad;
676 m_norm = model.m_norm;
678 m_sin2pos = model.m_sin2pos;
679 m_cospos2 = model.m_cospos2;
680 m_sinpos2 = model.m_sinpos2;
681 m_minor2 = model.m_minor2;
682 m_major2 = model.m_major2;
683 m_term1 = model.m_term1;
684 m_term2 = model.m_term2;
685 m_term3 = model.m_term3;
686
687 // Return
688 return;
689}
690
691
692/***********************************************************************//**
693 * @brief Delete class members
694 ***************************************************************************/
696{
697 // Return
698 return;
699}
700
701
702/***********************************************************************//**
703 * @brief Update precomputation cache
704 *
705 * Precomputes several variables in case that the model parameters
706 * semiminor(), semimajor() or posangle() changed. Precomputation speeds
707 * up the model evaluation.
708 *
709 * The method also computes the normalization
710 *
711 * \f[
712 * {\tt m\_norm} = \frac{1}{2 \pi \times a \times b}
713 * \f]
714 *
715 * where
716 * \f$a\f$ is the semimajor() axis and
717 * \f$b\f$ is the semiminor() axis of the ellipse.
718 *
719 * @warning
720 * The normalization of the elliptical Gaussian is only valid in the small
721 * angle approximation.
722 ***************************************************************************/
724{
725 // Initialise flag if something has changed
726 bool changed = false;
727
728 // Update if one axis has changed
729 if (m_last_minor != semiminor() || m_last_major != semimajor()) {
730
731 // Signal parameter changes
732 changed = true;
733
734 // Store last values
737
738 // Compute axes in radians
741
742 // Take their squares
745
746 // Compute normalisation.
747 // TODO: Implement correct formula. This one is not correct on
748 // TODO: a sphere, but it's fine for small Gaussians.
749 double denom = gammalib::twopi * m_minor_rad * m_major_rad;
750 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
751
752 } // endif: update required
753
754 // Update chache if position angle changed
755 if (m_last_posangle != posangle()) {
756
757 // Signal parameter changes
758 changed = true;
759
760 // Store last value
762
763 // Compute angle in radians
764 double posangle_rad = m_last_posangle * gammalib::deg2rad;
765
766 // Compute sine and cosine
767 double cospos = std::cos(posangle_rad);
768 double sinpos = std::sin(posangle_rad);
769
770 // Cache important values for further computations
771 m_cospos2 = cospos * cospos;
772 m_sinpos2 = sinpos * sinpos;
773 m_sin2pos = std::sin(2.0 * posangle_rad);
774
775 } // endif: position angle update required
776
777 // Perform precomputations in case anything has changed
778 if (changed) {
779
780 // Compute terms needed to compute inverse effective radius
781 // squared
785
786 } // endif: something has changed
787
788 // Return
789 return;
790}
791
792
793/***********************************************************************//**
794 * @brief Set boundary sky region
795 ***************************************************************************/
797{
798 // Set maximum model radius
799 double max_radius = (semimajor() > semiminor()) ? semimajor() : semiminor();
800
801 // Set sky region circle
802 GSkyRegionCircle region(dir(), max_radius * c_theta_max);
803
804 // Set region (circumvent const correctness)
805 const_cast<GModelSpatialEllipticalGauss*>(this)->m_region = region;
806
807 // Return
808 return;
809}
#define G_WRITE
#define G_READ
Exception handler interface definition.
Mathematical function definitions.
#define G_CONSTRUCTOR
Definition GMatrix.cpp:41
const GModelSpatialEllipticalGauss g_elliptical_gauss_seed
Elliptical gauss model class interface definition.
Radial disk model class interface definition.
Spatial model registry class definition.
Gammalib tools definition.
GChatter
Definition GTypemaps.hpp:33
@ SILENT
Definition GTypemaps.hpp:34
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
virtual void set_region(void) const
Set boundary sky region.
virtual GModelSpatialEllipticalGauss * clone(void) const
Clone elliptical Gaussian model.
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr )
virtual void read(const GXmlElement &xml)
Read model from XML element.
void copy_members(const GModelSpatialEllipticalGauss &model)
Copy class members.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
virtual GModelSpatialEllipticalGauss & operator=(const GModelSpatialEllipticalGauss &model)
Assignment operator.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual ~GModelSpatialEllipticalGauss(void)
Destructor.
virtual void clear(void)
Clear elliptical Gaussian model.
void update(void) const
Update precomputation cache.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
GModelSpatialEllipticalGauss(void)
Void constructor.
double m_sin2pos
sine of twice the position angle
double m_cospos2
squared cosine of position angle
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
double m_sinpos2
squared sine of position angle
Abstract elliptical spatial model base class.
void init_members(void)
Initialise class members.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
double semimajor(void) const
Return semi-major axis of ellipse.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
GModelPar m_lat
Declination or Galactic latitude (deg)
void free_members(void)
Delete class members.
double posangle(void) const
Return Position Angle of model.
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
std::string coordsys(void) const
Return coordinate system.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Interface definition for the spatial model registry class.
std::string m_type
Spatial model type.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
std::vector< GModelPar * > m_pars
Parameter pointers.
void init_members(void)
Initialise class members.
int size(void) const
Return number of parameters.
void free_members(void)
Delete class members.
GSkyRegionCircle m_region
Bounding circle.
const std::string & name(void) const
Return parameter name.
Class that handles photons.
Definition GPhoton.hpp:47
const GTime & time(void) const
Return photon time.
Definition GPhoton.hpp:134
const GSkyDir & dir(void) const
Return photon sky direction.
Definition GPhoton.hpp:110
const GEnergy & energy(void) const
Return photon energy.
Definition GPhoton.hpp:122
Random number generator class.
Definition GRan.hpp:44
double normal(void)
Returns normal deviates.
Definition GRan.cpp:257
Sky direction class.
Definition GSkyDir.hpp:62
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
Definition GSkyDir.cpp:573
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Definition GSkyDir.hpp:273
Interface for the circular sky region class.
Time class.
Definition GTime.hpp:55
XML element node class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition GTools.cpp:1162
bool is_infinite(const double &x)
Signal if argument is infinite.
Definition GTools.hpp:186
bool is_notanumber(const double &x)
Signal if argument is not a number.
Definition GTools.hpp:203
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition GTools.cpp:508
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:1708
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:1656
const double deg2rad
Definition GMath.hpp:43
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
Definition GTools.cpp:1796
double atan2d(const double &y, const double &x)
Compute arc tangens in degrees.
Definition GMath.cpp:308
const double twopi
Definition GMath.hpp:36
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.
Definition GTools.cpp:1838