GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GModelSpatialEllipticalDisk.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpatialEllipticalDisk.cpp - Elliptical disk source model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2013-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 GModelSpatialEllipticalDisk.cpp
23 * @brief Elliptical disk 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 __________________________________________________________ */
39
40/* __ Globals ____________________________________________________________ */
42const GModelSpatialRegistry g_elliptical_disk_registry(&g_elliptical_disk_seed);
43
44/* __ Method name definitions ____________________________________________ */
45#define G_CONSTRUCTOR "GModelSpatialEllipticalDisk::"\
46 "GModelSpatialEllipticalDisk(GSkyDir&, double&, double&, "\
47 "double&, std::string&)"
48#define G_READ "GModelSpatialEllipticalDisk::read(GXmlElement&)"
49#define G_WRITE "GModelSpatialEllipticalDisk::write(GXmlElement&)"
50
51/* __ Macros _____________________________________________________________ */
52
53/* __ Coding definitions _________________________________________________ */
54
55/* __ Debug definitions __________________________________________________ */
56
57
58/*==========================================================================
59 = =
60 = Constructors/destructors =
61 = =
62 ==========================================================================*/
63
64/***********************************************************************//**
65 * @brief Void constructor
66 ***************************************************************************/
69{
70 // Initialise members
72
73 // Return
74 return;
75}
76
77
78/***********************************************************************//**
79 * @brief Disk constructor
80 *
81 * @param[in] dir Sky position of disk centre.
82 * @param[in] semimajor Semi-major axis (degrees).
83 * @param[in] semiminor Semi-minor axis (degrees).
84 * @param[in] posangle Position angle of semi-major axis (degrees).
85 * @param[in] coordsys Coordinate system (either "CEL" or "GAL")
86 *
87 * @exception GException::invalid_argument
88 * Invalid @p coordsys argument specified.
89 *
90 * Construct elliptical disk model from sky position of the ellipse centre
91 * (@p dir), the @p semimajor and @p semiminor axes, and the position
92 * angle (@p posangle). The @p coordsys parameter specifies whether the sky
93 * direction and the position angle should be interpreted in the celestial
94 * or Galactic coordinates.
95 ***************************************************************************/
97 const double& semimajor,
98 const double& semiminor,
99 const double& posangle,
100 const std::string& coordsys) :
102{
103 // Throw an exception if the coordinate system is invalid
104 if ((coordsys != "CEL") && (coordsys != "GAL")) {
105 std::string msg = "Invalid coordinate system \""+coordsys+"\" "
106 "specified. Please specify either \"CEL\" or "
107 "\"GAL\".";
109 }
110
111 // Initialise members
112 init_members();
113
114 // Set parameter names
115 if (coordsys == "CEL") {
116 m_lon.name("RA");
117 m_lat.name("DEC");
118 }
119 else {
120 m_lon.name("GLON");
121 m_lat.name("GLAT");
122 }
123
124 // Assign parameters
125 this->dir(dir);
126 this->semiminor(semiminor);
127 this->semimajor(semimajor);
128 this->posangle(posangle);
129
130 // Return
131 return;
132}
133
134
135/***********************************************************************//**
136 * @brief XML constructor
137 *
138 * @param[in] xml XML element.
139 *
140 * Constructs elliptical disk model by extracting information from an XML
141 * element. See the read() method for more information about the expected
142 * structure of the XML element.
143 ***************************************************************************/
146{
147 // Initialise members
148 init_members();
149
150 // Read information from XML element
151 read(xml);
152
153 // Return
154 return;
155}
156
157
158/***********************************************************************//**
159 * @brief Copy constructor
160 *
161 * @param[in] model Elliptical disk model.
162 ***************************************************************************/
165{
166 // Initialise members
167 init_members();
168
169 // Copy members
170 copy_members(model);
171
172 // Return
173 return;
174}
175
176
177/***********************************************************************//**
178 * @brief Destructor
179 ***************************************************************************/
181{
182 // Free members
183 free_members();
184
185 // Return
186 return;
187}
188
189
190/*==========================================================================
191 = =
192 = Operators =
193 = =
194 ==========================================================================*/
195
196/***********************************************************************//**
197 * @brief Assignment operator
198 *
199 * @param[in] model Elliptical disk model.
200 * @return Elliptical disk model.
201 ***************************************************************************/
203{
204 // Execute only if object is not identical
205 if (this != &model) {
206
207 // Copy base class members
209
210 // Free members
211 free_members();
212
213 // Initialise members
214 init_members();
215
216 // Copy members
217 copy_members(model);
218
219 } // endif: object was not identical
220
221 // Return
222 return *this;
223}
224
225
226/*==========================================================================
227 = =
228 = Public methods =
229 = =
230 ==========================================================================*/
231
232/***********************************************************************//**
233 * @brief Clear elliptical disk model
234 ***************************************************************************/
236{
237 // Free class members (base and derived classes, derived class first)
238 free_members();
241
242 // Initialise members
245 init_members();
246
247 // Return
248 return;
249}
250
251
252/***********************************************************************//**
253 * @brief Clone elliptical disk model
254 *
255 * @return Pointer to deep copy of elliptical disk model.
256 ***************************************************************************/
258{
259 // Clone elliptical disk model
260 return new GModelSpatialEllipticalDisk(*this);
261}
262
263
264/***********************************************************************//**
265 * @brief Evaluate function (in units of sr^-1)
266 *
267 * @param[in] theta Angular distance from disk centre (radians).
268 * @param[in] posangle Position angle (counterclockwise from North) (radians).
269 * @param[in] energy Photon energy.
270 * @param[in] time Photon arrival time.
271 * @param[in] gradients Compute gradients?
272 * @return Model value.
273 *
274 * Evaluates the spatial component for an elliptical disk source model.
275 *
276 * The elliptical disk function is energy and time independent, and defined
277 * by
278 *
279 * \f[
280 * S_{\rm p}(\theta, \phi | E, t) = S_{\rm p}(\theta, \phi)
281 * \f]
282 *
283 * where \f$\theta\f$ is the angular separation from the centre of the
284 * elliptical disk and \f$\phi\f$ the position angle with respect to
285 * the model centre, counted counterclockwise from North. The coordinate
286 * system in which the position angle \f$\phi\f$ is given is defined by the
287 * coordinate system in which the centre of elliptical Gaussian model is
288 * specified. The coordsys() method may be used to retrieve a string of the
289 * coordinate system.
290 *
291 * \f$S_{\rm p}(\theta, \phi)\f$ is defined by
292 *
293 * \f[
294 * S_{\rm p}(\theta, \phi | E, t) = \left \{
295 * \begin{array}{l l}
296 * {\tt m\_norm}
297 * & \mbox{if} \, \, \theta \le \theta_{\rm eff}(\phi) \\
298 * \\
299 * 0 & \mbox{else}
300 * \end{array}
301 * \right .
302 * \f]
303 *
304 * where
305 *
306 * \f[
307 * \theta_{\rm eff}(\phi) = \left[
308 * \left( \frac{\sin^2 \phi_0}{b^2} + \frac{\cos^2 \phi_0}{a^2} \right) \cos^2 \phi +
309 * \left( \frac{\sin^2 \phi_0}{a^2} + \frac{\cos^2 \phi_0}{b^2} \right) \sin^2 \phi +
310 * \left( \frac{\sin 2\phi_0}{a^2} - \frac{\sin 2\phi_0}{b^2} \right) \sin \phi \cos \phi
311 * \right]^{-1/2}
312 * \f]
313 *
314 * is the effective radius of the elliptical disk for a position angle
315 * of \f$\phi\f$, \f$a\f$ is the semi-major axis of the ellipse, and
316 * \f$b\f$ is the semi-minor axis.
317 *
318 * The normalisation constant \f${\tt m\_norm}\f$ is given by
319 *
320 * \f[
321 * {\tt m\_norm} = \frac{1}{2 \pi \sqrt{(1-\cos a)(1-\cos b})}
322 * \f]
323 *
324 * The method will not compute analytical parameter gradients, even if the
325 * @p gradients argument is set to true. Radial disk parameter gradients
326 * need to be computed numerically.
327 ***************************************************************************/
328double GModelSpatialEllipticalDisk::eval(const double& theta,
329 const double& posangle,
330 const GEnergy& energy,
331 const GTime& time,
332 const bool& gradients) const
333{
334 // Initialise value
335 double value = 0.0;
336
337 // Continue only if we're inside circle enclosing the ellipse
338 if (theta <= theta_max()) {
339
340 // Update precomputation cache
341 update();
342
343 // Compute theta0
344 double sinphi = std::sin(posangle);
345 double cosphi = std::cos(posangle);
346 double term1 = m_term1 * cosphi * cosphi;
347 double term2 = m_term2 * sinphi * sinphi;
348 double term3 = m_term3 * sinphi * cosphi;
349 double theta0 = std::sqrt(1.0/(term1 + term2 + term3));
350
351 // Set value
352 value = (theta <= theta0) ? m_norm : 0.0;
353
354 // Compile option: Check for NaN/Inf
355 #if defined(G_NAN_CHECK)
356 if (gammalib::is_notanumber(value) || gammalib::is_infinite(value)) {
357 std::cout << "*** ERROR: GModelSpatialEllipticalDisk::eval";
358 std::cout << "(theta=" << theta << "): NaN/Inf encountered";
359 std::cout << "(posangle=" << posangle << "): NaN/Inf encountered";
360 std::cout << " (value=" << value;
361 std::cout << ", m_term1=" << m_term1;
362 std::cout << ", m_term2=" << m_term2;
363 std::cout << ", m_term3=" << m_term3;
364 std::cout << ", m_norm=" << m_norm;
365 std::cout << ")" << std::endl;
366 }
367 #endif
368
369 } // endif: position was inside enclosing circle
370
371 // Return value
372 return value;
373}
374
375
376/***********************************************************************//**
377 * @brief Returns MC sky direction
378 *
379 * @param[in] energy Photon energy.
380 * @param[in] time Photon arrival time.
381 * @param[in,out] ran Random number generator.
382 * @return Sky direction.
383 *
384 * Draws an arbitrary sky position from the 2D disk distribution.
385 *
386 * @todo Test function
387 ***************************************************************************/
389 const GTime& time,
390 GRan& ran) const
391{
392 // Update precomputation cache
393 update();
394
395 // Initialise photon
396 GPhoton photon;
397 photon.energy(energy);
398 photon.time(time);
399
400 // Draw randomly from the radial disk and reject the value if its
401 //outside the ellipse
402 do {
403
404 // Simulate offset from photon arrival direction
405 double cosrad = std::cos(semimajor() * gammalib::deg2rad);
406 double theta = std::acos(1.0 - ran.uniform() * (1.0 - cosrad)) *
408 double phi = 360.0 * ran.uniform();
409
410 // Rotate sky direction by offset
411 GSkyDir sky_dir = dir();
412 sky_dir.rotate_deg(phi, theta);
413
414 // Set photon sky direction
415 photon.dir(sky_dir);
416
417 } while(GModelSpatialElliptical::eval(photon) <= 0.0);
418
419 // Return photon direction
420 return (photon.dir());
421}
422
423
424/***********************************************************************//**
425 * @brief Checks where model contains specified sky direction
426 *
427 * @param[in] dir Sky direction.
428 * @param[in] margin Margin to be added to sky direction (degrees)
429 * @return True if the model contains the sky direction.
430 *
431 * Signals whether a sky direction is contained in the elliptical disk
432 * model.
433 *
434 * @todo Implement correct evaluation of effective ellipse radius.
435 ***************************************************************************/
437 const double& margin) const
438{
439 // Compute distance to centre (radian)
440 double distance = dir.dist(this->dir());
441
442 // Return flag
443 return (distance <= theta_max() + margin*gammalib::deg2rad);
444}
445
446
447/***********************************************************************//**
448 * @brief Return maximum model radius (in radians)
449 *
450 * @return Returns maximum model radius.
451 ***************************************************************************/
453{
454 // Set maximum model radius
455 double theta_max = (semimajor() > semiminor())
458
459 // Return value
460 return theta_max;
461}
462
463
464/***********************************************************************//**
465 * @brief Read model from XML element
466 *
467 * @param[in] xml XML element.
468 *
469 * @exception GException::model_invalid_parnum
470 * Invalid number of model parameters found in XML element.
471 * @exception GException::model_invalid_parnames
472 * Invalid model parameter names found in XML element.
473 *
474 * Reads the elliptical disk model information from an XML element. The XML
475 * element shall have either the format
476 *
477 * <spatialModel type="EllipticalDisk">
478 * <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
479 * <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
480 * <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
481 * <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/>
482 * <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/>
483 * </spatialModel>
484 *
485 * or
486 *
487 * <spatialModel type="EllipticalDisk">
488 * <parameter name="GLON" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
489 * <parameter name="GLAT" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
490 * <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
491 * <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/>
492 * <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/>
493 * </spatialModel>
494 *
495 * @todo Implement a test of the ellipse boundary. The axes
496 * and axes minimum should be >0.
497 ***************************************************************************/
499{
500 // Verify number of model parameters
502
503 // Read disk location
505
506 // Get parameters
509
510 // Read parameters
511 m_semiminor.read(*minor);
512 m_semimajor.read(*major);
513
514 // Return
515 return;
516}
517
518
519/***********************************************************************//**
520 * @brief Write model into XML element
521 *
522 * @param[in] xml XML element into which model information is written.
523 *
524 * Write the elliptical disk model information into an XML element. The XML
525 * element will have the format
526 *
527 * <spatialModel type="EllipticalDisk">
528 * <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/>
529 * <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/>
530 * <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/>
531 * <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/>
532 * <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/>
533 * </spatialModel>
534 *
535 ***************************************************************************/
537{
538 // Verify model type
540
541 // Write disk location
543
544 // Get or create parameters
547
548 // Write parameters
549 m_semiminor.write(*minor);
550 m_semimajor.write(*major);
551
552 // Return
553 return;
554}
555
556
557/***********************************************************************//**
558 * @brief Print information
559 *
560 * @param[in] chatter Chattiness.
561 * @return String containing model information.
562 ***************************************************************************/
563std::string GModelSpatialEllipticalDisk::print(const GChatter& chatter) const
564{
565 // Initialise result string
566 std::string result;
567
568 // Continue only if chatter is not silent
569 if (chatter != SILENT) {
570
571 // Append header
572 result.append("=== GModelSpatialEllipticalDisk ===");
573
574 // Append parameters
575 result.append("\n"+gammalib::parformat("Number of parameters"));
576 result.append(gammalib::str(size()));
577 for (int i = 0; i < size(); ++i) {
578 result.append("\n"+m_pars[i]->print(chatter));
579 }
580
581 } // endif: chatter was not silent
582
583 // Return result
584 return result;
585}
586
587
588/*==========================================================================
589 = =
590 = Private methods =
591 = =
592 ==========================================================================*/
593
594/***********************************************************************//**
595 * @brief Initialise class members
596 ***************************************************************************/
598{
599 // Initialise model type
600 m_type = "EllipticalDisk";
601
602 // Initialise precomputation cache. Note that zero values flag
603 // uninitialised as a zero radius is not meaningful
604 m_last_minor = 0.0;
605 m_last_major = 0.0;
606 m_minor_rad = 0.0;
607 m_major_rad = 0.0;
608 m_norm = 0.0;
609 m_last_posangle = 9999.0; // Signals that has not been initialised
610 m_sin2pos = 0.0;
611 m_cospos2 = 0.0;
612 m_sinpos2 = 0.0;
613 m_minor2 = 0.0;
614 m_major2 = 0.0;
615 m_term1 = 0.0;
616 m_term2 = 0.0;
617 m_term3 = 0.0;
618
619 // Return
620 return;
621}
622
623
624/***********************************************************************//**
625 * @brief Copy class members
626 *
627 * @param[in] model Elliptical disk model.
628 *
629 * We do not have to push back the members on the parameter stack as this
630 * should have been done by init_members() that was called before. Otherwise
631 * we would have the radius twice on the stack.
632 ***************************************************************************/
634{
635 // Copy members
636 m_type = model.m_type; // Needed to conserve model type
637
638 // Copy precomputation cache
641 m_minor_rad = model.m_minor_rad;
642 m_major_rad = model.m_major_rad;
643 m_norm = model.m_norm;
645 m_sin2pos = model.m_sin2pos;
646 m_cospos2 = model.m_cospos2;
647 m_sinpos2 = model.m_sinpos2;
648 m_minor2 = model.m_minor2;
649 m_major2 = model.m_major2;
650 m_term1 = model.m_term1;
651 m_term2 = model.m_term2;
652 m_term3 = model.m_term3;
653
654 // Return
655 return;
656}
657
658
659/***********************************************************************//**
660 * @brief Delete class members
661 ***************************************************************************/
663{
664 // Return
665 return;
666}
667
668
669/***********************************************************************//**
670 * @brief Update precomputation cache
671 *
672 * Precomputes several variables in case that the model parameters
673 * semiminor(), semimajor() or posangle() changed. Precomputation speeds
674 * up the model evaluation.
675 *
676 * The method also computes the normalization
677 *
678 * \f[
679 * {\tt m\_norm} = \frac{1}{2 \pi \sqrt{(1-\cos a)(1-\cos b})}
680 * \f]
681 *
682 * where
683 * \f$a\f$ is the semimajor() axis and
684 * \f$b\f$ is the semiminor() axis of the ellipse.
685 *
686 * @warning
687 * The normalization of the elliptical disk is only valid in the small
688 * angle approximation.
689 ***************************************************************************/
691{
692 // Initialise flag if something has changed
693 bool changed = false;
694
695 // Update if one axis has changed
696 if (m_last_minor != semiminor() || m_last_major != semimajor()) {
697
698 // Signal parameter changes
699 changed = true;
700
701 // Store last values
704
705 // Compute axes in radians
708
709 // Take their squares
712
713 // Compute normalisation
714 double denom = gammalib::twopi *
715 std::sqrt((1.0 - std::cos(m_minor_rad)) *
716 (1.0 - std::cos(m_major_rad)));
717 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
718
719 } // endif: update required
720
721 // Update chache if position angle changed
722 if (m_last_posangle != posangle()) {
723
724 // Signal parameter changes
725 changed = true;
726
727 // Store last value
729
730 // Compute angle in radians
731 double posangle_rad = m_last_posangle * gammalib::deg2rad;
732
733 // Compute sine and cosine
734 double cospos = std::cos(posangle_rad);
735 double sinpos = std::sin(posangle_rad);
736
737 // Cache important values for further computations
738 m_cospos2 = cospos * cospos;
739 m_sinpos2 = sinpos * sinpos;
740 m_sin2pos = std::sin(2.0 * posangle_rad);
741
742 } // endif: position angle update required
743
744 // Perform precomputations in case anything has changed
745 if (changed) {
746
747 // Compute terms needed to compute inverse effective radius
748 // squared
752
753 } // endif: something has changed
754
755 // Return
756 return;
757}
758
759
760/***********************************************************************//**
761 * @brief Set boundary sky region
762 ***************************************************************************/
764{
765 // Set maximum model radius
766 double max_radius = (semimajor() > semiminor()) ? semimajor() : semiminor();
767
768 // Set sky region circle
769 GSkyRegionCircle region(dir(), max_radius);
770
771 // Set region (circumvent const correctness)
772 const_cast<GModelSpatialEllipticalDisk*>(this)->m_region = region;
773
774 // Return
775 return;
776}
#define G_WRITE
#define G_READ
Exception handler interface definition.
Mathematical function definitions.
#define G_CONSTRUCTOR
Definition GMatrix.cpp:41
const GModelSpatialEllipticalDisk g_elliptical_disk_seed
Elliptical disk 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.
double m_last_major
Last semi-major axis.
virtual void set_region(void) const
Set boundary sky region.
virtual GModelSpatialEllipticalDisk * clone(void) const
Clone elliptical disk model.
double m_minor_rad
Minor axis in radians.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
void init_members(void)
Initialise class members.
double m_cospos2
squared cosine of position angle
double m_last_minor
Last semi-minor axis.
double m_major_rad
Major axis in radians.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
void copy_members(const GModelSpatialEllipticalDisk &model)
Copy class members.
virtual GModelSpatialEllipticalDisk & operator=(const GModelSpatialEllipticalDisk &model)
Assignment operator.
double m_sinpos2
squared sine of position angle
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^-1)
double m_sin2pos
sine of twice the position angle
virtual ~GModelSpatialEllipticalDisk(void)
Destructor.
virtual void clear(void)
Clear elliptical disk model.
virtual double theta_max(void) const
Return maximum model radius (in radians)
double m_last_posangle
Last position angle.
void update(void) const
Update precomputation cache.
void free_members(void)
Delete class members.
GModelSpatialEllipticalDisk(void)
Void constructor.
virtual void read(const GXmlElement &xml)
Read model from XML element.
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)
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
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 uniform(void)
Returns random double precision floating value in range 0 to 1.
Definition GRan.cpp:242
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
const double twopi
Definition GMath.hpp:36
const double rad2deg
Definition GMath.hpp:44
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.
Definition GTools.cpp:1838