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

Sky model class. More...

#include <GModelSky.hpp>

Inheritance diagram for GModelSky:
GModel GBase

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 GModelSkyoperator= (const GModelSky &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear sky model. More...
 
virtual GModelSkyclone (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...
 
GModelSpatialspatial (void) const
 Return spatial model component. More...
 
GModelSpectralspectral (void) const
 Return spectral model component. More...
 
GModelTemporaltemporal (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 &region, 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 &region, 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 &region, 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 &region, 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 GModeloperator= (const GModel &model)
 Assignment operator. More...
 
virtual GModelParoperator[] (const int &index)
 Returns reference to model parameter by index. More...
 
virtual const GModelParoperator[] (const int &index) const
 Returns reference to model parameter by index (const version) More...
 
virtual GModelParoperator[] (const std::string &name)
 Returns reference to model parameter by name. More...
 
virtual const GModelParoperator[] (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...
 
GModelParat (const int &index)
 Returns reference to model parameter by index. More...
 
const GModelParat (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...
 
GModelParscale (const int &index)
 Returns reference to scale parameter by index. More...
 
const GModelParscale (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 GModelAssociationsassociations (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...
 
GModelSpatialxml_spatial (const GXmlElement &spatial) const
 Return pointer to spatial model from XML element. More...
 
GModelSpectralxml_spectral (const GXmlElement &spectral) const
 Return pointer to spectral model from XML element. More...
 
GModelTemporalxml_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...
 
GModelSpatialm_spatial
 Spatial model. More...
 
GModelSpectralm_spectral
 Spectral model. More...
 
GModelTemporalm_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< GModelParm_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
 

Detailed Description

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

  • \(S_{\rm p}(\vec{p} | E, t)\) is the spatial component,
  • \(S_{\rm E}(E | t)\) is the spectral component, and
  • \(S_{\rm t}(t)\) is the temporal component.

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.

Constructor & Destructor Documentation

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().

GModelSky::GModelSky ( const std::string &  type)
explicit

Type constructor.

Parameters
[in]typeModel 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().

GModelSky::GModelSky ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML 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.

Parameters
[in]spatialSpatial XML element.
[in]spectralSpectral 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.

Parameters
[in]spatialSpatial XML element.
[in]spectralSpectral XML element.
[in]temporalTemporal 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.

Parameters
[in]spatialSpatial model component.
[in]spectralSpectral 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.

Parameters
[in]spatialSpatial model component.
[in]spectralSpectral model component.
[in]temporalTemporal 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.

Parameters
[in]modelSky model.

Definition at line 306 of file GModelSky.cpp.

References copy_members(), and init_members().

GModelSky::~GModelSky ( void  )
virtual

Destructor.

Definition at line 322 of file GModelSky.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModel.

Definition at line 249 of file GModelSky.hpp.

void GModelSky::clear ( void  )
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().

GModelSky * GModelSky::clone ( void  ) const
virtual

Clone sky model.

Returns
Pointer to deep copy of sky model.

Implements GModel.

Definition at line 399 of file GModelSky.cpp.

References GModelSky().

void GModelSky::copy_members ( const GModelSky model)
protected

Copy class members.

Parameters
[in]modelSky 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=().

double GModelSky::eflux ( const GEnergy emin,
const GEnergy emax 
) const

Return sky model energy flux.

Parameters
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model energy flux (erg cm \(^{-2}\) s \(^{-1}\))

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.

Parameters
[in]regionSky region.
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model energy flux (erg cm \(^{-2}\) s \(^{-1}\))

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().

double GModelSky::eflux_error ( const GEnergy emin,
const GEnergy emax 
) const

Return sky model energy flux error.

Parameters
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model energy flux error (erg cm \(^{-2}\) s \(^{-1}\))

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.

Parameters
[in]regionSky region.
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model energy flux error (erg cm \(^{-2}\) s \(^{-1}\))

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().

double GModelSky::eval ( const GEvent event,
const GObservation obs,
const bool &  gradients = false 
) const
virtual

Evaluate sky model for a given event of an observation.

Parameters
[in]eventObserved event.
[in]obsObservation.
[in]gradientsCompute gradients?
Returns
Value of sky model.

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().

GVector GModelSky::eval ( const GObservation obs,
GMatrixSparse gradients = NULL 
) const
virtual

Evaluate sky model for all events of an observation.

Parameters
[in]obsObservation.
[out]gradientsPointer to sparse matrix holding model gradients.
Returns
Values of sky model.

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().

double GModelSky::flux ( const GEnergy emin,
const GEnergy emax 
) const

Return sky model photon flux.

Parameters
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model photon flux (cm \(^{-2}\) s \(^{-1}\))

Returns the spatially integrate photon flux in the sky model.

Todo:
Take spatial photon flux normalisation into account

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.

Parameters
[in]regionSky region.
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model photon flux (cm \(^{-2}\) s \(^{-1}\))

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().

double GModelSky::flux_error ( const GEnergy emin,
const GEnergy emax 
) const

Return sky model photon flux error.

Parameters
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model photon flux error (cm \(^{-2}\) s \(^{-1}\))

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.

Parameters
[in]regionSky region.
[in]eminMinimum energy.
[in]emaxMaximum energy.
Returns
Sky model photon flux error (cm \(^{-2}\) s \(^{-1}\))

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().

void GModelSky::free_members ( void  )
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().

GVector GModelSky::gradients ( const GPhoton photon)

Return parameter gradients of sky model for a given photon.

Parameters
[in]photonPhoton.
Returns
Vector of parameter gradients

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().

void GModelSky::init_members ( void  )
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=().

bool GModelSky::is_constant ( void  ) const
inlinevirtual

Signals if sky model is temporally constant.

Returns
True if sky model is temporally constant, false otherwise.

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.

Parameters
[in]areaSimulation surface area (cm2).
[in]dirCentre of simulation cone.
[in]radiusRadius of simulation cone (deg).
[in]eminMinimum photon energy.
[in]emaxMaximum photon energy.
[in]tminMinimum photon arrival time.
[in]tmaxMaximum photon arrival time.
[in,out]ranRandom number generator.
Returns
List of photons

Returns a list of photons that has been derived by Monte Carlo simulation from the model. A simulation region is define by specification of

  • a simulation cone, which is a circular region on the sky defined by a centre direction dir and a radius,
  • an energy range [emin, emax], and
  • a time interval [tmin, 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.

Todo:
Implement unique model ID to assign as Monte Carlo ID

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().

double GModelSky::npred ( const GEnergy obsEng,
const GTime obsTime,
const GObservation obs 
) const
virtual

Return spatially integrated sky model.

Parameters
[in]obsEngMeasured photon energy.
[in]obsTimeMeasured photon arrival time.
[in]obsObservation.
Returns
Spatially integrated sky model.

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().

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

Assignment operator.

Parameters
[in]modelSky model.
Returns
Sky model.

Definition at line 344 of file GModelSky.cpp.

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

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

Print model information.

Parameters
[in]chatterChattiness.
Returns
String containing model information.

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().

void GModelSky::read ( const GXmlElement xml)
virtual

Read sky model from XML element.

Parameters
[in]xmlXML 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().

void GModelSky::set_pointers ( void  )
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().

void GModelSky::set_type ( void  )
protected

Set model type based on spatial model component.

Set the model type depending on the class type of the spatial model component.

Todo:
A method could be implemented in the GModelSpatial class that determines the model type. This is however not very critical.

Definition at line 2032 of file GModelSky.cpp.

References m_spatial, and m_type.

Referenced by GModelSky(), read(), and spatial().

void GModelSky::signal_analytical_gradients ( const GObservation obs) const
protected

Signal all parameters that have analytical gradients for a given observation.

Parameters
[in]obsObservation.

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().

void GModelSky::spatial ( const GModelSpatial spatial)

Set spatial model component.

Parameters
[in]spatialPointer 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().

GModelSpectral * GModelSky::spectral ( void  ) const
inline

Return spectral model component.

Returns
Pointer to 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.

Parameters
[in]spectralPointer 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().

GModelTemporal * GModelSky::temporal ( void  ) const
inline

Return temporal model component.

Returns
Pointer to 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.

Parameters
[in]temporalPointer 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().

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

Return sky model type.

Returns
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().

bool GModelSky::valid_model ( void  ) const
protected

Verifies if model has all components.

Returns
True is model is valid, false otherwise.

Definition at line 2191 of file GModelSky.cpp.

References m_spatial, m_spectral, and m_temporal.

Referenced by mc(), and npred().

double GModelSky::value ( const GPhoton photon)

Return value of sky model for a given photon.

Parameters
[in]photonPhoton.
Returns
Value of sky model.

Returns the value of the sky model for a given photon. If no model components exist the model will return a value of 1.

Todo:
We probably should return a value of 0 is no model components exist. But we may also make sure that the model never has NULL pointers, which would avoid all the pointer checks.

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().

void GModelSky::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlSource 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().

GModelSpatial * GModelSky::xml_spatial ( const GXmlElement spatial) const
protected

Return pointer to spatial model from XML element.

Parameters
[in]spatialXML element.
Returns
Pointer to spatial model.

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().

GModelSpectral * GModelSky::xml_spectral ( const GXmlElement spectral) const
protected

Return pointer to spectral model from XML element.

Parameters
[in]spectralXML element.
Returns
Pointer to spectral model.

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().

GModelTemporal * GModelSky::xml_temporal ( const GXmlElement temporal) const
protected

Return pointer to temporal model from XML element.

Parameters
[in]temporalXML element.
Returns
Pointer to temporal model.

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().

Member Data Documentation

GModelSpatial* GModelSky::m_spatial
protected
GModelSpectral* GModelSky::m_spectral
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().

GModelTemporal* GModelSky::m_temporal
protected
std::string GModelSky::m_type
protected

Model type.

Definition at line 236 of file GModelSky.hpp.

Referenced by copy_members(), GModelSky(), init_members(), set_type(), and type().


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