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

Point source spatial model. More...

#include <GModelSpatialPointSource.hpp>

Inheritance diagram for GModelSpatialPointSource:
GModelSpatial GBase

Public Member Functions

 GModelSpatialPointSource (void)
 Void constructor. More...
 
 GModelSpatialPointSource (const bool &dummy, const std::string &type)
 Model type constructor. More...
 
 GModelSpatialPointSource (const GSkyDir &dir)
 Sky direction constructor. More...
 
 GModelSpatialPointSource (const double &ra, const double &dec)
 Value constructor. More...
 
 GModelSpatialPointSource (const GXmlElement &xml)
 XML constructor. More...
 
 GModelSpatialPointSource (const GModelSpatialPointSource &model)
 Copy constructor. More...
 
virtual ~GModelSpatialPointSource (void)
 Destructor. More...
 
virtual GModelSpatialPointSourceoperator= (const GModelSpatialPointSource &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear point source model. More...
 
virtual GModelSpatialPointSourceclone (void) const
 Clone point source model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual std::string type (void) const
 Return model type. More...
 
virtual GClassCode code (void) const
 Return class code. More...
 
virtual double eval (const GPhoton &photon, 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 double mc_norm (const GSkyDir &dir, const double &radius) const
 Return normalization of point source for Monte Carlo simulations. More...
 
virtual bool contains (const GSkyDir &dir, const double &margin=0.0) const
 Checks where model contains specified sky direction. 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 point source information. More...
 
void type (const std::string &type)
 Set model type. 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 point source. More...
 
void dir (const GSkyDir &dir)
 Set position of point source. 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 GModelSpatialPointSource &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 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_ra
 Right Ascension (deg) More...
 
GModelPar m_dec
 Declination (deg) More...
 
GSkyRegionCircle m_region
 Bounding circle. More...
 
- Protected Attributes inherited from GModelSpatial
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Point source spatial model.

This class implements a point source as the spatial component of the factorised source model. The point source has two parameters: the Right Ascension and Declination of the point source location.

Definition at line 48 of file GModelSpatialPointSource.hpp.

Constructor & Destructor Documentation

GModelSpatialPointSource::GModelSpatialPointSource ( void  )

Void constructor.

Constructs empty point source model.

Definition at line 71 of file GModelSpatialPointSource.cpp.

References init_members().

Referenced by clone().

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

Model type constructor.

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

Constructs empty point source model by specifying a model type.

Definition at line 89 of file GModelSpatialPointSource.cpp.

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

GModelSpatialPointSource::GModelSpatialPointSource ( const GSkyDir dir)
explicit

Sky direction constructor.

Parameters
[in]dirSky direction.

Construct a point source spatial model from a sky direction.

Definition at line 111 of file GModelSpatialPointSource.cpp.

References dir(), and init_members().

GModelSpatialPointSource::GModelSpatialPointSource ( const double &  ra,
const double &  dec 
)

Value constructor.

Parameters
[in]raRight Ascencion of model centre.
[in]decDeclination of model centre.

Construct a point source spatial model from the Right Ascension and Declination of the model centre.

Definition at line 134 of file GModelSpatialPointSource.cpp.

References init_members(), m_dec, m_ra, and GOptimizerPar::value().

GModelSpatialPointSource::GModelSpatialPointSource ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Construct a point source spatial 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 159 of file GModelSpatialPointSource.cpp.

References init_members(), and read().

GModelSpatialPointSource::GModelSpatialPointSource ( const GModelSpatialPointSource model)

Copy constructor.

Parameters
[in]modelPoint source spatial model.

Definition at line 178 of file GModelSpatialPointSource.cpp.

References copy_members(), and init_members().

GModelSpatialPointSource::~GModelSpatialPointSource ( void  )
virtual

Destructor.

Definition at line 195 of file GModelSpatialPointSource.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelSpatial.

Definition at line 113 of file GModelSpatialPointSource.hpp.

void GModelSpatialPointSource::clear ( void  )
virtual

Clear point source model.

Implements GModelSpatial.

Definition at line 250 of file GModelSpatialPointSource.cpp.

References free_members(), GModelSpatial::free_members(), init_members(), and GModelSpatial::init_members().

GModelSpatialPointSource * GModelSpatialPointSource::clone ( void  ) const
virtual

Clone point source model.

Returns
Pointer to deep copy of point source model.

Implements GModelSpatial.

Definition at line 270 of file GModelSpatialPointSource.cpp.

References GModelSpatialPointSource().

GClassCode GModelSpatialPointSource::code ( void  ) const
inlinevirtual

Return class code.

Returns
GModelSpatialPointSource.

Returns the code GModelSpatialPointSource of the class.

Implements GModelSpatial.

Definition at line 156 of file GModelSpatialPointSource.hpp.

References GMODEL_SPATIAL_POINT_SOURCE.

bool GModelSpatialPointSource::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 point source model.

Implements GModelSpatial.

Definition at line 335 of file GModelSpatialPointSource.cpp.

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

void GModelSpatialPointSource::copy_members ( const GModelSpatialPointSource model)
protected

Copy class members.

Parameters
[in]modelPoint source spatial model.

Definition at line 581 of file GModelSpatialPointSource.cpp.

References m_dec, GModelSpatial::m_pars, m_ra, m_region, and m_type.

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

double GModelSpatialPointSource::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 199 of file GModelSpatialPointSource.hpp.

References m_dec, and GOptimizerPar::value().

Referenced by dir(), read(), and write().

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

Set Declination of model centre.

Parameters
[in]decDeclination of model centre.

Sets the Declination of model centre.

Definition at line 213 of file GModelSpatialPointSource.hpp.

References m_dec, and GOptimizerPar::value().

GSkyDir GModelSpatialPointSource::dir ( void  ) const

Return position of point source.

Returns
Point source sky direction.

Returns the sky direction of the point source.

Definition at line 502 of file GModelSpatialPointSource.cpp.

References dec(), ra(), and GSkyDir::radec_deg().

Referenced by GCOMDri::compute_drm_ptsrc(), contains(), eval(), GModelSpatialPointSource(), GCOMResponse::irf(), GLATResponse::irf(), GCTAResponseCube::irf_ptsrc(), GCTAResponseIrf::irf_ptsrc(), mc(), mc_norm(), GCTAResponseIrf::nroi_ptsrc(), and read().

void GModelSpatialPointSource::dir ( const GSkyDir dir)

Set position of point source.

Sets the sky direction of the point source.

Definition at line 520 of file GModelSpatialPointSource.cpp.

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

double GModelSpatialPointSource::eval ( const GPhoton photon,
const bool &  gradients = false 
) const
virtual

Evaluate function.

Parameters
[in]photonIncident photon.
[in]gradientsCompute gradients?
Returns
Model value.

Evaluates the spatial part for a point source model. It implements a delta function with respect to the coordinates of the source. For numerical reasons, a certain tolerance is accepted (typically 0.1 arcsec, i.e. well below the angular resolution of gamma-ray telescopes).

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

Implements GModelSpatial.

Definition at line 293 of file GModelSpatialPointSource.cpp.

References GPhoton::dir(), dir(), GSkyDir::dist_deg(), and tolerance.

void GModelSpatialPointSource::free_members ( void  )
protected

Delete class members.

Definition at line 602 of file GModelSpatialPointSource.cpp.

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

GSkyDir GModelSpatialPointSource::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 for the point source model. As the point source is a point in the sky, the methods always returns the directon of the point source.

Implements GModelSpatial.

Definition at line 316 of file GModelSpatialPointSource.cpp.

References dir().

double GModelSpatialPointSource::mc_norm ( const GSkyDir dir,
const double &  radius 
) const
inlinevirtual

Return normalization of point source for Monte Carlo simulations.

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

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

Implements GModelSpatial.

Definition at line 232 of file GModelSpatialPointSource.hpp.

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

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

Assignment operator.

Parameters
[in]modelPoint source spatial model.
Returns
Point source spatial model.

Definition at line 217 of file GModelSpatialPointSource.cpp.

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

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

Print point source information.

Parameters
[in]chatterChattiness.
Returns
String containing point source information.

Implements GModelSpatial.

Definition at line 470 of file GModelSpatialPointSource.cpp.

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

double GModelSpatialPointSource::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 170 of file GModelSpatialPointSource.hpp.

References m_ra, and GOptimizerPar::value().

Referenced by dir(), read(), and write().

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

Set Right Ascencion of model centre.

Parameters
[in]raRight Ascencion of model centre.

Sets the Right Ascencion of model centre.

Definition at line 184 of file GModelSpatialPointSource.hpp.

References m_ra, and GOptimizerPar::value().

void GModelSpatialPointSource::read ( const GXmlElement xml)
virtual

Read model from XML element.

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

Read the point source information from an XML element with the following format

<spatialModel type="PointSource">
  <parameter free="0" max="360" min="-360" name="RA" scale="1" value="83.6331" />
  <parameter free="0" max="90" min="-90" name="DEC" scale="1" value="22.0145" />
</spatialModel>

or

<spatialModel type="PointSource">
  <parameter free="0" max="360" min="-360" name="GLON" scale="1" value="83.6331" />
  <parameter free="0" max="90" min="-90" name="GLAT" scale="1" value="22.0145" />
</spatialModel>

Implements GModelSpatial.

Definition at line 372 of file GModelSpatialPointSource.cpp.

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

Referenced by GModelSpatialPointSource().

GSkyRegion * GModelSpatialPointSource::region ( void  ) const
inlinevirtual

Return boundary sky region.

Returns
Boundary sky region.

Returns a sky region that fully encloses the point source.

Implements GModelSpatial.

Definition at line 248 of file GModelSpatialPointSource.hpp.

References m_region, and set_region().

void GModelSpatialPointSource::set_region ( void  ) const
protected

Set boundary sky region.

Definition at line 612 of file GModelSpatialPointSource.cpp.

References GSkyRegionCircle::centre(), m_dec, m_ra, m_region, GSkyRegionCircle::radius(), and GOptimizerPar::value().

Referenced by region().

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

Return model type.

Returns
Model type.

Returns the type of the spatial point source model.

Implements GModelSpatial.

Definition at line 127 of file GModelSpatialPointSource.hpp.

References m_type.

Referenced by GModelSpatialPointSource(), type(), and write().

void GModelSpatialPointSource::type ( const std::string &  type)
inline

Set model type.

Parameters
[in]typeModel type.

Set the type of the spatial point source model.

Definition at line 141 of file GModelSpatialPointSource.hpp.

References m_type, and type().

void GModelSpatialPointSource::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 'SkyDirFunction'
GException::model_invalid_parnumInvalid number of model parameters found in XML element.
GException::model_invalid_parnamesInvalid model parameter names found in XML element.

Write the point source information into an XML element with the following format

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

Implements GModelSpatial.

Definition at line 438 of file GModelSpatialPointSource.cpp.

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

Member Data Documentation

GModelPar GModelSpatialPointSource::m_dec
protected

Declination (deg)

Definition at line 102 of file GModelSpatialPointSource.hpp.

Referenced by copy_members(), dec(), dir(), GModelSpatialPointSource(), init_members(), read(), set_region(), and write().

GModelPar GModelSpatialPointSource::m_ra
protected

Right Ascension (deg)

Definition at line 101 of file GModelSpatialPointSource.hpp.

Referenced by copy_members(), dir(), GModelSpatialPointSource(), init_members(), ra(), read(), set_region(), and write().

GSkyRegionCircle GModelSpatialPointSource::m_region
mutableprotected

Bounding circle.

Definition at line 103 of file GModelSpatialPointSource.hpp.

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

std::string GModelSpatialPointSource::m_type
protected

Model type.

Definition at line 100 of file GModelSpatialPointSource.hpp.

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


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