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

#include <GModelSpatialEllipticalDisk.hpp>

Inheritance diagram for GModelSpatialEllipticalDisk:
GModelSpatialElliptical GModelSpatial GBase

Public Member Functions

 GModelSpatialEllipticalDisk (void)
 Void constructor. More...
 
 GModelSpatialEllipticalDisk (const GSkyDir &dir, const double &semimajor, const double &semiminor, const double &posangle, const std::string &coordsys="CEL")
 Disk constructor. More...
 
 GModelSpatialEllipticalDisk (const GXmlElement &xml)
 XML constructor. More...
 
 GModelSpatialEllipticalDisk (const GModelSpatialEllipticalDisk &model)
 Copy constructor. More...
 
virtual ~GModelSpatialEllipticalDisk (void)
 Destructor. More...
 
virtual
GModelSpatialEllipticalDisk
operator= (const GModelSpatialEllipticalDisk &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear elliptical disk model. More...
 
virtual
GModelSpatialEllipticalDisk
clone (void) const
 Clone elliptical disk model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
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) 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 information. More...
 
- Public Member Functions inherited from GModelSpatialElliptical
 GModelSpatialElliptical (void)
 Void constructor. More...
 
 GModelSpatialElliptical (const GModelSpatialElliptical &model)
 Copy constructor. More...
 
 GModelSpatialElliptical (const GXmlElement &xml)
 XML constructor. More...
 
virtual ~GModelSpatialElliptical (void)
 Destructor. More...
 
