GammaLib 2.1.0.dev
|
#include <GModelSpatialEllipticalGauss.hpp>
Public Member Functions | |
GModelSpatialEllipticalGauss (void) | |
Void constructor. | |
GModelSpatialEllipticalGauss (const bool &dummy, const std::string &type) | |
Model type constructor. | |
GModelSpatialEllipticalGauss (const GSkyDir &dir, const double &major, const double &minor, const double &posangle, const std::string &coordsys="CEL") | |
Elliptical Gaussian constructor. | |
GModelSpatialEllipticalGauss (const GXmlElement &xml) | |
XML constructor. | |
GModelSpatialEllipticalGauss (const GModelSpatialEllipticalGauss &model) | |
Copy constructor. | |
virtual | ~GModelSpatialEllipticalGauss (void) |
Destructor. | |
virtual GModelSpatialEllipticalGauss & | operator= (const GModelSpatialEllipticalGauss &model) |
Assignment operator. | |
virtual void | clear (void) |
Clear elliptical Gaussian model. | |
virtual GModelSpatialEllipticalGauss * | clone (void) const |
Clone elliptical Gaussian model. | |
virtual std::string | classname (void) const |
Return class name. | |
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}\)) | |
virtual GSkyDir | mc (const GEnergy &energy, const GTime &time, GRan &ran) const |
Returns MC sky direction. | |
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 void | read (const GXmlElement &xml) |
Read model from XML element. | |
virtual void | write (GXmlElement &xml) const |
Write model into XML element. | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print information. | |
Public Member Functions inherited from GModelSpatialElliptical | |
GModelSpatialElliptical (void) | |
Void constructor. | |
GModelSpatialElliptical (const GModelSpatialElliptical &model) | |
Copy constructor. | |
GModelSpatialElliptical (const GXmlElement &xml) | |
XML constructor. | |
virtual | ~GModelSpatialElliptical (void) |
Destructor. | |
virtual GModelSpatialElliptical & | operator= (const GModelSpatialElliptical &model) |
Assignment operator. | |
virtual GClassCode | code (void) const |
Return class code. | |
virtual double | eval (const GPhoton &photon, const bool &gradients=false) const |
Return model value. | |
virtual double | mc_norm (const GSkyDir &dir, const double &radius) const |
Return normalization of elliptical source for Monte Carlo simulations. | |
std::string | coordsys (void) const |
Return coordinate system. | |
const GSkyDir & | dir (void) const |
Return position of elliptical spatial model. | |
void | dir (const GSkyDir &dir) |
Set position of radial spatial model. | |
double | posangle (void) const |
Return Position Angle of model. | |
void | posangle (const double &posangle) |
Set Position Angle of model. | |
double | semiminor (void) const |
Return semi-minor axis of ellipse. | |
double | semimajor (void) const |
Return semi-major axis of ellipse. | |
void | semiminor (const double &semiminor) |
Set semi-minor axis of ellipse. | |
void | semimajor (const double &semimajor) |
Set semi-major axis of ellipse. | |
Public Member Functions inherited from GModelSpatial | |
GModelSpatial (void) | |
Void constructor. | |
GModelSpatial (const GModelSpatial &model) | |
Copy constructor. | |
virtual | ~GModelSpatial (void) |
Destructor. | |
virtual GModelSpatial & | operator= (const GModelSpatial &model) |
Assignment operator. | |
virtual GModelPar & | operator[] (const int &index) |
Returns model parameter. | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns model parameter (const version) | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns model parameter. | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns model parameter (const version) | |
virtual double | flux (const GSkyRegion ®ion, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const |
Returns model flux within sky region. | |
std::string | type (void) const |
Return model type. | |
void | type (const std::string &type) |
Set model type. | |
GModelPar & | at (const int &index) |
Returns model parameter. | |
const GModelPar & | at (const int &index) const |
Returns model parameter (const version) | |
bool | has_par (const std::string &name) const |
Checks if parameter name exists. | |
bool | has_free_pars (void) const |
Checks if the spatial model has free parameters. | |
int | size (void) const |
Return number of parameters. | |
void | autoscale (void) |
Autoscale parameters. | |
const GSkyRegion * | region (void) const |
Return boundary sky region. | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const GModelSpatialEllipticalGauss &model) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
void | update (void) const |
Update precomputation cache. | |
virtual void | set_region (void) const |
Set boundary sky region. | |
Protected Member Functions inherited from GModelSpatialElliptical | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const GModelSpatialElliptical &model) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
bool | is_celestial (void) const |
Check if model holds celestial coordinates. | |
Protected Member Functions inherited from GModelSpatial | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const GModelSpatial &model) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
Protected Attributes | |
double | m_last_minor |
Last semi-minor axis. | |
double | m_last_major |
Last semi-major axis. | |
double | m_last_posangle |
Last position angle. | |
double | m_cospos2 |
squared cosine of position angle | |
double | m_sinpos2 |
squared sine of position angle | |
double | m_sin2pos |
sine of twice the position angle | |
double | m_minor2 |
square of minor axis | |
double | m_major2 |
square of major axis | |
double | m_minor_rad |
Minor axis in radians. | |
double | m_major_rad |
Major axis in radians. | |
double | m_norm |
Normalization. | |
double | m_term1 |
Help term 1. | |
double | m_term2 |
Help term 2. | |
double | m_term3 |
Help term 3. | |
Protected Attributes inherited from GModelSpatialElliptical | |
GModelPar | m_lon |
Right Ascension or Galactic longitude (deg) | |
GModelPar | m_lat |
Declination or Galactic latitude (deg) | |
GModelPar | m_posangle |
Position angle from North, counterclockwise (deg) | |
GModelPar | m_semiminor |
Semi-minor axis of ellipse (deg) | |
GModelPar | m_semimajor |
Semi-major axis of ellipse (deg) | |
GSkyDir | m_dir |
Sky direction representing parameters. | |
double | m_last_lon |
Last longitude. | |
double | m_last_lat |
Last latitude. | |
Protected Attributes inherited from GModelSpatial | |
std::string | m_type |
Spatial model type. | |
GSkyRegionCircle | m_region |
Bounding circle. | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. | |
Definition at line 54 of file GModelSpatialEllipticalGauss.hpp.
GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss | ( | void | ) |
Void constructor.
Definition at line 76 of file GModelSpatialEllipticalGauss.cpp.
References init_members().
Referenced by clone().
GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss | ( | const bool & | dummy, |
const std::string & | type ) |
Model type constructor.
[in] | dummy | Dummy flag. |
[in] | type | Model type. |
Constructs empty elliptical Gaussian model by specifying a model type
.
Definition at line 95 of file GModelSpatialEllipticalGauss.cpp.
References init_members(), GModelSpatial::m_type, and GModelSpatial::type().
GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss | ( | const GSkyDir & | dir, |
const double & | semimajor, | ||
const double & | semiminor, | ||
const double & | posangle, | ||
const std::string & | coordsys = "CEL" ) |
Elliptical Gaussian constructor.
[in] | dir | Centre of elliptical Gaussian. |
[in] | semimajor | Semi-major axis (degrees). |
[in] | semiminor | Semi-minor axis (degrees). |
[in] | posangle | Position angle of semi-major axis (degrees). |
[in] | coordsys | Coordinate system (either "CEL" or "GAL") |
GException::invalid_argument | Invalid coordsys argument specified. |
Construct an elliptical Gaussian model from the ellipse centre direction (dir
), the semimajor
and semiminor
axes, and the position angle (posangle
). The coordsys
parameter specifies whether the sky direction and the position angle should be interpreted in the celestial or Galactic coordinates.
Definition at line 128 of file GModelSpatialEllipticalGauss.cpp.
References GModelSpatialElliptical::coordsys(), GModelSpatialElliptical::dir(), G_CONSTRUCTOR, init_members(), GModelSpatialElliptical::m_lat, GModelSpatialElliptical::m_lon, GOptimizerPar::name(), GModelSpatialElliptical::posangle(), GModelSpatialElliptical::semimajor(), and GModelSpatialElliptical::semiminor().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs elliptical Gaussian model by extracting information from an XML element. See the read() method for more information about the expected structure of the XML element.
Definition at line 176 of file GModelSpatialEllipticalGauss.cpp.
References init_members(), and read().
GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss | ( | const GModelSpatialEllipticalGauss & | model | ) |
Copy constructor.
[in] | model | Elliptical Gaussian model. |
Definition at line 195 of file GModelSpatialEllipticalGauss.cpp.
References copy_members(), and init_members().
|
virtual |
Destructor.
Definition at line 212 of file GModelSpatialEllipticalGauss.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GModelSpatialElliptical.
Definition at line 124 of file GModelSpatialEllipticalGauss.hpp.
|
virtual |
Clear elliptical Gaussian model.
Implements GModelSpatialElliptical.
Definition at line 267 of file GModelSpatialEllipticalGauss.cpp.
References GModelSpatial::free_members(), GModelSpatialElliptical::free_members(), free_members(), GModelSpatial::init_members(), GModelSpatialElliptical::init_members(), and init_members().
|
virtual |
Clone elliptical Gaussian model.
Implements GModelSpatialElliptical.
Definition at line 289 of file GModelSpatialEllipticalGauss.cpp.
References GModelSpatialEllipticalGauss().
|
virtual |
Checks whether model contains specified sky direction.
[in] | dir | Sky direction. |
[in] | margin | Margin to be added to sky direction (degrees) |
Signals whether a sky direction is contained in the elliptical gauss model.
Implements GModelSpatialElliptical.
Definition at line 475 of file GModelSpatialEllipticalGauss.cpp.
References gammalib::deg2rad, GModelSpatialElliptical::dir(), GSkyDir::dist(), and theta_max().
|
protected |
Copy class members.
[in] | model | Elliptical Gaussian model. |
Definition at line 666 of file GModelSpatialEllipticalGauss.cpp.
References m_cospos2, m_last_major, m_last_minor, m_last_posangle, m_major2, m_major_rad, m_minor2, m_minor_rad, m_norm, m_sin2pos, m_sinpos2, m_term1, m_term2, m_term3, and GModelSpatial::m_type.
Referenced by GModelSpatialEllipticalGauss(), and operator=().
|
virtual |
Evaluate function (in units of sr \(^{-1}\))
[in] | theta | Angular distance from disk centre (radians) |
[in] | posangle | Position angle (counterclockwise from North) (radians) |
[in] | energy | Photon energy (not used) |
[in] | time | Photon arrival time (not used) |
[in] | gradients | Compute gradients? (not used) |
Evaluates the spatial component for an elliptical Gaussian source model.
The elliptical Gaussian function is energy and time independent, and defined by
\[ S_{\rm p}(\theta, \phi | E, t) = S_{\rm p}(\theta, \phi) \]
where \(\theta\) is the angular separation from the centre of the elliptical Gaussian and \(\phi\) the position angle with respect to the model centre, counted counterclockwise from North. The coordinate system in which the position angle \(\phi\) is given is defined by the coordinate system in which the centre of elliptical Gaussian model is specified. The coordsys() method may be used to retrieve a string of the coordinate system.
The function \(S_{\rm p}(\theta, \phi)\) is given by
\[ S_{\rm p}(\theta, \phi) = {\tt m\_norm} \times \exp \left( -\frac{\theta^2}{2} \left[ \left( \frac{\sin^2 \phi_0}{b^2} + \frac{\cos^2 \phi_0}{a^2} \right) \cos^2 \phi + \left( \frac{\sin^2 \phi_0}{a^2} + \frac{\cos^2 \phi_0}{b^2} \right) \sin^2 \phi + \left( \frac{\sin 2\phi_0}{a^2} - \frac{\sin 2\phi_0}{b^2} \right) \sin \phi \cos \phi \right] \right) \]
where \(a\) is the semi-major axis of the ellipse, \(b\) is the semi-minor axis, and \(\phi_0\) is the position angle of the ellipse, counted counterclockwise from North.
\({\tt m\_norm}\) is a normalization constant that is approximated by
\[ {\tt m\_norm} = \frac{1}{2 \pi \times a \times b} \]
which is only accurate for values of \(a\) and \(b\) that do not exceed a few degrees. For larger ellipse sizes it is recommended to spatially integrate \(S_{\rm p}(\theta, \phi)\) in order to obtain a proper normalisation.
The method will not compute analytical parameter gradients, even if the gradients
argument is set to true. Elliptical Gaussian parameter gradients need to be computed numerically.
Implements GModelSpatialElliptical.
Definition at line 355 of file GModelSpatialEllipticalGauss.cpp.
References gammalib::is_infinite(), gammalib::is_notanumber(), m_norm, m_term1, m_term2, m_term3, GModelSpatialElliptical::posangle(), theta_max(), and update().
|
protected |
Delete class members.
Definition at line 695 of file GModelSpatialEllipticalGauss.cpp.
Referenced by clear(), operator=(), and ~GModelSpatialEllipticalGauss().
|
protected |
Initialise class members.
Definition at line 634 of file GModelSpatialEllipticalGauss.cpp.
References m_cospos2, m_last_major, m_last_minor, m_last_posangle, m_major2, m_major_rad, m_minor2, m_minor_rad, m_norm, m_sin2pos, m_sinpos2, m_term1, m_term2, m_term3, and GModelSpatial::m_type.
Referenced by clear(), GModelSpatialEllipticalGauss(), GModelSpatialEllipticalGauss(), GModelSpatialEllipticalGauss(), GModelSpatialEllipticalGauss(), GModelSpatialEllipticalGauss(), and operator=().
|
virtual |
Returns MC sky direction.
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in,out] | ran | Random number generator. |
Draws an arbitrary sky direction from the elliptical Gaussian model.
Implements GModelSpatialElliptical.
Definition at line 421 of file GModelSpatialEllipticalGauss.cpp.
References gammalib::atan2d(), GModelSpatialElliptical::dir(), GPhoton::dir(), GPhoton::energy(), GRan::normal(), GModelSpatialElliptical::posangle(), GSkyDir::rotate_deg(), GModelSpatialElliptical::semimajor(), GModelSpatialElliptical::semiminor(), GPhoton::time(), and update().
|
virtual |
Assignment operator.
[in] | model | Elliptical gauss model. |
Definition at line 234 of file GModelSpatialEllipticalGauss.cpp.
References copy_members(), free_members(), init_members(), and GModelSpatialElliptical::operator=().
Print information.
[in] | chatter | Chattiness. |
Implements GModelSpatialElliptical.
Definition at line 600 of file GModelSpatialEllipticalGauss.cpp.
References GModelSpatial::m_pars, gammalib::parformat(), print(), SILENT, GModelSpatial::size(), and gammalib::str().
Referenced by print().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
Reads the elliptical gauss model information from an XML element. The XML element shall have either the format
<spatialModel type="EllipticalGaussian"> <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/> <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/> <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/> <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/> <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/> </spatialModel>
or
<spatialModel type="EllipticalGaussian"> <parameter name="GLON" scale="1.0" value="83.6331" min="-360" max="360" free="1"/> <parameter name="GLAT" scale="1.0" value="22.0145" min="-90" max="90" free="1"/> <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/> <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/> <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/> </spatialModel>
Reimplemented from GModelSpatialElliptical.
Definition at line 535 of file GModelSpatialEllipticalGauss.cpp.
References G_READ, GModelSpatialElliptical::m_semimajor, GModelSpatialElliptical::m_semiminor, GOptimizerPar::name(), GModelPar::read(), GModelSpatialElliptical::read(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().
Referenced by GModelSpatialEllipticalGauss().
|
protectedvirtual |
Set boundary sky region.
Implements GModelSpatialElliptical.
Definition at line 796 of file GModelSpatialEllipticalGauss.cpp.
References GModelSpatialElliptical::dir(), GModelSpatial::m_region, GModelSpatial::region(), GModelSpatialElliptical::semimajor(), and GModelSpatialElliptical::semiminor().
|
virtual |
Return maximum model radius (in radians)
Returns the maximum model radius which is defined as the maximum of 5 semimajor() and 5 semiminor().
Implements GModelSpatialElliptical.
Definition at line 494 of file GModelSpatialEllipticalGauss.cpp.
References gammalib::deg2rad, GModelSpatialElliptical::semimajor(), GModelSpatialElliptical::semiminor(), and theta_max().
Referenced by contains(), eval(), and theta_max().
|
protected |
Update precomputation cache.
Precomputes several variables in case that the model parameters semiminor(), semimajor() or posangle() changed. Precomputation speeds up the model evaluation.
The method also computes the normalization
\[ {\tt m\_norm} = \frac{1}{2 \pi \times a \times b} \]
where \(a\) is the semimajor() axis and \(b\) is the semiminor() axis of the ellipse.
Definition at line 723 of file GModelSpatialEllipticalGauss.cpp.
References gammalib::deg2rad, m_cospos2, m_last_major, m_last_minor, m_last_posangle, m_major2, m_major_rad, m_minor2, m_minor_rad, m_norm, m_sin2pos, m_sinpos2, m_term1, m_term2, m_term3, GModelSpatialElliptical::posangle(), GModelSpatialElliptical::semimajor(), GModelSpatialElliptical::semiminor(), and gammalib::twopi.
|
virtual |
Write model into XML element.
[in] | xml | XML element into which model information is written. |
Write the elliptical gauss model information into an XML element. The XML element will have the format
<spatialModel type="EllipticalGaussian"> <parameter name="RA" scale="1.0" value="83.6331" min="-360" max="360" free="1"/> <parameter name="DEC" scale="1.0" value="22.0145" min="-90" max="90" free="1"/> <parameter name="PA" scale="1.0" value="45.0" min="-360" max="360" free="1"/> <parameter name="MinorRadius" scale="1.0" value="0.5" min="0.001" max="10" free="1"/> <parameter name="MajorRadius" scale="1.0" value="2.0" min="0.001" max="10" free="1"/> </spatialModel>
Reimplemented from GModelSpatialElliptical.
Definition at line 573 of file GModelSpatialEllipticalGauss.cpp.
References G_WRITE, GModelSpatialElliptical::m_semimajor, GModelSpatialElliptical::m_semiminor, GOptimizerPar::name(), GModelSpatial::type(), GModelPar::write(), GModelSpatialElliptical::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().
|
mutableprotected |
squared cosine of position angle
Definition at line 104 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Last semi-major axis.
Definition at line 102 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Last semi-minor axis.
Definition at line 101 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Last position angle.
Definition at line 103 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
square of major axis
Definition at line 108 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Major axis in radians.
Definition at line 110 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
square of minor axis
Definition at line 107 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Minor axis in radians.
Definition at line 109 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Normalization.
Definition at line 111 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
mutableprotected |
sine of twice the position angle
Definition at line 106 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
squared sine of position angle
Definition at line 105 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Help term 1.
Definition at line 112 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
mutableprotected |
Help term 2.
Definition at line 113 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
mutableprotected |
Help term 3.
Definition at line 114 of file GModelSpatialEllipticalGauss.hpp.
Referenced by copy_members(), eval(), init_members(), and update().