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

Abstract elliptical spatial model base class. More...

#include <GModelSpatialElliptical.hpp>

Inheritance diagram for GModelSpatialElliptical:
GModelSpatial GBase GModelSpatialEllipticalDisk GModelSpatialEllipticalGauss

Public Member Functions

 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 void clear (void)=0
 Clear object. More...
 
virtual GModelSpatialEllipticalclone (void) const =0
 Clones object. More...
 
virtual std::string classname (void) const =0
 Return class name. More...
 
virtual std::string type (void) const =0
 
virtual double eval (const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
 
virtual GSkyDir mc (const GEnergy &energy, const GTime &time, GRan &ran) const =0
 
virtual bool contains (const GSkyDir &dir, const double &margin=0.0) const =0
 
virtual double theta_max (void) const =0
 
virtual GSkyRegionregion (void) const =0
 
virtual std::string print (const GChatter &chatter=NORMAL) const =0
 Print content of object. 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...
 
virtual void read (const GXmlElement &xml)
 Read model from XML element. More...
 
virtual void write (GXmlElement &xml) const
 Write model into XML element. 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...
 
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...
 
GSkyDir dir (void) const
 Return position of elliptical spatial model. More...
 
void dir (const GSkyDir &dir)
 Set position of elliptical 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 GModelSpatialElliptical &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

GModelPar m_ra
 Right Ascension (deg) More...
 
GModelPar m_dec
 Declination (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...
 
- Protected Attributes inherited from GModelSpatial
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Abstract elliptical spatial model base class.

This class defines the interface for an elliptical model as spatial component of the factorized source model. Typical examples of elliptical components are elliptical Disk, Gaussian or Shell shaped sources.

Definition at line 52 of file GModelSpatialElliptical.hpp.

Constructor & Destructor Documentation

GModelSpatialElliptical::GModelSpatialElliptical ( void  )

Void constructor.

Definition at line 54 of file GModelSpatialElliptical.cpp.

References init_members().

GModelSpatialElliptical::GModelSpatialElliptical ( const GModelSpatialElliptical model)

Copy constructor.

Parameters
[in]modelElliptical spatial model.

Definition at line 91 of file GModelSpatialElliptical.cpp.

References copy_members(), and init_members().

GModelSpatialElliptical::GModelSpatialElliptical ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs an elliptical spatial model component 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 73 of file GModelSpatialElliptical.cpp.

References init_members(), and read().

GModelSpatialElliptical::~GModelSpatialElliptical ( void  )
virtual

Destructor.

Definition at line 108 of file GModelSpatialElliptical.cpp.

References free_members().

Member Function Documentation

virtual std::string GModelSpatialElliptical::classname ( void  ) const
pure virtual

Return class name.

Returns
String containing the class name.

Returns the class name for non-abstract classes in a human readable way.

Implements GModelSpatial.

Implemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

virtual void GModelSpatialElliptical::clear ( void  )
pure virtual

Clear object.

Sets the object to a clean initial state. After calling the method the object will be in the same state as it were if an empty instance of the object would have been created.

Implements GModelSpatial.

Implemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

virtual GModelSpatialElliptical* GModelSpatialElliptical::clone ( void  ) const
pure virtual

Clones object.

Returns
Pointer to deep copy of object.

Creates a deep copy of the object and returns a pointer to the object.

Implements GModelSpatial.

Implemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

GClassCode GModelSpatialElliptical::code ( void  ) const
inlinevirtual

Return class code.

Returns
GModelSpatialElliptical.

Returns the code GModelSpatialElliptical of the class.

Implements GModelSpatial.

Definition at line 128 of file GModelSpatialElliptical.hpp.

References GMODEL_SPATIAL_ELLIPTICAL.

virtual bool GModelSpatialElliptical::contains ( const GSkyDir dir,
const double &  margin = 0.0 
) const
pure virtual
void GModelSpatialElliptical::copy_members ( const GModelSpatialElliptical model)
protected

Copy class members.

Parameters
[in]modelRadial spatial model.

Definition at line 429 of file GModelSpatialElliptical.cpp.

References m_dec, GModelSpatial::m_pars, m_posangle, m_ra, m_semimajor, and m_semiminor.

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

double GModelSpatialElliptical::dec ( void  ) const
inline

Return Declination of model centre.

Returns
Declination of model centre (degrees).

Returns the Declination of the model centre in degrees.

Definition at line 171 of file GModelSpatialElliptical.hpp.

References m_dec, and GOptimizerPar::value().

Referenced by dir(), GCTAResponseIrf::nroi_elliptical(), read(), and write().

void GModelSpatialElliptical::dec ( const double &  dec)
inline

Set Declination of model centre.

Parameters
[in]decDeclination (degrees).

Sets the Declination of the model centre in degrees.

Definition at line 185 of file GModelSpatialElliptical.hpp.

References m_dec, and GOptimizerPar::value().

void GModelSpatialElliptical::dir ( const GSkyDir dir)

Set position of elliptical spatial model.

Definition at line 340 of file GModelSpatialElliptical.cpp.

References GSkyDir::dec_deg(), m_dec, m_ra, GSkyDir::ra_deg(), and GOptimizerPar::value().

virtual double GModelSpatialElliptical::eval ( const double &  theta,
const double &  posangle,
const GEnergy energy,
const GTime time,
const bool &  gradients = false 
) const
pure virtual
double GModelSpatialElliptical::eval ( const GPhoton photon,
const bool &  gradients = false 
) const
virtual

Return model value.

Parameters
[in]photonIncident Photon.
[in]gradientsCompute gradients?
Returns
Value of spatial elliptical model.

Evaluates the elliptical spatial model value for a specific incident photon.

If the gradients flag is true the method will also compute the parameter gradients for all model parameters.

Implements GModelSpatial.

Definition at line 173 of file GModelSpatialElliptical.cpp.

References GPhoton::dir(), dir(), GSkyDir::dist(), GPhoton::energy(), eval(), GSkyDir::posang(), and GPhoton::time().

void GModelSpatialElliptical::free_members ( void  )
protected
virtual GSkyDir GModelSpatialElliptical::mc ( const GEnergy energy,
const GTime time,
GRan ran 
) const
pure virtual
double GModelSpatialElliptical::mc_norm ( const GSkyDir dir,
const double &  radius 
) const
inlinevirtual

Return normalization of elliptical source for Monte Carlo simulations.

Parameters
[in]dirCentre of simulation cone.
[in]radiusRadius of simulation cone (degrees).
Returns
Normalization.

Returns the normalization for an elliptical source within a circular region. The normalization is 1 if the elliptical source falls within the circle define by dir and radius, 0 otherwise.

Implements GModelSpatial.

Definition at line 294 of file GModelSpatialElliptical.hpp.

References dir(), GSkyDir::dist_deg(), norm(), and theta_max().

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

Assignment operator.

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

Definition at line 130 of file GModelSpatialElliptical.cpp.

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

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

void GModelSpatialElliptical::posangle ( const double &  posangle)
inline

Set Position Angle of model.

Parameters
[in]posanglePosition Angle of model (degrees).

Sets the Position Angle of model in degrees, measured counterclockwise from celestial North.

Definition at line 216 of file GModelSpatialElliptical.hpp.

References m_posangle, and GOptimizerPar::value().

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

Print content of object.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing the content of the object.

Formats the content in a standard way and puts this content in a C++ string that is returned.

Implements GModelSpatial.

Implemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

double GModelSpatialElliptical::ra ( void  ) const
inline

Return Right Ascencion of model centre.

Returns
Right Ascencion of model centre (degrees).

Returns the Right Ascension of the model centre in degrees.

Definition at line 142 of file GModelSpatialElliptical.hpp.

References m_ra, and GOptimizerPar::value().

Referenced by dir(), GCTAResponseIrf::nroi_elliptical(), read(), and write().

void GModelSpatialElliptical::ra ( const double &  ra)
inline

Set Right Ascencion of model centre.

Parameters
[in]raRight Ascension (degrees).

Sets the Right Ascension of the model centre in degrees.

Definition at line 156 of file GModelSpatialElliptical.hpp.

References m_ra, and GOptimizerPar::value().

void GModelSpatialElliptical::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 source location and position angle information from an XML element in the following format

<spatialModel type="...">
  <parameter name="RA"  scale="1" value="83.63" min="-360" max="360" free="1"/>
  <parameter name="DEC" scale="1" value="22.01" min="-90"  max="90"  free="1"/>
  <parameter name="PA"  scale="1" value="45.0"  min="-360" max="360" free="1"/>
  ...
</spatialModel>

or

<spatialModel type="...">
  <parameter name="GLON" scale="1" value="83.63" min="-360" max="360" free="1"/>
  <parameter name="GLAT" scale="1" value="22.01" min="-90"  max="90"  free="1"/>
  <parameter name="PA"   scale="1" value="45.0"  min="-360" max="360" free="1"/>
  ...
</spatialModel>

Implements GModelSpatial.

Reimplemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

Definition at line 219 of file GModelSpatialElliptical.cpp.

References dec(), GSkyDir::dec_deg(), dir(), G_READ, GSkyDir::lb_deg(), m_dec, m_posangle, m_ra, GOptimizerPar::name(), ra(), GSkyDir::ra_deg(), GModelPar::read(), GOptimizerPar::value(), gammalib::xml_get_par(), and gammalib::xml_has_par().

Referenced by GModelSpatialElliptical(), GModelSpatialEllipticalDisk::read(), and GModelSpatialEllipticalGauss::read().

virtual GSkyRegion* GModelSpatialElliptical::region ( void  ) const
pure virtual
void GModelSpatialElliptical::semimajor ( const double &  semimajor)
inline

Set semi-major axis of ellipse.

Parameters
[in]semimajorSemi-major axis of ellipse (degrees)

Sets the semi-major axis of the ellipse in degrees.

Definition at line 274 of file GModelSpatialElliptical.hpp.

References m_semimajor, and GOptimizerPar::value().

void GModelSpatialElliptical::semiminor ( const double &  semiminor)
inline

Set semi-minor axis of ellipse.

Parameters
[in]semiminorSemi-minor axis of ellipse (degrees)

Sets the semi-minor axis of the ellipse in degrees.

Definition at line 245 of file GModelSpatialElliptical.hpp.

References m_semiminor, and GOptimizerPar::value().

virtual double GModelSpatialElliptical::theta_max ( void  ) const
pure virtual
virtual std::string GModelSpatialElliptical::type ( void  ) const
pure virtual

Implements GModelSpatial.

Implemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

Referenced by write().

void GModelSpatialElliptical::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 requested type.
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 elliptical source location and position angle information into an XML element in the following format

<spatialModel type="...">
  <parameter name="RA"  scale="1" value="83.63" min="-360" max="360" free="1"/>
  <parameter name="DEC" scale="1" value="22.01" min="-90"  max="90"  free="1"/>
  <parameter name="PA"  scale="1" value="45.0"  min="-360" max="360" free="1"/>
  ...
</spatialModel>
Todo:
The case that an existing spatial XML element with "GLON" and "GLAT" as coordinates is not supported.

Implements GModelSpatial.

Reimplemented in GModelSpatialEllipticalGauss, and GModelSpatialEllipticalDisk.

Definition at line 293 of file GModelSpatialElliptical.cpp.

References GXmlElement::attribute(), dec(), G_WRITE, m_dec, m_posangle, m_ra, GOptimizerPar::name(), ra(), type(), GModelPar::write(), and gammalib::xml_need_par().

Referenced by GModelSpatialEllipticalDisk::write(), and GModelSpatialEllipticalGauss::write().

Member Data Documentation

GModelPar GModelSpatialElliptical::m_dec
protected
GModelPar GModelSpatialElliptical::m_posangle
protected

Position angle from North, counterclockwise (deg)

Definition at line 114 of file GModelSpatialElliptical.hpp.

Referenced by copy_members(), GModelSpatialEllipticalDisk::eval(), init_members(), posangle(), read(), and write().

GModelPar GModelSpatialElliptical::m_ra
protected

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