GammaLib  1.7.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

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

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 120 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 90 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 110 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 133 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 171 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 206 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 240 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 276 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 305 of file GModelSky.cpp.

References copy_members(), and init_members().

GModelSky::~GModelSky ( void  )
virtual

Destructor.

Definition at line 321 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 200 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 378 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 398 of file GModelSky.cpp.

References GModelSky().

void GModelSky::copy_members ( const GModelSky model)
protected

Copy class members.

Parameters
[in]modelSky model.

Definition at line 1117 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::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 564 of file GModelSky.cpp.

References GObservation::response(), and value().

void GModelSky::free_members ( void  )
protected

Delete class members.

Definition at line 1138 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 528 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 1099 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 230 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 845 of file GModelSky.cpp.

References GPhotons::append(), GPhoton::dir(), GSkyDir::dist_deg(), GPhoton::energy(), GModelSpectralNodes::energy(), GModelSpectral::eval(), GModelSpectral::flux(), GModelSpectralNodes::intensity(), m_spatial, m_spectral, m_temporal, GModelTemporal::mc(), GModelSpectral::mc(), GModelSpatial::mc(), GModelSpatial::mc_norm(), GModel::name(), GModelSpectralNodes::nodes(), norm(), GPhotons::reserve(), GModelSpatialDiffuseCube::set_mc_cone(), 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 611 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 343 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 1019 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 687 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 1161 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 1214 of file GModelSky.cpp.

References m_spatial, and m_type.

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

GModelSpatial * GModelSky::spatial ( void  ) const
inline

Return spatial model component.

Returns
Pointer to 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 246 of file GModelSky.hpp.

References m_spatial.

Referenced by GCOMDri::compute_drm(), GCOMDri::compute_drm_ptsrc(), GResponse::convolve(), GResponse::eval_prob(), 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.

Parameters
[in]spatialPointer to spatial model component.

Sets the spatial model component of the model.

Definition at line 412 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 262 of file GModelSky.hpp.

References m_spectral.

Referenced by cta_nroi_kern::eval(), GResponse::eval_prob(), mc(), GCTAOnOffObservation::N_gamma(), GCTAResponseIrf::nroi(), print(), set_pointers(), 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 442 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 278 of file GModelSky.hpp.

References m_temporal.

Referenced by cta_nroi_kern::eval(), GResponse::eval_prob(), GModelSky(), GCTAResponseIrf::nroi(), print(), read(), set_pointers(), 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 469 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 215 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 1316 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 502 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(), 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 756 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 1262 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 1281 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 1300 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 189 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 187 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: