GammaLib
2.1.0.dev
|
Sky model class. More...
#include <GModelSky.hpp>
Classes | |
class | eflux_kern |
class | flux_kern |
Public Member Functions | |
GModelSky (void) | |
Void constructor. More... | |
GModelSky (const std::string &type) | |
Type constructor. More... | |
GModelSky (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSky (const GXmlElement &spatial, const GXmlElement &spectral) | |
Construct sky model from spatial and spectral XML elements. More... | |
GModelSky (const GXmlElement &spatial, const GXmlElement &spectral, const GXmlElement &temporal) | |
Construct sky model from spatial, spectral and temporal XML elements. More... | |
GModelSky (const GModelSpatial &spatial, const GModelSpectral &spectral) | |
Construct sky model from spatial and spectral components. More... | |
GModelSky (const GModelSpatial &spatial, const GModelSpectral &spectral, const GModelTemporal &temporal) | |
Construct sky model from spatial, spectral and temporal components. More... | |
GModelSky (const GModelSky &model) | |
Copy constructor. More... | |
virtual | ~GModelSky (void) |
Destructor. More... | |
virtual GModelSky & | operator= (const GModelSky &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear sky model. More... | |
virtual GModelSky * | clone (void) const |
Clone sky model. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual std::string | type (void) const |
Return sky model type. More... | |
virtual bool | is_constant (void) const |
Signals if sky model is temporally constant. More... | |
virtual double | eval (const GEvent &event, const GObservation &obs, const bool &gradients=false) const |
Evaluate sky model for a given event of an observation. More... | |
virtual GVector | eval (const GObservation &obs, GMatrixSparse *gradients=NULL) const |
Evaluate sky model for all events of an observation. More... | |
virtual double | npred (const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const |
Return spatially integrated sky model. More... | |
virtual void | read (const GXmlElement &xml) |
Read sky 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 model information. More... | |
GModelSpatial * | spatial (void) const |
Return spatial model component. More... | |
GModelSpectral * | spectral (void) const |
Return spectral model component. More... | |
GModelTemporal * | temporal (void) const |
Return temporal model component. More... | |
void | spatial (const GModelSpatial *spatial) |
Set spatial model component. More... | |
void | spectral (const GModelSpectral *spectral) |
Set spectral model component. More... | |
void | temporal (const GModelTemporal *temporal) |
Set temporal model component. More... | |
double | value (const GPhoton &photon) |
Return value of sky model for a given photon. More... | |
GVector | gradients (const GPhoton &photon) |
Return parameter gradients of sky model for a given photon. More... | |
GPhotons | mc (const double &area, const GSkyDir &dir, const double &radius, const GEnergy &emin, const GEnergy &emax, const GTime &tmin, const GTime &tmax, GRan &ran) const |
Return simulated list of photons. More... | |
double | flux (const GEnergy &emin, const GEnergy &emax) const |
Return sky model photon flux. More... | |
double | flux (const GSkyRegion ®ion, const GEnergy &emin, const GEnergy &emax) const |
Return sky model photon flux within sky region. More... | |
double | eflux (const GEnergy &emin, const GEnergy &emax) const |
Return sky model energy flux. More... | |
double | eflux (const GSkyRegion ®ion, const GEnergy &emin, const GEnergy &emax) const |
Return sky model energy flux within sky region. More... | |
double | flux_error (const GEnergy &emin, const GEnergy &emax) const |
Return sky model photon flux error. More... | |
double | flux_error (const GSkyRegion ®ion, const GEnergy &emin, const GEnergy &emax) const |
Return sky model photon flux error within sky region. More... | |
double | eflux_error (const GEnergy &emin, const GEnergy &emax) const |
Return sky model energy flux error. More... | |
double | eflux_error (const GSkyRegion ®ion, const GEnergy &emin, const GEnergy &emax) const |
Return sky model energy flux error within sky region. More... | |
Public Member Functions inherited from GModel | |
GModel (void) | |
Void constructor. More... | |
GModel (const GXmlElement &xml) | |
XML constructor. More... | |
GModel (const GModel &model) | |
Copy constructor. More... | |
virtual | ~GModel (void) |
Destructor. More... | |
virtual GModel & | operator= (const GModel &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns reference to model parameter by index. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns reference to model parameter by index (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns reference to model parameter by name. More... | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns reference to model parameter by name const version) More... | |
int | size (void) const |
Return number of parameters in model. More... | |
int | scales (void) const |
Return number of scale parameters in model. More... | |
GModelPar & | at (const int &index) |
Returns reference to model parameter by index. More... | |
const GModelPar & | at (const int &index) const |
Returns reference to model parameter by index (const version) More... | |
bool | has_par (const std::string &name) const |
Checks if parameter name exists. More... | |
bool | has_scales (void) const |
Signals that model has scales. More... | |
const std::string & | name (void) const |
Return parameter name. More... | |
void | name (const std::string &name) |
Set parameter name. More... | |
const double & | ts (void) const |
Return Test Statistic value. More... | |
void | ts (const double &ts) |
Set Test Statistic value. More... | |
const bool & | tscalc (void) const |
Return Test Statistic computation flag. More... | |
void | tscalc (const bool &tscalc) |
Set Test Statistic computation flag. More... | |
const bool & | has_ts (void) const |
Signals that model has Test Statistics value. More... | |
std::string | instruments (void) const |
Returns instruments to which model applies. More... | |
void | instruments (const std::string &instruments) |
Set instruments to which model applies. More... | |
GModelPar & | scale (const int &index) |
Returns reference to scale parameter by index. More... | |
const GModelPar & | scale (const int &index) const |
Returns reference to scale parameter by index (const version) More... | |
GModelPar | scale (const std::string &instrument) const |
Returns model scale factor for a given instrument. More... | |
void | scale (const GModelPar &par) |
Set model scale factor for a given instrument. More... | |
std::string | ids (void) const |
Returns observation identifiers to which model applies. More... | |
void | ids (const std::string &ids) |
Set observation identifiers to which model applies. More... | |
bool | is_valid (const std::string &instruments, const std::string &ids) const |
Verifies if model is valid for a given instrument and identifier. More... | |
const GModelAssociations & | associations (void) const |
Return model associations. More... | |
void | associations (const GModelAssociations &associations) |
Set model associations. More... | |
const bool & | has_eval_indices (void) const |
Signals that parameter indices updated by eval() method were set. More... | |
const std::vector< int > & | eval_indices (void) const |
Return vector of parameter indices updated by eval() method. 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 GModelSky &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | set_pointers (void) |
Set parameter pointers. More... | |
void | set_type (void) |
Set model type based on spatial model component. More... | |
void | signal_analytical_gradients (const GObservation &obs) const |
Signal all parameters that have analytical gradients for a given observation. More... | |
GModelSpatial * | xml_spatial (const GXmlElement &spatial) const |
Return pointer to spatial model from XML element. More... | |
GModelSpectral * | xml_spectral (const GXmlElement &spectral) const |
Return pointer to spectral model from XML element. More... | |
GModelTemporal * | xml_temporal (const GXmlElement &temporal) const |
Return pointer to temporal model from XML element. More... | |
bool | valid_model (void) const |
Verifies if model has all components. More... | |
Protected Member Functions inherited from GModel | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModel &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | read_attributes (const GXmlElement &xml) |
Read model attributes. More... | |
void | write_attributes (GXmlElement &xml) const |
Write model attributes. More... | |
std::string | print_attributes (void) const |
Print model attributes. More... | |
void | read_scales (const GXmlElement &xml) |
Read instrument scales from XML element. More... | |
void | write_scales (GXmlElement &xml) const |
Write instrument scales into XML element. More... | |
Protected Attributes | |
std::string | m_type |
Model type. More... | |
GModelSpatial * | m_spatial |
Spatial model. More... | |
GModelSpectral * | m_spectral |
Spectral model. More... | |
GModelTemporal * | m_temporal |
Temporal model. More... | |
Protected Attributes inherited from GModel | |
std::string | m_name |
Model name. More... | |
std::vector< std::string > | m_instruments |
Instruments to which model applies. More... | |
std::vector< GModelPar > | m_scales |
Model instrument scale factors. More... | |
std::vector< std::string > | m_ids |
Identifiers to which model applies. More... | |
std::vector< GModelPar * > | m_pars |
Pointers to all model parameters. More... | |
GModelAssociations | m_associations |
Model associations. More... | |
bool | m_has_ts |
Signals if TS is available. More... | |
bool | m_has_tscalc |
Signals if tscalc attribute is available. More... | |
bool | m_tscalc |
Signals if TS should be computed. More... | |
double | m_ts |
Test Statistic of the model. More... | |
bool | m_has_eval_inx |
std::vector< int > | m_eval_inx |
Sky model class.
This class implements a sky model that is factorized into a spatial, a spectral and a temporal component. The factorization is given by
\[ S(\vec{p}, E, t) = S_{\rm p}(\vec{p} | E, t) \, S_{\rm E}(E | t) \, S_{\rm t}(t) \]
where
The spatial component describes the energy and time dependent morphology of the source. It satisfies
\[ \int_{\Omega} S_{\rm p}(\vec{p} | E, t) d\Omega = 1 \]
for all \(E\) and \(t\), hence the spatial component does not impact the spatially integrated spectral and temporal properties of the source.
The spectral component describes the spatially integrated time dependent spectral distribution of the source. It satisfies
\[ \int_{E} S_{\rm E}(E | t) dE = \Phi \]
for all \(t\), where \(\Phi\) is the spatially and spectrally integrated total source flux. The spectral component does not impact the temporal properties of the integrated flux \(\Phi\).
The temporal component describes the temporal variation of the total integrated flux \(\Phi\) of the source.
The class has two methods for model evaluation that evaluate the model for a specific event, given an observation. The eval() method returns the model value. Note that the eval() method calls protected methods that handle time dispersion, energy dispersion and the point spread function (spatial dispersion). Dispersion is handled by integrating over the relevant intervals of the source properties. Integration of the model is done by three nested integrals. The outmost integral integrates over time (method integrate_time()), the next integral integrates over energy (method integrate_energy()), and the innermost integral integrates over the point spread function (method integrate_dir()).
The npred() method returns the integral over the model for a given observed energy and time.
The read() and write() methods allow reading of model information from and writing to an XML element. The type() method returns the model type that has been found in an XML element.
The model factorization is implemented by the abstract model component classes GModelSpatial, GModelSpectral and GModelTemporal. The GModelSky class holds pointers to derived instances of these classes, which can be accessed using the spatial(), spectral() and temporal() methods. Note that these pointers can be NULL (for example if no model has been yet defined), so the validity of the pointers needs to be checked before using them.
Definition at line 122 of file GModelSky.hpp.
GModelSky::GModelSky | ( | void | ) |
Void constructor.
Construct an empty sky model. An empty sky model has no type.
Definition at line 91 of file GModelSky.cpp.
References init_members().
Referenced by clone().
|
explicit |
Type constructor.
[in] | type | Model type. |
Construct an empty sky model of the specified type
. This constructor does basically the same than the void constructor with the only difference that the m_type member of the class is set to the specified type
string.
Definition at line 111 of file GModelSky.cpp.
References init_members(), m_type, and type().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs a sky model from the model information that is found in the xml
element. Only the spatial and spectral information is handled by this constructor. For the temporal component, a constant model of type GModelTemporalConst will be allocated.
Definition at line 134 of file GModelSky.cpp.
References GModelTemporalConst::clone(), GXmlNode::element(), init_members(), m_spatial, m_spectral, m_temporal, set_pointers(), set_type(), temporal(), xml_spatial(), and xml_spectral().
GModelSky::GModelSky | ( | const GXmlElement & | spatial, |
const GXmlElement & | spectral | ||
) |
Construct sky model from spatial and spectral XML elements.
[in] | spatial | Spatial XML element. |
[in] | spectral | Spectral XML element. |
Constructs a sky model from the spatial
and spectral
information that is found in the respective XML elements. For the temporal component, a constant model of type GModelTemporalConst will be allocated.
Definition at line 172 of file GModelSky.cpp.
References GModelTemporalConst::clone(), init_members(), m_spatial, m_spectral, m_temporal, set_pointers(), set_type(), temporal(), xml_spatial(), and xml_spectral().
GModelSky::GModelSky | ( | const GXmlElement & | spatial, |
const GXmlElement & | spectral, | ||
const GXmlElement & | temporal | ||
) |
Construct sky model from spatial, spectral and temporal XML elements.
[in] | spatial | Spatial XML element. |
[in] | spectral | Spectral XML element. |
[in] | temporal | Temporal XML element. |
Constructs a sky model from the spatial
, spectral
and temporal
information that is found in the respective XML elements.
Definition at line 207 of file GModelSky.cpp.
References init_members(), m_spatial, m_spectral, m_temporal, set_pointers(), set_type(), xml_spatial(), xml_spectral(), and xml_temporal().
GModelSky::GModelSky | ( | const GModelSpatial & | spatial, |
const GModelSpectral & | spectral | ||
) |
Construct sky model from spatial and spectral components.
[in] | spatial | Spatial model component. |
[in] | spectral | Spectral model component. |
Constructs a sky model from spatial
and spectral
model components. For the temporal component, a constant model of type GModelTemporalConst will be allocated.
Definition at line 241 of file GModelSky.cpp.
References GModelTemporalConst::clone(), GModelSpectral::clone(), GModelSpatial::clone(), init_members(), m_spatial, m_spectral, m_temporal, set_pointers(), set_type(), and temporal().
GModelSky::GModelSky | ( | const GModelSpatial & | spatial, |
const GModelSpectral & | spectral, | ||
const GModelTemporal & | temporal | ||
) |
Construct sky model from spatial, spectral and temporal components.
[in] | spatial | Spatial model component. |
[in] | spectral | Spectral model component. |
[in] | temporal | Temporal model component. |
Constructs a sky model from spatial
, spectral
and temporal
model components.
Definition at line 277 of file GModelSky.cpp.
References GModelTemporal::clone(), GModelSpectral::clone(), GModelSpatial::clone(), init_members(), m_spatial, m_spectral, m_temporal, set_pointers(), and set_type().
GModelSky::GModelSky | ( | const GModelSky & | model | ) |
Copy constructor.
[in] | model | Sky model. |
Definition at line 306 of file GModelSky.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModel.
Definition at line 249 of file GModelSky.hpp.
|
virtual |
Clear sky model.
This method properly resets the sky model to an initial state.
Implements GModel.
Definition at line 379 of file GModelSky.cpp.
References GModel::free_members(), free_members(), GModel::init_members(), and init_members().
Referenced by read().
|
virtual |
Clone sky model.
Implements GModel.
Definition at line 399 of file GModelSky.cpp.
References GModelSky().
|
protected |
Copy class members.
[in] | model | Sky model. |
Definition at line 1935 of file GModelSky.cpp.
References GModelTemporal::clone(), GModelSpectral::clone(), GModelSpatial::clone(), m_spatial, m_spectral, m_temporal, m_type, and set_pointers().
Referenced by GModelSky(), and operator=().
Return sky model energy flux.
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the spatially integrate energy flux in the sky model.
Definition at line 1173 of file GModelSky.cpp.
References GModelSpectral::eflux(), GModelSpectralNodes::eflux(), GModelSpectralNodes::energy(), GModelSpectral::eval(), GModelSpectralNodes::intensity(), GModelSpectralNodes::nodes(), spatial(), spectral(), and GModelSpatialDiffuseCube::spectrum().
Referenced by eflux(), and eflux_error().
double GModelSky::eflux | ( | const GSkyRegion & | region, |
const GEnergy & | emin, | ||
const GEnergy & | emax | ||
) | const |
Return sky model energy flux within sky region.
[in] | region | Sky region. |
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the energy flux of the sky model within a given sky region. If the spatial model is energy dependent the method integrates the flux over the specified energy range. Otherwise the spatially integrated flux is multiplied by the spectral flux.
Definition at line 1234 of file GModelSky.cpp.
References GModelSpatial::classname(), GModelSpectral::eflux(), eflux(), GModelSpatial::flux(), log(), GEnergy::MeV(), GIntegral::romberg(), spatial(), and spectral().
Return sky model energy flux error.
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the spatially integrate energy flux error in the sky model. The energy flux error is computed using Gaussian error propagation
\[ \Delta F_E = \sqrt{ \sum_i \left( \frac{\partial F_E}{\partial p_i} \right)^2 \left( \Delta p_i \right)^2 } \]
where \(F_E\) is the sky model energy flux and \(p_i\) are the sky model parameters.
Definition at line 1575 of file GModelSky.cpp.
References GOptimizerPar::autoscale(), eflux(), GOptimizerPar::factor_error(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), GModel::size(), and sqrt().
Referenced by eflux_error().
double GModelSky::eflux_error | ( | const GSkyRegion & | region, |
const GEnergy & | emin, | ||
const GEnergy & | emax | ||
) | const |
Return sky model energy flux error within sky region.
[in] | region | Sky region. |
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the spatially integrate energy flux error in the sky model. The energy flux error is computed using Gaussian error propagation
\[ \Delta F_E = \sqrt{ \sum_i \left( \frac{\partial F_E}{\partial p_i} \right)^2 \left( \Delta p_i \right)^2 } \]
where \(F_E\) is the sky model energy flux and \(p_i\) are the sky model parameters.
Definition at line 1713 of file GModelSky.cpp.
References GOptimizerPar::autoscale(), eflux(), eflux_error(), GOptimizerPar::factor_error(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), GModel::size(), and sqrt().
|
virtual |
Evaluate sky model for a given event of an observation.
[in] | event | Observed event. |
[in] | obs | Observation. |
[in] | gradients | Compute gradients? |
Evalutes the value of the sky model for an event
of a specific observation obs
.
If the gradients
flag is true the method will also compute the parameter gradients for all model parameters.
Implements GModel.
Definition at line 565 of file GModelSky.cpp.
References GObservation::response(), signal_analytical_gradients(), and value().
|
virtual |
Evaluate sky model for all events of an observation.
[in] | obs | Observation. |
[out] | gradients | Pointer to sparse matrix holding model gradients. |
Evalutes the value of the sky model for an event
of a specific observation obs
.
If the gradients
flag is true the method will also compute the parameter gradients for all model parameters.
Implements GModel.
Definition at line 596 of file GModelSky.cpp.
References GObservation::response(), and signal_analytical_gradients().
Return sky model photon flux.
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the spatially integrate photon flux in the sky model.
Definition at line 1061 of file GModelSky.cpp.
References GModelSpectralNodes::energy(), GModelSpectral::eval(), GModelSpectral::flux(), GModelSpectralNodes::flux(), GModelSpectralNodes::intensity(), GModelSpectralNodes::nodes(), spatial(), spectral(), and GModelSpatialDiffuseCube::spectrum().
Referenced by flux(), flux_error(), and mc().
double GModelSky::flux | ( | const GSkyRegion & | region, |
const GEnergy & | emin, | ||
const GEnergy & | emax | ||
) | const |
Return sky model photon flux within sky region.
[in] | region | Sky region. |
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the photon flux of the sky model within a given sky region.
Definition at line 1119 of file GModelSky.cpp.
References GModelSpatial::classname(), GModelSpectral::flux(), GModelSpatial::flux(), flux(), log(), GEnergy::MeV(), GIntegral::romberg(), spatial(), and spectral().
Return sky model photon flux error.
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the spatially integrate photon flux error in the sky model. The photon flux error is computed using Gaussian error propagation
\[ \Delta F_{ph} = \sqrt{ \sum_i \left( \frac{\partial F_{ph}}{\partial p_i} \right)^2 \left( \Delta p_i \right)^2 } \]
where \(F_{ph}\) is the sky model photon flux and \(p_i\) are the sky model parameters.
Definition at line 1299 of file GModelSky.cpp.
References GOptimizerPar::autoscale(), GOptimizerPar::factor_error(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), flux(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), GModel::size(), and sqrt().
Referenced by flux_error().
double GModelSky::flux_error | ( | const GSkyRegion & | region, |
const GEnergy & | emin, | ||
const GEnergy & | emax | ||
) | const |
Return sky model photon flux error within sky region.
[in] | region | Sky region. |
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Returns the spatially integrate photon flux error in the sky model. The photon flux error is computed using Gaussian error propagation
\[ \Delta F_{ph} = \sqrt{ \sum_i \left( \frac{\partial F_{ph}}{\partial p_i} \right)^2 \left( \Delta p_i \right)^2 } \]
where \(F_{ph}\) is the sky model photon flux and \(p_i\) are the sky model parameters.
Definition at line 1437 of file GModelSky.cpp.
References GOptimizerPar::autoscale(), GOptimizerPar::factor_error(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), flux(), flux_error(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), GModel::size(), and sqrt().
|
protected |
Delete class members.
Definition at line 1956 of file GModelSky.cpp.
References m_spatial, m_spectral, and m_temporal.
Referenced by clear(), operator=(), and ~GModelSky().
Return parameter gradients of sky model for a given photon.
[in] | photon | Photon. |
Returns a vector of parameter gradients for the sky model for a given photon
. If there are no parameters in the sky model, an empty vector will be returned.
Definition at line 529 of file GModelSky.cpp.
References GPhoton::energy(), GModelTemporal::eval(), GModelSpectral::eval(), GModelSpatial::eval(), GModel::m_pars, m_spatial, m_spectral, m_temporal, GModel::size(), and GPhoton::time().
|
protected |
Initialise class members.
Definition at line 1917 of file GModelSky.cpp.
References m_spatial, m_spectral, m_temporal, and m_type.
Referenced by clear(), GModelSky(), and operator=().
|
inlinevirtual |
Signals if sky model is temporally constant.
Signals if the sky model is temporally constant. A temporally constant model is a model that has a temporal component of type "Constant".
Implements GModel.
Definition at line 279 of file GModelSky.hpp.
References m_temporal, and GModelTemporal::type().
GPhotons GModelSky::mc | ( | const double & | area, |
const GSkyDir & | dir, | ||
const double & | radius, | ||
const GEnergy & | emin, | ||
const GEnergy & | emax, | ||
const GTime & | tmin, | ||
const GTime & | tmax, | ||
GRan & | ran | ||
) | const |
Return simulated list of photons.
[in] | area | Simulation surface area (cm2). |
[in] | dir | Centre of simulation cone. |
[in] | radius | Radius of simulation cone (deg). |
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
[in] | tmin | Minimum photon arrival time. |
[in] | tmax | Maximum photon arrival time. |
[in,out] | ran | Random number generator. |
Returns a list of photons that has been derived by Monte Carlo simulation from the model. A simulation region is define by specification of
dir
and a radius
,emin
, emax
], andtmin
, tmax
].Only photons with parameters in the simulation region will be returned by the method.
The simulation cone may eventually cover the entire sky (by setting the radius to 180 degrees), yet simulations will be more efficient if only the sky region will be simulated that is actually observed by the telescope.
Definition at line 882 of file GModelSky.cpp.
References GPhotons::append(), GPhoton::dir(), GSkyDir::dist_deg(), GPhoton::energy(), GModelSpectralNodes::energy(), GModelSpectral::eval(), GModelSpectral::flux(), flux(), GModelSpectralNodes::intensity(), m_spatial, m_spectral, m_temporal, GModelTemporal::mc(), GModelSpectral::mc(), GModelSpatial::mc(), GModelSpatialDiffuseCube::mc_cone(), GModelSpatial::mc_norm(), GModel::name(), GModelSpectralNodes::nodes(), norm(), GPhotons::reserve(), GTimes::size(), spectral(), GModelSpatialDiffuseCube::spectrum(), GPhoton::time(), valid_model(), and value().
|
virtual |
Return spatially integrated sky model.
[in] | obsEng | Measured photon energy. |
[in] | obsTime | Measured photon arrival time. |
[in] | obs | Observation. |
Computes
\[ N_{\rm pred}(E',t') = \int_{\rm ROI} P(p',E',t') \, dp' \, dE' \]
of the event probability
\[ P(p',E',t') = \int \int \int S(p,E,t) \times R(p',E',t'|p,E,t) \, dp \, dE \, dt \]
where \(S(p,E,t)\) is the source model, \(R(p',E',t'|p,E,t)\) is the instrument response function, \(p'\) is the measured photon direction, \(E'\) is the measured photon energy, \(t'\) is the measured photon arrival time, \(p\) is the true photon arrival direction, \(E\) is the true photon energy, and \(t\) is the true photon arrival time.
The method calls the GResponse::nroi() method that does the relevant integration.
Implements GModel.
Definition at line 648 of file GModelSky.cpp.
References gammalib::is_infinite(), gammalib::is_notanumber(), GObservation::response(), and valid_model().
Assignment operator.
[in] | model | Sky model. |
Definition at line 344 of file GModelSky.cpp.
References copy_members(), free_members(), init_members(), and GModel::operator=().
Print model information.
[in] | chatter | Chattiness. |
Implements GModel.
Definition at line 1837 of file GModelSky.cpp.
References m_spatial, m_spectral, m_temporal, gammalib::parformat(), GModel::print_attributes(), GModel::scale(), GModel::scales(), SILENT, GModelTemporal::size(), GModelSpectral::size(), GModelSpatial::size(), GModel::size(), spatial(), spectral(), gammalib::str(), temporal(), and type().
|
virtual |
Read sky model from XML element.
[in] | xml | XML element. |
Reads the sky model from an XML element. The XML element is expected to respect the following format:
<source name=".." type=".." instrument=".." id=".." ts=".."> <spectrum type=".."> .. </spectrum> <spatialModel type=".."> .. </spatialModel> <temporal type=".."> .. </temporal> </source>
The temporal element is optional. In no temporal element is specified a constant component with unity normalization will be assumed.
Optionally, the model may also contain scale parameters following the format:
<source name=".." type=".." instrument=".." id=".." ts=".."> <spectrum type=".."> .. </spectrum> <spatialModel type=".."> .. </spatialModel> <temporal type=".."> .. </temporal> <scaling> <instrument name=".." scale="1.0" min="0.1" max="10.0" value="1.0" free="0"/> <instrument name=".." scale="1.0" min="0.1" max="10.0" value="0.5" free="0"/> </scaling> </source>
(see GModel::read_scales() for more information on instrument scales).
Implements GModel.
Definition at line 724 of file GModelSky.cpp.
References clear(), GModelTemporalConst::clone(), GXmlNode::element(), GXmlNode::elements(), m_spatial, m_spectral, m_temporal, GModel::read_attributes(), set_pointers(), set_type(), temporal(), xml_spatial(), xml_spectral(), and xml_temporal().
|
protected |
Set parameter pointers.
Gathers all parameter pointers from the model into a flat array of model pointers.
Definition at line 1979 of file GModelSky.cpp.
References GModel::m_pars, GModel::m_scales, GModelTemporal::size(), GModelSpectral::size(), GModelSpatial::size(), spatial(), spectral(), and temporal().
Referenced by copy_members(), GModelSky(), read(), spatial(), spectral(), and temporal().
|
protected |
Set model type based on spatial model component.
Set the model type depending on the class type of the spatial model component.
Definition at line 2032 of file GModelSky.cpp.
References m_spatial, and m_type.
Referenced by GModelSky(), read(), and spatial().
|
protected |
Signal all parameters that have analytical gradients for a given observation.
[in] | obs | Observation. |
This method signals all spectral, temporal and model scaling parameters for which analytical gradients exist for a given observation. Analytical gradients will be signalled for all of these parameters that are free and for which has_grad()
is true
.
Note that spatial analytical gradients are excluded. These will be signalled by the underlying convolution method as analytical gradients are not (yet) supported by all convolution methods.
Definition at line 2087 of file GModelSky.cpp.
References GObservation::computed_gradient(), GOptimizerPar::has_grad(), GModel::has_scales(), GObservation::instrument(), GOptimizerPar::is_free(), GOptimizerPar::name(), GModel::scale(), GModel::scales(), GModelTemporal::size(), GModelSpectral::size(), spectral(), and temporal().
Referenced by eval().
|
inline |
Return spatial model component.
Returns a pointer to the spatial model component of the model. The pointer is of type GModelSpatial. Note that a NULL pointer may be returned if the sky model has no spatial model component.
Definition at line 295 of file GModelSky.hpp.
References m_spatial.
Referenced by GResponse::convolve(), eflux(), com_elliptical_kerns_omega::eval(), GModelSky::flux_kern::eval(), GResponse::eval_prob(), GResponse::eval_probs(), flux(), GResponse::irf_composite(), GCOMResponse::irf_diffuse(), GResponse::irf_diffuse(), GCOMResponse::irf_elliptical(), GResponse::irf_elliptical(), GCOMResponse::irf_ptsrc(), GResponse::irf_ptsrc(), GCOMResponse::irf_radial(), GCTAResponseCube::irf_radial(), GResponse::irf_radial(), GResponse::irf_spatial(), GCTAResponseIrf::nroi(), GCTAResponseIrf::nroi_composite(), GCTAResponseIrf::nroi_diffuse(), GCTAResponseIrf::nroi_elliptical(), GCTAResponseIrf::nroi_ptsrc(), GCTAResponseIrf::nroi_radial(), print(), GCTAOnOffObservation::set(), set_pointers(), and write().
void GModelSky::spatial | ( | const GModelSpatial * | spatial | ) |
Set spatial model component.
[in] | spatial | Pointer to spatial model component. |
Sets the spatial model component of the model.
Definition at line 413 of file GModelSky.cpp.
References GModelSpatial::clone(), m_spatial, set_pointers(), and set_type().
|
inline |
Return spectral model component.
Returns a pointer to the spectral model component of the model. The pointer is of type GModelSpectral. Note that a NULL pointer may be returned if the sky model has no spectral model component.
Definition at line 311 of file GModelSky.hpp.
References m_spectral.
Referenced by GResponse::convolve(), GResponse::ebounds_model(), GResponse::edisp_kerns::edisp_kerns(), eflux(), cta_nroi_kern::eval(), GModelSky::flux_kern::eval(), GResponse::eval_prob(), GResponse::eval_probs(), flux(), mc(), GCTAOnOffObservation::N_gamma(), GCTAResponseIrf::nroi(), print(), set_pointers(), signal_analytical_gradients(), GResponse::size_edisp_vector(), and write().
void GModelSky::spectral | ( | const GModelSpectral * | spectral | ) |
Set spectral model component.
[in] | spectral | Pointer to spectral model component. |
Sets the spectral model component of the model.
Definition at line 443 of file GModelSky.cpp.
References GModelSpectral::clone(), m_spectral, and set_pointers().
|
inline |
Return temporal model component.
Returns a pointer to the temporal model component of the model. The pointer is of type GModelTemporal. Note that a NULL pointer may be returned if the sky model has no temporal model component.
Definition at line 327 of file GModelSky.hpp.
References m_temporal.
Referenced by GResponse::convolve(), GResponse::edisp_kerns::edisp_kerns(), cta_nroi_kern::eval(), GResponse::eval_prob(), GResponse::eval_probs(), GModelSky(), GCTAResponseIrf::nroi(), print(), read(), set_pointers(), signal_analytical_gradients(), GResponse::size_edisp_vector(), and write().
void GModelSky::temporal | ( | const GModelTemporal * | temporal | ) |
Set temporal model component.
[in] | temporal | Pointer to temporal model component. |
Sets the temporal model component of the model.
Definition at line 470 of file GModelSky.cpp.
References GModelTemporal::clone(), m_temporal, and set_pointers().
|
inlinevirtual |
Return sky model type.
Returns the type of the sky model. The type is an arbitrary string that is used in the XML declaration of the model to describe the model type.
Implements GModel.
Definition at line 264 of file GModelSky.hpp.
References m_type.
Referenced by GModelSky(), and print().
|
protected |
Verifies if model has all components.
Definition at line 2191 of file GModelSky.cpp.
References m_spatial, m_spectral, and m_temporal.
double GModelSky::value | ( | const GPhoton & | photon | ) |
Return value of sky model for a given photon.
[in] | photon | Photon. |
Returns the value of the sky model for a given photon
. If no model components exist the model will return a value of 1.
Definition at line 503 of file GModelSky.cpp.
References GPhoton::energy(), GModelTemporal::eval(), GModelSpectral::eval(), GModelSpatial::eval(), m_spatial, m_spectral, m_temporal, and GPhoton::time().
Referenced by eval(), GModelSky::flux_kern::eval(), GModelSky::eflux_kern::eval(), and mc().
|
virtual |
Write model into XML element.
[in] | xml | Source library. |
Writes the sky model into an XML source library. The format written to the xml
element is as follows:
<source name=".." type=".." instrument=".." id=".." ts=".."> <spectrum type=".."> .. </spectrum> <spatialModel type=".."> .. </spatialModel> <temporal type=".."> .. </temporal> <scaling> <instrument name=".." scale="1.0" min="0.1" max="10.0" value="1.0" free="0"/> <instrument name=".." scale="1.0" min="0.1" max="10.0" value="0.5" free="0"/> </scaling> </source>
For compatibility reasons the temporal element will only be written if it is a non-constant component or a constant component with a normalization that differs from unity.
The scaling element will only be written optionally in case that instrument dependent scaling factors exist (see GModel::write_scales() for more information on instrument scales).
Implements GModel.
Definition at line 793 of file GModelSky.cpp.
References GXmlNode::append(), GXmlElement::attribute(), GXmlNode::element(), GXmlNode::elements(), GModel::name(), GModelTemporalConst::norm(), spatial(), spectral(), temporal(), GModelTemporal::write(), GModelSpectral::write(), GModelSpatial::write(), and GModel::write_attributes().
|
protected |
Return pointer to spatial model from XML element.
[in] | spatial | XML element. |
Returns pointer to spatial model that is defined in an XML element.
Definition at line 2137 of file GModelSky.cpp.
References GModelSpatialRegistry::alloc().
Referenced by GModelSky(), and read().
|
protected |
Return pointer to spectral model from XML element.
[in] | spectral | XML element. |
Returns pointer to spectral model that is defined in an XML element.
Definition at line 2156 of file GModelSky.cpp.
References GModelSpectralRegistry::alloc().
Referenced by GModelSky(), and read().
|
protected |
Return pointer to temporal model from XML element.
[in] | temporal | XML element. |
Returns pointer to temporal model that is defined in an XML element.
Definition at line 2175 of file GModelSky.cpp.
References GModelTemporalRegistry::alloc().
Referenced by GModelSky(), and read().
|
protected |
Spatial model.
Definition at line 237 of file GModelSky.hpp.
Referenced by copy_members(), free_members(), GModelSky(), gradients(), init_members(), mc(), print(), read(), set_type(), spatial(), valid_model(), and value().
|
protected |
Spectral model.
Definition at line 238 of file GModelSky.hpp.
Referenced by copy_members(), free_members(), GModelSky(), gradients(), init_members(), mc(), print(), read(), spectral(), valid_model(), and value().
|
protected |
Temporal model.
Definition at line 239 of file GModelSky.hpp.
Referenced by copy_members(), free_members(), GModelSky(), gradients(), init_members(), is_constant(), mc(), print(), read(), temporal(), valid_model(), and value().
|
protected |
Model type.
Definition at line 236 of file GModelSky.hpp.
Referenced by copy_members(), GModelSky(), init_members(), set_type(), and type().