GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialGeneralGauss Class Reference

Generalized radial Gaussian model class. More...

#include <GModelSpatialRadialGeneralGauss.hpp>

Inheritance diagram for GModelSpatialRadialGeneralGauss:
GModelSpatialRadial GModelSpatial GBase

Public Member Functions

 GModelSpatialRadialGeneralGauss (void)
 Void constructor. More...
 
 GModelSpatialRadialGeneralGauss (const GSkyDir &dir, const double &radius, const double &ridx, const std::string &coordsys="CEL")
 Constructor. More...
 
 GModelSpatialRadialGeneralGauss (const GXmlElement &xml)
 XML constructor. More...
 
 GModelSpatialRadialGeneralGauss (const GModelSpatialRadialGeneralGauss &model)
 Copy constructor. More...
 
virtual ~GModelSpatialRadialGeneralGauss (void)
 Destructor. More...
 
virtual
GModelSpatialRadialGeneralGauss
operator= (const GModelSpatialRadialGeneralGauss &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear radial Gauss model. More...
 
virtual
GModelSpatialRadialGeneralGauss
clone (void) const
 Clone radial Gauss model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual double eval (const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
 Evaluate Generalised Gaussian source model. More...
 
virtual GSkyDir mc (const GEnergy &energy, const GTime &time, GRan &ran) const
 Returns MC sky direction. More...
 
virtual bool contains (const GSkyDir &dir, const double &margin=0.0) const
 Checks where model contains specified sky direction. More...
 
virtual double theta_max (void) const
 Return maximum model radius (in radians) More...
 
virtual void read (const GXmlElement &xml)
 Read model from XML element. More...
 
virtual void write (GXmlElement &xml) const
 Write model into XML element. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print generalised radial Gaussian source information. More...
 
double radius (void) const
 Return radius. More...
 
void radius (const double &radius)
 Set radius. More...
 
double ridx (void) const
 Return ridx. More...
 
void ridx (const double &ridx)
 Set reciprocal index. More...
 
- Public Member Functions inherited from GModelSpatialRadial
 GModelSpatialRadial (void)
 Void constructor. More...
 
 GModelSpatialRadial (const GModelSpatialRadial &model)
 Copy constructor. More...
 
 GModelSpatialRadial (const GXmlElement &xml)
 XML constructor. More...
 
virtual ~GModelSpatialRadial (void)
 Destructor. More...
 
virtual GModelSpatialRadialoperator= (const GModelSpatialRadial &model)
 Assignment operator. More...
 
virtual GClassCode code (void) const
 Return class code. More...
 
virtual bool is_energy_dependent (void) const
 Signals whether radial model is energy dependent. More...
 
virtual bool is_time_dependent (void) const
 Signals whether radial model is time dependent. More...
 
virtual double eval (const GPhoton &photon, const bool &gradients=false) const
 Return model value. More...
 
virtual double mc_norm (const GSkyDir &dir, const double &radius) const
 Return normalization of radial source for Monte Carlo simulations. More...
 
std::string coordsys (void) const
 Return coordinate system. More...
 
const GSkyDirdir (void) const
 Return position of radial spatial model. More...
 
void dir (const GSkyDir &dir)
 Set position of radial spatial model. More...
 
- Public Member Functions inherited from GModelSpatial
 GModelSpatial (void)
 Void constructor. More...
 
 GModelSpatial (const GModelSpatial &model)
 Copy constructor. More...
 
virtual ~GModelSpatial (void)
 Destructor. More...
 
virtual GModelSpatialoperator= (const GModelSpatial &model)
 Assignment operator. More...
 
virtual GModelParoperator[] (const int &index)
 Returns model parameter. More...
 
virtual const GModelParoperator[] (const int &index) const
 Returns model parameter (const version) More...
 
virtual GModelParoperator[] (const std::string &name)
 Returns model parameter. More...
 
virtual const GModelParoperator[] (const std::string &name) const
 Returns model parameter (const version) More...
 
virtual double flux (const GSkyRegion &region, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
 Returns model flux integrated in circular sky region. More...
 
std::string type (void) const
 Return model type. More...
 
void type (const std::string &type)
 Set model type. More...
 
GModelParat (const int &index)
 Returns model parameter. More...
 
const GModelParat (const int &index) const
 Returns model parameter (const version) More...
 
bool has_par (const std::string &name) const
 Checks if parameter name exists. More...
 
bool has_free_pars (void) const
 Checks if the spatial model has free parameters. More...
 
int size (void) const
 Return number of parameters. More...
 
void autoscale (void)
 Autoscale parameters. More...
 
const GSkyRegionregion (void) const
 Return boundary sky region. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelSpatialRadialGeneralGauss &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void update (void) const
 Update precomputation cache. More...
 
virtual void set_region (void) const
 Set boundary sky region. More...
 
- Protected Member Functions inherited from GModelSpatialRadial
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelSpatialRadial &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
bool is_celestial (void) const
 Check if model holds celestial coordinates. More...
 
- Protected Member Functions inherited from GModelSpatial
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelSpatial &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

GModelPar m_radius
 Gaussian width (deg) More...
 
GModelPar m_ridx
 Reciprocal of exponent of the radial profile. More...
 
double m_last_radius
 Last radius. More...
 
double m_inv_radius_rad
 radius(rad)^-1 More...
 
double m_last_ridx
 Last reciprocal radial index. More...
 
double m_inv_ridx
 Spatial profile index. More...
 
double m_value_norm
 1/(2pi radius(rad)^2 ridx Gamma(ridx)) More...
 
- Protected Attributes inherited from GModelSpatialRadial
GModelPar m_lon
 Right Ascension or Galactic longitude (deg) More...
 
GModelPar m_lat
 Declination or Galactic latitude (deg) More...
 
GSkyDir m_dir
 Sky direction representing parameters. More...
 
double m_last_lon
 Last longitude. More...
 
double m_last_lat
 Last latitude. More...
 
- Protected Attributes inherited from GModelSpatial
std::string m_type
 Spatial model type. More...
 
GSkyRegionCircle m_region
 Bounding circle. More...
 
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Generalized radial Gaussian model class.

This class implements the spatial component of the factorised source model for a generalised radial Gaussian source.

Definition at line 54 of file GModelSpatialRadialGeneralGauss.hpp.

Constructor & Destructor Documentation

GModelSpatialRadialGeneralGauss::GModelSpatialRadialGeneralGauss ( void  )

Void constructor.

Constructs empty radial Gaussian model.

Definition at line 71 of file GModelSpatialRadialGeneralGauss.cpp.

References init_members().

Referenced by clone().

GModelSpatialRadialGeneralGauss::GModelSpatialRadialGeneralGauss ( const GSkyDir dir,
const double &  radius,
const double &  ridx,
const std::string &  coordsys = "CEL" 
)

Constructor.

Parameters
[in]dirSky position of Gaussian.
[in]radiusWidth of generalised Gaussian (deg).
[in]ridxReciprocal of exponential index of radial profile.
[in]coordsysCoordinate system (either "CEL" or "GAL")
Exceptions
GException::invalid_argumentInvalid coordsys argument specified.

Constructs a generalised Gaussian spatial model using a sky direction (dir), a Gaussian width parameter radius in degrees and a reciprocal of the exponential index ridx. The coordsys parameter specifies whether the sky direction should be interpreted in the celestial or Galactic coordinate system.

Definition at line 99 of file GModelSpatialRadialGeneralGauss.cpp.

References GModelSpatialRadial::dir(), init_members(), GModelSpatialRadial::m_lat, GModelSpatialRadial::m_lon, GOptimizerPar::name(), radius(), and ridx().

GModelSpatialRadialGeneralGauss::GModelSpatialRadialGeneralGauss ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs a generalised Gaussian spatial model by extracting information from an XML element. See the method read() for more information about the expected structure of the XML element.

Definition at line 137 of file GModelSpatialRadialGeneralGauss.cpp.

References init_members(), and read().

GModelSpatialRadialGeneralGauss::GModelSpatialRadialGeneralGauss ( const GModelSpatialRadialGeneralGauss model)

Copy constructor.

Parameters
[in]modelGeneralised radial Gaussian model.

Definition at line 156 of file GModelSpatialRadialGeneralGauss.cpp.

References copy_members(), and init_members().

GModelSpatialRadialGeneralGauss::~GModelSpatialRadialGeneralGauss ( void  )
virtual

Destructor.

Definition at line 173 of file GModelSpatialRadialGeneralGauss.cpp.

References free_members().

Member Function Documentation

std::string GModelSpatialRadialGeneralGauss::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GModelSpatialRadialGeneralGauss").

Implements GModelSpatialRadial.

Definition at line 121 of file GModelSpatialRadialGeneralGauss.hpp.

void GModelSpatialRadialGeneralGauss::clear ( void  )
virtual
GModelSpatialRadialGeneralGauss * GModelSpatialRadialGeneralGauss::clone ( void  ) const
virtual

Clone radial Gauss model.

Implements GModelSpatialRadial.

Definition at line 248 of file GModelSpatialRadialGeneralGauss.cpp.

References GModelSpatialRadialGeneralGauss().

bool GModelSpatialRadialGeneralGauss::contains ( const GSkyDir dir,
const double &  margin = 0.0 
) const
virtual

Checks where model contains specified sky direction.

Parameters
[in]dirSky direction.
[in]marginMargin to be added to sky direction (deg)
Returns
True if the model contains the sky direction.

Signals whether a sky direction is contained in the radial gauss model.

Implements GModelSpatialRadial.

Definition at line 386 of file GModelSpatialRadialGeneralGauss.cpp.

References gammalib::deg2rad, GModelSpatialRadial::dir(), GSkyDir::dist(), and theta_max().

void GModelSpatialRadialGeneralGauss::copy_members ( const GModelSpatialRadialGeneralGauss model)
protected

Copy class members.

Parameters
[in]modelGeneralised radial Gaussian spatial model.

We do not have to push back the members on the parameter stack as this should have been done by init_members() that was called before. Otherwise we would have sigma twice on the stack.

Definition at line 588 of file GModelSpatialRadialGeneralGauss.cpp.

References m_inv_radius_rad, m_inv_ridx, m_last_radius, m_last_ridx, m_radius, m_ridx, GModelSpatial::m_type, and m_value_norm.

Referenced by GModelSpatialRadialGeneralGauss(), and operator=().

double GModelSpatialRadialGeneralGauss::eval ( const double &  theta,
const GEnergy energy,
const GTime time,
const bool &  gradients = false 
) const
virtual

Evaluate Generalised Gaussian source model.

Parameters
[in]thetaAngular distance from source centre (radians).
[in]energyPhoton energy (not used).
[in]timePhoton arrival time (not used).
[in]gradientsCompute gradients?
Returns
Model value ( \({\rm sr}^{-1}\)).

Evaluates the spatial component for a Generalised Gaussian source model using

\[ M_{\rm S}({\bf p} | E, t) = M_{\rm S}(\theta) = \frac{1}{2 \pi r^2 \eta \Gamma(\eta)} \exp \left(-(\frac{\theta}{r})^1/\eta \right) \]

where

  • \(\theta\) is the angular separation from the centre of the model, and
  • \(r\) is the Generalised Gaussian radius.
  • \(\eta\) is the reciprocal of the radial profile exponent.

If gradients is true the method will also compute parameter gradients

Note that the model normalisation is only correct in the small angle approximation and for \(\eta\) order unity or smaller.

Implements GModelSpatialRadial.

Definition at line 284 of file GModelSpatialRadialGeneralGauss.cpp.

References exp(), G_EVAL, gammalib::is_infinite(), gammalib::is_notanumber(), m_inv_radius_rad, m_inv_ridx, GModelSpatial::m_pars, m_value_norm, pow(), GEnergy::print(), GTime::print(), gammalib::str(), update(), and gammalib::warning().

Referenced by mc().

void GModelSpatialRadialGeneralGauss::free_members ( void  )
protected

Delete class members.

Definition at line 610 of file GModelSpatialRadialGeneralGauss.cpp.

Referenced by clear(), operator=(), and ~GModelSpatialRadialGeneralGauss().

void GModelSpatialRadialGeneralGauss::init_members ( void  )
protected
GSkyDir GModelSpatialRadialGeneralGauss::mc ( const GEnergy energy,
const GTime time,
GRan ran 
) const
virtual

Returns MC sky direction.

Parameters
[in]energyPhoton energy.
[in]timePhoton arrival time.
[in,out]ranRandom number generator.
Returns
Sky direction.

Draws an arbitrary sky direction from the 2D Generalised Gaussian distribution as function of the photon energy and arrival time.

Todo:
This method is only valid in the small angle approximation.

Implements GModelSpatialRadial.

Definition at line 328 of file GModelSpatialRadialGeneralGauss.cpp.

References GModelSpatialRadial::dir(), eval(), G_MC, m_value_norm, gammalib::rad2deg, GSkyDir::rotate_deg(), sin(), theta_max(), GRan::uniform(), and update().

GModelSpatialRadialGeneralGauss & GModelSpatialRadialGeneralGauss::operator= ( const GModelSpatialRadialGeneralGauss model)
virtual

Assignment operator.

Parameters
[in]modelGeneralised radial Gaussian model.
Returns
Radial Generalised radial Gaussian model.

Definition at line 195 of file GModelSpatialRadialGeneralGauss.cpp.

References copy_members(), free_members(), init_members(), and GModelSpatialRadial::operator=().

std::string GModelSpatialRadialGeneralGauss::print ( const GChatter chatter = NORMAL) const
virtual

Print generalised radial Gaussian source information.

Parameters
[in]chatterChattiness.
Returns
String containing model information.

Implements GModelSpatialRadial.

Definition at line 499 of file GModelSpatialRadialGeneralGauss.cpp.

References GModelSpatial::m_pars, gammalib::parformat(), SILENT, GModelSpatial::size(), and gammalib::str().

double GModelSpatialRadialGeneralGauss::radius ( void  ) const
inline

Return radius.

Returns
Radius (deg).

Returns the radius in degrees.

Definition at line 135 of file GModelSpatialRadialGeneralGauss.hpp.

References m_radius, and GOptimizerPar::value().

Referenced by GModelSpatialRadialGeneralGauss(), read(), theta_max(), update(), and write().

void GModelSpatialRadialGeneralGauss::radius ( const double &  radius)
inline

Set radius.

Parameters
[in]radius(deg).

Sets the radius in degrees.

Definition at line 148 of file GModelSpatialRadialGeneralGauss.hpp.

References m_radius, and GOptimizerPar::value().

void GModelSpatialRadialGeneralGauss::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.

Reads the generalised radial Gaussian model information from an XML element. The XML element shall have either the format

<spatialModel type="RadialGeneralGaussian">
  <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="Radius"  scale="1.0" value="0.45"    min="0.01" max="10"  free="1"/>
  <parameter name="R_Index" scale="1.0" value="0.5"     min="0.01" max="10"  free="1"/>
</spatialModel>

or

<spatialModel type="RadialGeneralGaussian">
  <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="Radius"  scale="1.0" value="0.45"    min="0.01" max="10"  free="1"/>
  <parameter name="R_Index" scale="1.0" value="0.5"     min="0.01" max="10"  free="1"/>
</spatialModel>
Todo:
Implement a test of the radius and radius boundary. The sigma and sigma minimum should be >0.

Reimplemented from GModelSpatialRadial.

Definition at line 438 of file GModelSpatialRadialGeneralGauss.cpp.

References G_READ, m_radius, m_ridx, GOptimizerPar::name(), radius(), GModelSpatialRadial::read(), GModelPar::read(), ridx(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().

Referenced by GModelSpatialRadialGeneralGauss().

double GModelSpatialRadialGeneralGauss::ridx ( void  ) const
inline

Return ridx.

Returns
Reciprocal of the radial profile index.

Returns the reciprocal of the radial profile index.

Definition at line 162 of file GModelSpatialRadialGeneralGauss.hpp.

References m_ridx, and GOptimizerPar::value().

Referenced by GModelSpatialRadialGeneralGauss(), read(), update(), and write().

void GModelSpatialRadialGeneralGauss::ridx ( const double &  ridx)
inline

Set reciprocal index.

Parameters
[in]ridxReciprocal of the radial profile index.

Sets the reciprocal index of the radial profile.

Definition at line 175 of file GModelSpatialRadialGeneralGauss.hpp.

References m_ridx, and GOptimizerPar::value().

void GModelSpatialRadialGeneralGauss::set_region ( void  ) const
protectedvirtual
double GModelSpatialRadialGeneralGauss::theta_max ( void  ) const
virtual

Return maximum model radius (in radians)

Returns \(5 \sigma\) as approximate edge of the Gaussian. This limit is of course arbitrary, but allows to limit the integration region for response computation.

Implements GModelSpatialRadial.

Definition at line 404 of file GModelSpatialRadialGeneralGauss.cpp.

References gammalib::deg2rad, and radius().

Referenced by contains(), and mc().

void GModelSpatialRadialGeneralGauss::update ( void  ) const
protected
void GModelSpatialRadialGeneralGauss::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element into which model information is written.

Writes the radial disk model information into an XML element. The XML element will have the format

<spatialModel type="RadialGeneralGaussian">
  <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="Sigma"   scale="1.0" value="0.45"    min="0.01" max="10"  free="1"/>
  <parameter name="R_Index" scale="1.0" value="0.5"     min="0.01" max="10"  free="1"/>
</spatialModel>

Reimplemented from GModelSpatialRadial.

Definition at line 475 of file GModelSpatialRadialGeneralGauss.cpp.

References G_WRITE, m_radius, m_ridx, GOptimizerPar::name(), radius(), ridx(), GModelSpatialRadial::write(), GModelPar::write(), and gammalib::xml_need_par().

Member Data Documentation

double GModelSpatialRadialGeneralGauss::m_inv_radius_rad
mutableprotected

radius(rad)^-1

Definition at line 108 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), eval(), init_members(), and update().

double GModelSpatialRadialGeneralGauss::m_inv_ridx
mutableprotected

Spatial profile index.

Definition at line 110 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), eval(), init_members(), and update().

double GModelSpatialRadialGeneralGauss::m_last_radius
mutableprotected

Last radius.

Definition at line 107 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), init_members(), and update().

double GModelSpatialRadialGeneralGauss::m_last_ridx
mutableprotected

Last reciprocal radial index.

Definition at line 109 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), init_members(), and update().

GModelPar GModelSpatialRadialGeneralGauss::m_radius
protected

Gaussian width (deg)

Definition at line 103 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), init_members(), radius(), read(), set_region(), and write().

GModelPar GModelSpatialRadialGeneralGauss::m_ridx
protected

Reciprocal of exponent of the radial profile.

Definition at line 104 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), init_members(), read(), ridx(), and write().

double GModelSpatialRadialGeneralGauss::m_value_norm
mutableprotected

1/(2pi radius(rad)^2 ridx Gamma(ridx))

Definition at line 111 of file GModelSpatialRadialGeneralGauss.hpp.

Referenced by copy_members(), eval(), init_members(), mc(), and update().


The documentation for this class was generated from the following files: