GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialGauss Class Reference

Radial Gaussian model class. More...

#include <GModelSpatialRadialGauss.hpp>

Inheritance diagram for GModelSpatialRadialGauss:
GModelSpatialRadial GModelSpatial GBase

Public Member Functions

 GModelSpatialRadialGauss (void)
 Void constructor. More...
 
 GModelSpatialRadialGauss (const bool &dummy, const std::string &type)
 Model type constructor. More...
 
 GModelSpatialRadialGauss (const GSkyDir &dir, const double &sigma)
 Constructor. More...
 
 GModelSpatialRadialGauss (const GXmlElement &xml)
 XML constructor. More...
 
 GModelSpatialRadialGauss (const GModelSpatialRadialGauss &model)
 Copy constructor. More...
 
virtual ~GModelSpatialRadialGauss (void)
 Destructor. More...
 
virtual GModelSpatialRadialGaussoperator= (const GModelSpatialRadialGauss &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear radial Gauss model. More...
 
virtual GModelSpatialRadialGaussclone (void) const
 Clone radial Gauss model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual std::string type (void) const
 Return model type. More...
 
virtual double eval (const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
 Evaluate function. 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 GSkyRegionregion (void) const
 Return boundary sky region. 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 Gaussian source information. More...
 
double sigma (void) const
 Return Gaussian sigma. More...
 
void sigma (const double &sigma)
 Set Gaussian sigma. 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 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...
 
double ra (void) const
 Return Right Ascencion of model centre. More...
 
double dec (void) const
 Return Declination of model centre. More...
 
void ra (const double &ra)
 Set Right Ascencion of model centre. More...
 
void dec (const double &dec)
 Set Declination of model centre. More...
 
GSkyDir dir (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...
 
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...
 
double flux (const GSkyRegion *reg, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
 Returns model flux integrated in circular 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 GModelSpatialRadialGauss &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
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...
 
- 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

std::string m_type
 Model type. More...
 
GModelPar m_sigma
 Gaussian width (deg) More...
 
GSkyRegionCircle m_region
 Bounding circle. More...
 
- Protected Attributes inherited from GModelSpatialRadial
GModelPar m_ra
 Right Ascension (deg) More...
 
GModelPar m_dec
 Declination (deg) More...
 
- Protected Attributes inherited from GModelSpatial
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Radial Gaussian model class.

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

Definition at line 49 of file GModelSpatialRadialGauss.hpp.

Constructor & Destructor Documentation

GModelSpatialRadialGauss::GModelSpatialRadialGauss ( void  )

Void constructor.

Constructs empty radial Gaussian model.

Definition at line 69 of file GModelSpatialRadialGauss.cpp.

References init_members().

Referenced by clone().

GModelSpatialRadialGauss::GModelSpatialRadialGauss ( const bool &  dummy,
const std::string &  type 
)

Model type constructor.

Parameters
[in]dummyDummy flag.
[in]typeModel type.

Constructs empty radial Gaussian model by specifying a model type.

Definition at line 87 of file GModelSpatialRadialGauss.cpp.

References init_members(), m_type, and type().

GModelSpatialRadialGauss::GModelSpatialRadialGauss ( const GSkyDir dir,
const double &  sigma 
)

Constructor.

Parameters
[in]dirSky position of Gaussian.
[in]sigmaWidth of Gaussian (in degrees).

Constructs a Gaussian spatial model using a sky direction (dir) and a Gaussian width parameter sigma in degrees.

Definition at line 111 of file GModelSpatialRadialGauss.cpp.

References GModelSpatialRadial::dir(), init_members(), and sigma().

GModelSpatialRadialGauss::GModelSpatialRadialGauss ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs a 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 136 of file GModelSpatialRadialGauss.cpp.

References init_members(), and read().

GModelSpatialRadialGauss::GModelSpatialRadialGauss ( const GModelSpatialRadialGauss model)

Copy constructor.

Parameters
[in]modelRadial Gaussian model.

Definition at line 155 of file GModelSpatialRadialGauss.cpp.

References copy_members(), and init_members().

GModelSpatialRadialGauss::~GModelSpatialRadialGauss ( void  )
virtual

Destructor.

Definition at line 172 of file GModelSpatialRadialGauss.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelSpatialRadial.

Definition at line 107 of file GModelSpatialRadialGauss.hpp.

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

Clone radial Gauss model.

Implements GModelSpatialRadial.

Definition at line 247 of file GModelSpatialRadialGauss.cpp.

References GModelSpatialRadialGauss().

bool GModelSpatialRadialGauss::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 (degrees)
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 351 of file GModelSpatialRadialGauss.cpp.

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

void GModelSpatialRadialGauss::copy_members ( const GModelSpatialRadialGauss model)
protected

Copy class members.

Parameters
[in]modelGaussian 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 549 of file GModelSpatialRadialGauss.cpp.

References m_region, m_sigma, and m_type.

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

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

Evaluate function.

Parameters
[in]thetaAngular distance from Gaussian centre (radians).
[in]energyPhoton energy.
[in]timePhoton arrival time.
[in]gradientsCompute gradients?
Returns
Model value.

Evaluates the spatial component for a Gaussian source model using

\[ S_{\rm p}(\vec{p} | E, t) = \frac{1}{2 \pi \sigma^2} \exp \left(-\frac{1}{2}\frac{\theta^2}{\sigma^2} \right) \]

where

  • \(\theta\) is the angular separation from the centre of the model, and
  • \(\sigma\) is the Gaussian width.

The method will not compute analytical parameter gradients, even if the gradients argument is set to true. Radial disk parameter gradients need to be computed numerically.

Todo:
The Gaussian function is only correct in the small angle approximation.

Implements GModelSpatialRadial.

Definition at line 282 of file GModelSpatialRadialGauss.cpp.

References gammalib::deg2rad, exp(), gammalib::is_infinite(), gammalib::is_notanumber(), sigma(), and gammalib::twopi.

void GModelSpatialRadialGauss::free_members ( void  )
protected

Delete class members.

Definition at line 564 of file GModelSpatialRadialGauss.cpp.

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

void GModelSpatialRadialGauss::init_members ( void  )
protected

Initialise class members.

Note that this model implements no gradients, as spatial models will always require numerical gradient computations. The minimum Gaussian width is set to 1 arcsec.

Definition at line 513 of file GModelSpatialRadialGauss.cpp.

References GSkyRegionCircle::clear(), GOptimizerPar::clear(), GOptimizerPar::free(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), GModelSpatial::m_pars, m_region, m_sigma, m_type, GOptimizerPar::min(), GOptimizerPar::name(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().

Referenced by clear(), GModelSpatialRadialGauss(), and operator=().

GSkyDir GModelSpatialRadialGauss::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 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 325 of file GModelSpatialRadialGauss.cpp.

References GRan::chisq2(), GModelSpatialRadial::dir(), GSkyDir::rotate_deg(), sigma(), and GRan::uniform().

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

Assignment operator.

Parameters
[in]modelRadial Gaussian model.
Returns
Radial Gaussian model.

Definition at line 194 of file GModelSpatialRadialGauss.cpp.

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

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

Print Gaussian source information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing model information.

Implements GModelSpatialRadial.

Definition at line 475 of file GModelSpatialRadialGauss.cpp.

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

void GModelSpatialRadialGauss::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.
Exceptions
GException::model_invalid_parnumInvalid number of model parameters found in XML element.
GException::model_invalid_parnamesInvalid model parameter names found in XML element.

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

<spatialModel type="RadialGaussian">
  <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"/>
</spatialModel>

or

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

Reimplemented from GModelSpatialRadial.

Definition at line 406 of file GModelSpatialRadialGauss.cpp.

References GXmlNode::elements(), G_READ, m_sigma, GOptimizerPar::name(), GModelSpatialRadial::read(), GModelPar::read(), sigma(), and gammalib::xml_get_par().

Referenced by GModelSpatialRadialGauss().

GSkyRegion * GModelSpatialRadialGauss::region ( void  ) const
inlinevirtual

Return boundary sky region.

Returns
Boundary sky region.

Returns a sky region that fully encloses the spatial model component.

Implements GModelSpatialRadial.

Definition at line 164 of file GModelSpatialRadialGauss.hpp.

References m_region, and set_region().

void GModelSpatialRadialGauss::set_region ( void  ) const
protected
double GModelSpatialRadialGauss::sigma ( void  ) const
inline

Return Gaussian sigma.

Returns
Gaussian sigma (degrees).

Returns the Gaussian sigma in degrees.

Definition at line 135 of file GModelSpatialRadialGauss.hpp.

References m_sigma, and GOptimizerPar::value().

Referenced by eval(), GModelSpatialRadialGauss(), mc(), read(), theta_max(), and write().

void GModelSpatialRadialGauss::sigma ( const double &  sigma)
inline

Set Gaussian sigma.

Parameters
[in]sigmaGaussian sigma (degrees).

Sets the Gaussian sigma in degrees.

Definition at line 149 of file GModelSpatialRadialGauss.hpp.

References m_sigma, and GOptimizerPar::value().

double GModelSpatialRadialGauss::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 369 of file GModelSpatialRadialGauss.cpp.

References gammalib::deg2rad, and sigma().

Referenced by contains().

std::string GModelSpatialRadialGauss::type ( void  ) const
inlinevirtual

Return model type.

Returns
Model type.

Returns the type of the radial Gauss model.

Implements GModelSpatialRadial.

Definition at line 121 of file GModelSpatialRadialGauss.hpp.

References m_type.

Referenced by GModelSpatialRadialGauss().

void GModelSpatialRadialGauss::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element into which model information is written.
Exceptions
GException::model_invalid_spatialExisting XML element is not of type 'GaussFunction'
GException::model_invalid_parnumInvalid number of model parameters found in XML element.
GException::model_invalid_parnamesInvalid model parameter names found in XML element.

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

<spatialModel type="RadialGaussian">
  <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"/>
</spatialModel>

Reimplemented from GModelSpatialRadial.

Definition at line 453 of file GModelSpatialRadialGauss.cpp.

References G_WRITE, m_sigma, GOptimizerPar::name(), sigma(), GModelSpatialRadial::write(), GModelPar::write(), and gammalib::xml_need_par().

Member Data Documentation

GSkyRegionCircle GModelSpatialRadialGauss::m_region
mutableprotected

Bounding circle.

Definition at line 97 of file GModelSpatialRadialGauss.hpp.

Referenced by copy_members(), init_members(), region(), and set_region().

GModelPar GModelSpatialRadialGauss::m_sigma
protected

Gaussian width (deg)

Definition at line 96 of file GModelSpatialRadialGauss.hpp.

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

std::string GModelSpatialRadialGauss::m_type
protected

Model type.

Definition at line 95 of file GModelSpatialRadialGauss.hpp.

Referenced by copy_members(), GModelSpatialRadialGauss(), init_members(), and type().


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