virtual GModelSpatialEllipticaloperator= (const GModelSpatialElliptical &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 elliptical source for Monte Carlo simulations. More...
 
std::string coordsys (void) const
 Return coordinate system. More...
 
const GSkyDirdir (void) const
 Return position of elliptical spatial model. More...
 
void dir (const GSkyDir &dir)
 Set position of radial spatial model. More...
 
double posangle (void) const
 Return Position Angle of model. More...
 
void posangle (const double &posangle)
 Set Position Angle of model. More...
 
double semiminor (void) const
 Return semi-minor axis of ellipse. More...
 
double semimajor (void) const
 Return semi-major axis of ellipse. More...
 
void semiminor (const double &semiminor)
 Set semi-minor axis of ellipse. More...
 
void semimajor (const double &semimajor)
 Set semi-major axis of ellipse. 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 within 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 GModelSpatialEllipticalDisk &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 GModelSpatialElliptical
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelSpatialElliptical &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

double m_last_semiminor
 Last semi-minor axis. More...
 
double m_last_semimajor
 Last semi-major axis. More...
 
double m_semiminor_rad
 Radius in radians. More...
 
double m_semimajor_rad
 Radius in radians. More...
 
double m_norm
 Normalization. More...
 
- Protected Attributes inherited from GModelSpatialElliptical
GModelPar m_lon
 Right Ascension or Galactic longitude (deg) More...
 
GModelPar m_lat
 Declination or Galactic latitude (deg) More...
 
GModelPar m_posangle
 Position angle from North, counterclockwise (deg) More...
 
GModelPar m_semiminor
 Semi-minor axis of ellipse (deg) More...
 
GModelPar m_semimajor
 Semi-major axis of ellipse (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

Definition at line 54 of file GModelSpatialEllipticalDisk.hpp.

Constructor & Destructor Documentation

GModelSpatialEllipticalDisk::GModelSpatialEllipticalDisk ( void  )

Void constructor.

Definition at line 67 of file GModelSpatialEllipticalDisk.cpp.

References init_members().

Referenced by clone().

GModelSpatialEllipticalDisk::GModelSpatialEllipticalDisk ( const GSkyDir dir,
const double &  semimajor,
const double &  semiminor,
const double &  posangle,
const std::string &  coordsys = "CEL" 
)

Disk constructor.

Parameters
[in]dirSky position of disk centre.
[in]semimajorSemi-major axis (degrees).
[in]semiminorSemi-minor axis (degrees).
[in]posanglePosition angle of semi-major axis (degrees).
[in]coordsysCoordinate system (either "CEL" or "GAL")
Exceptions
GException::invalid_argumentInvalid coordsys argument specified.

Construct elliptical disk model from sky position of the ellipse centre (dir), the semimajor and semiminor axes, and the position angle (posangle). The coordsys parameter specifies whether the sky direction should be interpreted in the celestial or Galactic coordinate system.

Definition at line 96 of file GModelSpatialEllipticalDisk.cpp.

References GModelSpatialElliptical::dir(), G_CONSTRUCTOR, init_members(), GModelSpatialElliptical::m_lat, GModelSpatialElliptical::m_lon, GOptimizerPar::name(), GModelSpatialElliptical::posangle(), GModelSpatialElliptical::semimajor(), and GModelSpatialElliptical::semiminor().

GModelSpatialEllipticalDisk::GModelSpatialEllipticalDisk ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs elliptical disk 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 144 of file GModelSpatialEllipticalDisk.cpp.

References init_members(), and read().

GModelSpatialEllipticalDisk::GModelSpatialEllipticalDisk ( const GModelSpatialEllipticalDisk model)

Copy constructor.

Parameters
[in]modelElliptical disk model.

Definition at line 163 of file GModelSpatialEllipticalDisk.cpp.

References copy_members(), and init_members().

GModelSpatialEllipticalDisk::~GModelSpatialEllipticalDisk ( void  )
virtual

Destructor.

Definition at line 180 of file GModelSpatialEllipticalDisk.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelSpatialElliptical.

Definition at line 114 of file GModelSpatialEllipticalDisk.hpp.

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

Clone elliptical disk model.

Returns
Pointer to deep copy of elliptical disk model.

Implements GModelSpatialElliptical.

Definition at line 257 of file GModelSpatialEllipticalDisk.cpp.

References GModelSpatialEllipticalDisk().

bool GModelSpatialEllipticalDisk::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 elliptical disk model.

Todo:
Implement correct evaluation of effective ellipse radius.

Implements GModelSpatialElliptical.

Definition at line 426 of file GModelSpatialEllipticalDisk.cpp.

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

void GModelSpatialEllipticalDisk::copy_members ( const GModelSpatialEllipticalDisk model)
protected

Copy class members.

Parameters
[in]modelElliptical disk 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 the radius twice on the stack.

Definition at line 614 of file GModelSpatialEllipticalDisk.cpp.

References m_last_semimajor, m_last_semiminor, m_norm, m_semimajor_rad, m_semiminor_rad, and GModelSpatial::m_type.

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

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

Evaluate function (in units of sr^-1)

Parameters
[in]thetaAngular distance from disk centre (radians).
[in]posanglePosition angle (counterclockwise from North) (radians).
[in]energyPhoton energy.
[in]timePhoton arrival time.
[in]gradientsCompute gradients?
Returns
Model value.

Evaluates the spatial component for an elliptical disk source model. The disk source model is an elliptical function \(S_{\rm p}(\theta, \phi | E, t)\), where \(\theta\) is the angular separation between elliptical disk centre and the actual location and \(\phi\) the position angle with respect to the ellipse centre, counted counterclockwise from North.

The function \(f(\theta, \phi)\) is given by

\[ S_{\rm p}(\theta, \phi | E, t) = \left \{ \begin{array}{l l} {\tt m\_norm} & \mbox{if} \, \, \theta \le \theta_0 \\ \\ 0 & \mbox{else} \end{array} \right . \]

where \(\theta_0\) is the effective radius of the ellipse on the sphere given by

\[\theta_0\ = \frac{ab}{\sqrt{b^2 \cos^2(\phi-\phi_0) + a^2 \sin^2(\phi-\phi_0)}}\]

and \(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.

The normalisation constant \({\tt m\_norm}\) which is the inverse of the solid angle subtended by an ellipse is given by

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:
Quote formula for ellipse solid angle

(see the update() method).

Implements GModelSpatialElliptical.

Definition at line 317 of file GModelSpatialEllipticalDisk.cpp.

References cos(), gammalib::deg2rad, gammalib::is_infinite(), gammalib::is_notanumber(), m_norm, GModelSpatialElliptical::m_posangle, m_semimajor_rad, m_semiminor_rad, sin(), sqrt(), theta_max(), update(), and GOptimizerPar::value().

void GModelSpatialEllipticalDisk::free_members ( void  )
protected

Delete class members.

Definition at line 634 of file GModelSpatialEllipticalDisk.cpp.

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

void GModelSpatialEllipticalDisk::init_members ( void  )
protected
GSkyDir GModelSpatialEllipticalDisk::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 position from the 2D disk distribution.

Todo:
Test function

Implements GModelSpatialElliptical.

Definition at line 377 of file GModelSpatialEllipticalDisk.cpp.

References gammalib::acos(), cos(), gammalib::deg2rad, GPhoton::dir(), GModelSpatialElliptical::dir(), GPhoton::energy(), GModelSpatialElliptical::eval(), gammalib::rad2deg, GSkyDir::rotate_deg(), GModelSpatialElliptical::semimajor(), GPhoton::time(), GRan::uniform(), and update().

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

Assignment operator.

Parameters
[in]modelElliptical disk model.
Returns
Elliptical disk model.

Definition at line 202 of file GModelSpatialEllipticalDisk.cpp.

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

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

Print information.

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

Implements GModelSpatialElliptical.

Definition at line 553 of file GModelSpatialEllipticalDisk.cpp.

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

void GModelSpatialEllipticalDisk::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 elliptical disk model information from an XML element. The XML element shall have either the format

<spatialModel type="EllipticalDisk">
  <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="EllipticalDisk">
  <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>
Todo:
Implement a test of the ellipse boundary. The axes and axes minimum should be >0.

Reimplemented from GModelSpatialElliptical.

Definition at line 488 of file GModelSpatialEllipticalDisk.cpp.

References G_READ, GModelSpatialElliptical::m_semimajor, GModelSpatialElliptical::m_semiminor, GOptimizerPar::name(), GModelSpatialElliptical::read(), GModelPar::read(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().

Referenced by GModelSpatialEllipticalDisk().

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

Return maximum model radius (in radians)

Returns
Returns maximum model radius.

Implements GModelSpatialElliptical.

Definition at line 442 of file GModelSpatialEllipticalDisk.cpp.

References gammalib::deg2rad, GModelSpatialElliptical::semimajor(), and GModelSpatialElliptical::semiminor().

Referenced by contains(), and eval().

void GModelSpatialEllipticalDisk::update ( void  ) const
protected

Update precomputation cache.

Computes the normalization

\[ {\tt m\_norm} = \frac{1}{2 \pi (1 - \cos a) (1 - \cos b)} \]

Todo:
check this formula

Definition at line 651 of file GModelSpatialEllipticalDisk.cpp.

References cos(), gammalib::deg2rad, m_last_semimajor, m_last_semiminor, m_norm, m_semimajor_rad, m_semiminor_rad, GModelSpatialElliptical::semimajor(), GModelSpatialElliptical::semiminor(), sqrt(), and gammalib::twopi.

Referenced by eval(), and mc().

void GModelSpatialEllipticalDisk::write ( GXmlElement xml) const
virtual

Write model into XML element.

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

Write the elliptical disk model information into an XML element. The XML element will have the format

<spatialModel type="EllipticalDisk">
  <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 526 of file GModelSpatialEllipticalDisk.cpp.

References G_WRITE, GModelSpatialElliptical::m_semimajor, GModelSpatialElliptical::m_semiminor, GOptimizerPar::name(), GModelSpatial::type(), GModelSpatialElliptical::write(), GModelPar::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().

Member Data Documentation

double GModelSpatialEllipticalDisk::m_last_semimajor
mutableprotected

Last semi-major axis.

Definition at line 101 of file GModelSpatialEllipticalDisk.hpp.

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

double GModelSpatialEllipticalDisk::m_last_semiminor
mutableprotected

Last semi-minor axis.

Definition at line 100 of file GModelSpatialEllipticalDisk.hpp.

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

double GModelSpatialEllipticalDisk::m_norm
mutableprotected

Normalization.

Definition at line 104 of file GModelSpatialEllipticalDisk.hpp.

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

double GModelSpatialEllipticalDisk::m_semimajor_rad
mutableprotected

Radius in radians.

Definition at line 103 of file GModelSpatialEllipticalDisk.hpp.

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

double GModelSpatialEllipticalDisk::m_semiminor_rad
mutableprotected

Radius in radians.

Definition at line 102 of file GModelSpatialEllipticalDisk.hpp.

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


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