GammaLib
2.0.0
|
#include <GModelSpatialRadialRing.hpp>
Public Member Functions | |
GModelSpatialRadialRing (void) | |
Void constructor. More... | |
GModelSpatialRadialRing (const GSkyDir &dir, const double &radius, const double &width, const std::string &coordsys="CEL") | |
Ring constructor. More... | |
GModelSpatialRadialRing (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSpatialRadialRing (const GModelSpatialRadialRing &model) | |
Copy constructor. More... | |
virtual | ~GModelSpatialRadialRing (void) |
Destructor. More... | |
virtual GModelSpatialRadialRing & | operator= (const GModelSpatialRadialRing &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear radial ring model. More... | |
virtual GModelSpatialRadialRing * | clone (void) const |
Clone radial ring 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 function (in units of sr^-1) More... | |
virtual GSkyDir | mc (const GEnergy &energy, const GTime &time, GRan &ran) const |
Return MC sky direction. More... | |
virtual bool | contains (const GSkyDir &dir, const double &margin=0.0) const |
Checks whether model contains specified sky direction. More... | |
virtual double | theta_min (void) const |
Return minimum model radius (in radians) 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... | |
double | radius (void) const |
Return ring inner radius. More... | |
void | radius (const double &radius) |
Set ring inner radius. More... | |
double | width (void) const |
Return ring width. More... | |
void | width (const double &width) |
Set ring width. 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 GModelSpatialRadial & | operator= (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 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 GModelSpatial & | operator= (const GModelSpatial &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns model parameter (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns model parameter (const version) More... | |
virtual double | flux (const GSkyRegion ®ion, 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... | |
GModelPar & | at (const int &index) |
Returns model parameter. More... | |
const GModelPar & | at (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 GSkyRegion * | region (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 GModelSpatialRadialRing &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 |
Ring inner radius (degrees) More... | |
GModelPar | m_width |
Ring width (degrees) More... | |
double | m_last_radius |
Last ring radius. More... | |
double | m_last_width |
Last ring width. More... | |
double | m_inner_radius_rad |
Inner radius in radians. More... | |
double | m_outer_radius_rad |
Outer radius in radians. More... | |
double | m_cos_inner_radius_rad |
Cosine of inner radius in radians. More... | |
double | m_cos_outer_radius_rad |
Cosine of outer radius in radians. More... | |
double | m_norm |
Normalization. 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... | |
Definition at line 54 of file GModelSpatialRadialRing.hpp.
GModelSpatialRadialRing::GModelSpatialRadialRing | ( | void | ) |
Void constructor.
Constructs empty radial ring model.
Definition at line 67 of file GModelSpatialRadialRing.cpp.
References init_members().
Referenced by clone().
GModelSpatialRadialRing::GModelSpatialRadialRing | ( | const GSkyDir & | dir, |
const double & | radius, | ||
const double & | width, | ||
const std::string & | coordsys = "CEL" |
||
) |
Ring constructor.
[in] | dir | Sky position of ring centre. |
[in] | radius | Ring inner radius (degrees). |
[in] | width | Ring width (degrees). |
[in] | coordsys | Coordinate system (either "CEL" or "GAL") |
GException::invalid_argument | Invalid coordsys argument specified. |
Constructs radial ring model from the sky position of the ring centre (dir
) and the ring inner radius (radius
) and width (width
) in degrees. The coordsys
parameter specifies whether the sky direction should be interpreted in the celestial or Galactic coordinate system.
Definition at line 93 of file GModelSpatialRadialRing.cpp.
References GModelSpatialRadial::dir(), G_CONSTRUCTOR, init_members(), GModelSpatialRadial::m_lat, GModelSpatialRadial::m_lon, GOptimizerPar::name(), radius(), and width().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Creates instance of radial ring 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 139 of file GModelSpatialRadialRing.cpp.
References init_members(), and read().
GModelSpatialRadialRing::GModelSpatialRadialRing | ( | const GModelSpatialRadialRing & | model | ) |
Copy constructor.
[in] | model | Radial ring model. |
Definition at line 158 of file GModelSpatialRadialRing.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModelSpatialRadial.
Definition at line 124 of file GModelSpatialRadialRing.hpp.
|
virtual |
Clear radial ring model.
Implements GModelSpatialRadial.
Definition at line 230 of file GModelSpatialRadialRing.cpp.
References free_members(), GModelSpatialRadial::free_members(), GModelSpatial::free_members(), init_members(), GModelSpatialRadial::init_members(), and GModelSpatial::init_members().
|
virtual |
Clone radial ring model.
Implements GModelSpatialRadial.
Definition at line 252 of file GModelSpatialRadialRing.cpp.
References GModelSpatialRadialRing().
|
virtual |
Checks whether model contains specified sky direction.
[in] | dir | Sky direction. |
[in] | margin | Margin to be added to sky direction (degrees) |
Signals whether a sky direction is contained in the radial ring model.
Implements GModelSpatialRadial.
Definition at line 367 of file GModelSpatialRadialRing.cpp.
References gammalib::deg2rad, GModelSpatialRadial::dir(), GSkyDir::dist(), theta_max(), and theta_min().
|
protected |
Copy class members.
[in] | model | Radial ring 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 589 of file GModelSpatialRadialRing.cpp.
References m_cos_inner_radius_rad, m_cos_outer_radius_rad, m_inner_radius_rad, m_last_radius, m_last_width, m_norm, m_outer_radius_rad, m_radius, GModelSpatial::m_type, and m_width.
Referenced by GModelSpatialRadialRing(), and operator=().
|
virtual |
Evaluate function (in units of sr^-1)
[in] | theta | Angular distance from ring centre (radians). |
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in] | gradients | Compute gradients? |
Evaluates the spatial component for a ring source model using
\[ S_{\rm p}(\vec{p} | E, t) = \left \{ \begin{array}{l l} \displaystyle {\tt m\_norm} & \mbox{if $\theta \le $ outer radius and $\theta \ge $ inner radius} \\ \\ \displaystyle 0 & \mbox{if $\theta > $ outer radius or $\theta < $ inner radius} \end{array} \right . \]
where
The method will not compute analytical parameter gradients, even if the gradients
argument is set to true. Radial ring parameter gradients need to be computed numerically.
Implements GModelSpatialRadial.
Definition at line 293 of file GModelSpatialRadialRing.cpp.
References gammalib::is_infinite(), gammalib::is_notanumber(), m_inner_radius_rad, m_norm, m_outer_radius_rad, and update().
|
protected |
Delete class members.
Definition at line 613 of file GModelSpatialRadialRing.cpp.
Referenced by clear(), operator=(), and ~GModelSpatialRadialRing().
|
protected |
Initialise class members.
Definition at line 535 of file GModelSpatialRadialRing.cpp.
References GOptimizerPar::clear(), GOptimizerPar::free(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_cos_inner_radius_rad, m_cos_outer_radius_rad, m_inner_radius_rad, m_last_radius, m_last_width, m_norm, m_outer_radius_rad, GModelSpatial::m_pars, m_radius, GModelSpatial::m_type, m_width, GOptimizerPar::min(), GOptimizerPar::name(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().
Referenced by clear(), GModelSpatialRadialRing(), and operator=().
|
virtual |
Return MC sky direction.
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in,out] | ran | Random number generator. |
Draws an arbitrary sky direction from the 2D ring distribution as function of the photon energy
and arrival time
.
Implements GModelSpatialRadial.
Definition at line 336 of file GModelSpatialRadialRing.cpp.
References gammalib::acos(), GModelSpatialRadial::dir(), m_cos_inner_radius_rad, m_cos_outer_radius_rad, gammalib::rad2deg, GSkyDir::rotate_deg(), GRan::uniform(), and update().
|
virtual |
Assignment operator.
[in] | model | Radial ring model. |
Definition at line 197 of file GModelSpatialRadialRing.cpp.
References copy_members(), free_members(), init_members(), and GModelSpatialRadial::operator=().
Print information.
[in] | chatter | Chattiness. |
Implements GModelSpatialRadial.
Definition at line 501 of file GModelSpatialRadialRing.cpp.
References GModelSpatial::m_pars, gammalib::parformat(), SILENT, GModelSpatial::size(), and gammalib::str().
|
inline |
Return ring inner radius.
Returns the inner radius of the ring in degrees.
Definition at line 138 of file GModelSpatialRadialRing.hpp.
References m_radius, and GOptimizerPar::value().
Referenced by GModelSpatialRadialRing(), GCTAResponseIrf::irf_radial(), GCTAResponseIrf::nroi_radial(), read(), set_region(), theta_max(), theta_min(), update(), and write().
|
inline |
Set ring inner radius.
[in] | radius | Ring inner radius (degrees). |
Sets the inner radius of the ring in degrees.
Definition at line 152 of file GModelSpatialRadialRing.hpp.
References m_radius, and GOptimizerPar::value().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
Reads the radial ring model information from an XML element. The XML element shall have either the format
<spatialModel type="RadialRing"> <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="Width" scale="1.0" value="0.15" min="0.01" max="10" free="1"/> </spatialModel>
or
<spatialModel type="RadialRing"> <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="Width" scale="1.0" value="0.15" min="0.01" max="10" free="1"/> </spatialModel>
Reimplemented from GModelSpatialRadial.
Definition at line 437 of file GModelSpatialRadialRing.cpp.
References G_READ, m_radius, m_width, GOptimizerPar::name(), radius(), GModelSpatialRadial::read(), GModelPar::read(), width(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().
Referenced by GModelSpatialRadialRing().
|
protectedvirtual |
Set boundary sky region.
Implements GModelSpatialRadial.
Definition at line 660 of file GModelSpatialRadialRing.cpp.
References GModelSpatialRadial::dir(), GModelSpatial::m_region, radius(), GModelSpatial::region(), and width().
|
virtual |
Return maximum model radius (in radians)
Implements GModelSpatialRadial.
Definition at line 403 of file GModelSpatialRadialRing.cpp.
References gammalib::deg2rad, radius(), and width().
Referenced by contains(), and update().
|
virtual |
Return minimum model radius (in radians)
Definition at line 391 of file GModelSpatialRadialRing.cpp.
References gammalib::deg2rad, and radius().
Referenced by contains(), and update().
|
protected |
Update precomputation cache.
Computes the normalization
\[ {\tt m\_norm} = \frac{1}{2 \pi (\cos r_i - \cos r_o)} \]
This is the correct normalization on the sphere for any radii.
Definition at line 630 of file GModelSpatialRadialRing.cpp.
References cos(), m_cos_inner_radius_rad, m_cos_outer_radius_rad, m_inner_radius_rad, m_last_radius, m_last_width, m_norm, m_outer_radius_rad, radius(), theta_max(), theta_min(), gammalib::twopi, and width().
|
inline |
Return ring width.
Returns the width of the ring in degrees.
Definition at line 167 of file GModelSpatialRadialRing.hpp.
References m_width, and GOptimizerPar::value().
Referenced by GModelSpatialRadialRing(), read(), set_region(), theta_max(), update(), and write().
|
inline |
Set ring width.
[in] | width | Ring width (degrees). |
Sets the width of the ring in degrees.
Definition at line 181 of file GModelSpatialRadialRing.hpp.
References m_width, and GOptimizerPar::value().
|
virtual |
Write model into XML element.
[in] | xml | XML element into which model information is written. |
Writes the radial ring model information into an XML element. The XML element will have the format
<spatialModel type="RadialRing"> <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="Width" scale="1.0" value="0.15" min="0.01" max="10" free="1"/> </spatialModel>
Reimplemented from GModelSpatialRadial.
Definition at line 474 of file GModelSpatialRadialRing.cpp.
References G_WRITE, m_radius, m_width, GOptimizerPar::name(), radius(), GModelSpatial::type(), width(), GModelSpatialRadial::write(), GModelPar::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().
|
mutableprotected |
Cosine of inner radius in radians.
Definition at line 112 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), init_members(), mc(), and update().
|
mutableprotected |
Cosine of outer radius in radians.
Definition at line 113 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), init_members(), mc(), and update().
|
mutableprotected |
Inner radius in radians.
Definition at line 110 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
mutableprotected |
Last ring radius.
Definition at line 108 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Last ring width.
Definition at line 109 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Normalization.
Definition at line 114 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
mutableprotected |
Outer radius in radians.
Definition at line 111 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
protected |
Ring inner radius (degrees)
Definition at line 104 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), init_members(), radius(), read(), and write().
|
protected |
Ring width (degrees)
Definition at line 105 of file GModelSpatialRadialRing.hpp.
Referenced by copy_members(), init_members(), read(), width(), and write().