GammaLib
2.0.0
|
#include <GModelSpatialRadialShell.hpp>
Public Member Functions | |
GModelSpatialRadialShell (void) | |
Void constructor. More... | |
GModelSpatialRadialShell (const bool &dummy, const std::string &type) | |
Model type constructor. More... | |
GModelSpatialRadialShell (const GSkyDir &dir, const double &radius, const double &width, const std::string &coordsys="CEL") | |
Shell constructor. More... | |
GModelSpatialRadialShell (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSpatialRadialShell (const GModelSpatialRadialShell &model) | |
Copy constructor. More... | |
virtual | ~GModelSpatialRadialShell (void) |
Destructor. More... | |
virtual GModelSpatialRadialShell & | operator= (const GModelSpatialRadialShell &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear radial shell model. More... | |
virtual GModelSpatialRadialShell * | clone (void) const |
Clone radial shell 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 |
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... | |
double | radius (void) const |
Return shell radius. More... | |
double | width (void) const |
Return shell width. More... | |
void | radius (const double &radius) |
Set shell radius. More... | |
void | width (const double &width) |
Set width radius. 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 GModelSpatialRadialShell &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... | |
Static Protected Member Functions | |
static double | f1 (double x) |
Return function 1 value needed for precomputation. More... | |
static double | f2 (double x) |
Return function 2 value needed for precomputation. More... | |
Protected Attributes | |
GModelPar | m_radius |
Inner shell radius (deg) More... | |
GModelPar | m_width |
Shell thickness (deg) More... | |
double | m_last_radius |
Last shell radius (deg) More... | |
double | m_last_width |
Last shell width (deg) More... | |
double | m_theta_in |
Inner shell radius (rad) More... | |
double | m_x_in |
sin(m_theta_in)^2 More... | |
double | m_theta_out |
Outer shell radius (rad) More... | |
double | m_x_out |
sin(m_theta_out)^2 More... | |
double | m_norm |
Shell 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 64 of file GModelSpatialRadialShell.hpp.
GModelSpatialRadialShell::GModelSpatialRadialShell | ( | void | ) |
Void constructor.
Constructs empty radial shell model.
Definition at line 73 of file GModelSpatialRadialShell.cpp.
References init_members().
Referenced by clone().
GModelSpatialRadialShell::GModelSpatialRadialShell | ( | const bool & | dummy, |
const std::string & | type | ||
) |
Model type constructor.
[in] | dummy | Dummy flag. |
[in] | type | Model type. |
Constructs empty radial shell model by specifying a model type
.
Definition at line 91 of file GModelSpatialRadialShell.cpp.
References init_members(), GModelSpatial::m_type, and GModelSpatial::type().
GModelSpatialRadialShell::GModelSpatialRadialShell | ( | const GSkyDir & | dir, |
const double & | radius, | ||
const double & | width, | ||
const std::string & | coordsys = "CEL" |
||
) |
Shell constructor.
[in] | dir | Sky position of shell centre. |
[in] | radius | Inner shell radius (degrees). |
[in] | width | Shell width (degrees). |
[in] | coordsys | Coordinate system (either "CEL" or "GAL") |
GException::invalid_argument | Invalid coordsys argument specified. |
Constructs the shell model from the shell centre (dir
), the inner shell radius
, and the shell width
. The coordsys
parameter specifies whether the sky direction should be interpreted in the celestial or Galactic coordinate system.
Definition at line 122 of file GModelSpatialRadialShell.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. |
Constructs shell 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 168 of file GModelSpatialRadialShell.cpp.
References init_members(), and read().
GModelSpatialRadialShell::GModelSpatialRadialShell | ( | const GModelSpatialRadialShell & | model | ) |
Copy constructor.
[in] | model | Radial shell source model. |
Definition at line 187 of file GModelSpatialRadialShell.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModelSpatialRadial.
Definition at line 136 of file GModelSpatialRadialShell.hpp.
|
virtual |
Clear radial shell model.
Implements GModelSpatialRadial.
Definition at line 259 of file GModelSpatialRadialShell.cpp.
References GModelSpatialRadial::free_members(), free_members(), GModelSpatial::free_members(), GModelSpatialRadial::init_members(), init_members(), and GModelSpatial::init_members().
|
virtual |
Clone radial shell model.
Implements GModelSpatialRadial.
Definition at line 281 of file GModelSpatialRadialShell.cpp.
References GModelSpatialRadialShell().
|
virtual |
Checks where 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 shell model.
Implements GModelSpatialRadial.
Definition at line 437 of file GModelSpatialRadialShell.cpp.
References gammalib::deg2rad, GModelSpatialRadial::dir(), GSkyDir::dist(), and theta_max().
|
protected |
Copy class members.
[in] | model | Radial shell source 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 and width twice on the stack.
Definition at line 641 of file GModelSpatialRadialShell.cpp.
References m_last_radius, m_last_width, m_norm, m_radius, m_theta_in, m_theta_out, GModelSpatial::m_type, m_width, m_x_in, and m_x_out.
Referenced by GModelSpatialRadialShell(), and operator=().
|
virtual |
Evaluate function (in units of sr^-1)
[in] | theta | Angular distance from shell centre (radians). |
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in] | gradients | Compute gradients? |
Evaluates the spatial part for a shell source model. The shell source model is a radial function \(f(\theta)\), where \(\theta\) is the angular separation between shell centre and the actual location.
The function is given by
\[ S_{\rm p}(\vec{p} | E, t) = {\tt m\_norm} \left \{ \begin{array}{l l} \displaystyle \sqrt{ \sin^2 \theta_{\rm out} - \sin^2 \theta } - \sqrt{ \sin^2 \theta_{\rm in} - \sin^2 \theta } & \mbox{if $\theta \le \theta_{\rm in}$} \\ \\ \displaystyle \sqrt{ \sin^2 \theta_{\rm out} - \sin^2 \theta } & \mbox{if $\theta_{\rm in} < \theta \le \theta_{\rm out}$} \\ \\ \displaystyle 0 & \mbox{if $\theta > \theta_{\rm out}$} \end{array} \right . \]
Here, \(\theta_{\rm in}\) and \(\theta_{\rm out}\) are the shell inner and outer radius.
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.
Implements GModelSpatialRadial.
Definition at line 327 of file GModelSpatialRadialShell.cpp.
References gammalib::is_infinite(), gammalib::is_notanumber(), m_norm, m_x_in, m_x_out, sin(), sqrt(), and update().
Referenced by mc().
|
staticprotected |
|
staticprotected |
Return function 2 value needed for precomputation.
Compute
\[f2(x) = \frac{1+\cos 2x}{4} \ln \left( \frac{\sqrt{2} \cos x}{\sqrt{2} + \sqrt{ 1 - \cos 2 x}} \right)\]
.
Definition at line 768 of file GModelSpatialRadialShell.cpp.
References cos(), f1(), log(), and gammalib::sqrt_two.
Referenced by update().
|
protected |
Delete class members.
Definition at line 665 of file GModelSpatialRadialShell.cpp.
Referenced by clear(), operator=(), and ~GModelSpatialRadialShell().
|
protected |
Initialise class members.
Definition at line 586 of file GModelSpatialRadialShell.cpp.
References GOptimizerPar::clear(), GOptimizerPar::free(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_last_radius, m_last_width, m_norm, GModelSpatial::m_pars, m_radius, m_theta_in, m_theta_out, GModelSpatial::m_type, m_width, m_x_in, m_x_out, GOptimizerPar::min(), GOptimizerPar::name(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().
Referenced by clear(), GModelSpatialRadialShell(), and operator=().
|
virtual |
Returns MC sky direction.
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in,out] | ran | Random number generator. |
GException::invalid_return_value | Invalid u_max value |
Draws an arbitrary sky position from the 2D shell distribution.
Implements GModelSpatialRadial.
Definition at line 381 of file GModelSpatialRadialShell.cpp.
References GModelSpatialRadial::dir(), eval(), G_MC, m_norm, m_theta_out, m_x_out, gammalib::rad2deg, GSkyDir::rotate_deg(), sin(), GRan::uniform(), and update().
|
virtual |
Assignment operator.
[in] | model | Radial shell source model. |
Definition at line 226 of file GModelSpatialRadialShell.cpp.
References copy_members(), free_members(), init_members(), and GModelSpatialRadial::operator=().
Print information.
[in] | chatter | Chattiness. |
Implements GModelSpatialRadial.
Definition at line 552 of file GModelSpatialRadialShell.cpp.
References GModelSpatial::m_pars, gammalib::parformat(), SILENT, GModelSpatial::size(), and gammalib::str().
|
inline |
Return shell radius.
Returns the shell radius in degrees.
Definition at line 150 of file GModelSpatialRadialShell.hpp.
References m_radius, and GOptimizerPar::value().
Referenced by GModelSpatialRadialShell(), GCTAResponseIrf::irf_radial(), GCTAResponseIrf::nroi_radial(), read(), theta_max(), update(), and write().
|
inline |
Set shell radius.
[in] | radius | Shell radius (degrees). |
Sets the shell radius in degrees.
Definition at line 164 of file GModelSpatialRadialShell.hpp.
References m_radius, and GOptimizerPar::value().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
Reads the radial shell model information from an XML element. The XML element shall have either the format
<spatialModel type="RadialShell"> <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.30" min="0.01" max="10" free="1"/> <parameter name="Width" scale="1.0" value="0.10" min="0.01" max="10" free="1"/> </spatialModel>
or
<spatialModel type="RadialShell"> <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.30" min="0.01" max="10" free="1"/> <parameter name="Width" scale="1.0" value="0.10" min="0.01" max="10" free="1"/> </spatialModel>
Reimplemented from GModelSpatialRadial.
Definition at line 488 of file GModelSpatialRadialShell.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 GModelSpatialRadialShell().
|
protectedvirtual |
Set boundary sky region.
Implements GModelSpatialRadial.
Definition at line 784 of file GModelSpatialRadialShell.cpp.
References GModelSpatialRadial::dir(), m_radius, GModelSpatial::m_region, m_width, GModelSpatial::region(), and GOptimizerPar::value().
|
virtual |
Return maximum model radius (in radians)
Implements GModelSpatialRadial.
Definition at line 453 of file GModelSpatialRadialShell.cpp.
References gammalib::deg2rad, radius(), and width().
Referenced by contains().
|
protected |
Update precomputation cache.
Performs precomputations that are valid for a given pair of radius and width values. The following members are set by this method: m_last_radius, m_last_width, m_theta_in, m_theta_out, m_x_in, m_x_out and m_norm.
m_theta_in contains the inner shell radius in radians, while m_theta_out contains the outer shell radius in radians.
\({\tt m\_x\_in} = \sin^2 {\tt m\_theta\_in}\), \({\tt m\_x\_out} = \sin^2 {\tt m\_theta\_out}\), and
\[{\tt m\_norm} = \frac{1}{2 \pi} \frac{\sqrt{1-\cos 2 {\tt m\_theta\_out}} - \sqrt{1-\cos 2 {\tt m\_theta\_in}}}{2 \sqrt{2}} + \frac{1+\cos 2 {\tt m\_theta\_out}}{4} \ln \left( \frac{\sqrt{2} \cos {\tt m\_theta\_out}} {\sqrt{2} + \sqrt{1 - \cos 2 {\tt m\_theta\_out}}} \right) - \frac{1+\cos 2 {\tt m\_theta\_in}}{4} \ln \left( \frac{\sqrt{2} \cos {\tt m\_theta\_in}} {\sqrt{2} + \sqrt{1 - \cos 2 {\tt m\_theta\_in}}} \right)\]
Definition at line 695 of file GModelSpatialRadialShell.cpp.
References gammalib::deg2rad, f1(), f2(), gammalib::is_infinite(), gammalib::is_notanumber(), m_last_radius, m_last_width, m_norm, m_theta_in, m_theta_out, m_x_in, m_x_out, radius(), sin(), gammalib::sqrt_two, gammalib::twopi, and width().
|
inline |
Return shell width.
Returns the shell width in degrees.
Definition at line 179 of file GModelSpatialRadialShell.hpp.
References m_width, and GOptimizerPar::value().
Referenced by GModelSpatialRadialShell(), read(), theta_max(), update(), and write().
|
inline |
Set width radius.
[in] | width | Shell width (degrees). |
Sets the shell width in degrees.
Definition at line 193 of file GModelSpatialRadialShell.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 shell model information into an XML element. The XML element will have the format
<spatialModel type="RadialShell"> <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.30" min="0.01" max="10" free="1"/> <parameter name="Width" scale="1.0" value="0.10" min="0.01" max="10" free="1"/> </spatialModel>
Reimplemented from GModelSpatialRadial.
Definition at line 525 of file GModelSpatialRadialShell.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 |
Last shell radius (deg)
Definition at line 120 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Last shell width (deg)
Definition at line 121 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Shell normalization.
Definition at line 126 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), eval(), init_members(), mc(), and update().
|
protected |
Inner shell radius (deg)
Definition at line 116 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), init_members(), radius(), read(), set_region(), and write().
|
mutableprotected |
Inner shell radius (rad)
Definition at line 122 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprotected |
Outer shell radius (rad)
Definition at line 124 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), init_members(), mc(), and update().
|
protected |
Shell thickness (deg)
Definition at line 117 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), init_members(), read(), set_region(), width(), and write().
|
mutableprotected |
sin(m_theta_in)^2
Definition at line 123 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), eval(), init_members(), and update().
|
mutableprotected |
sin(m_theta_out)^2
Definition at line 125 of file GModelSpatialRadialShell.hpp.
Referenced by copy_members(), eval(), init_members(), mc(), and update().