GammaLib
2.0.0
|
Interface class for multi-wavelength observations. More...
#include <GMWLObservation.hpp>
Public Member Functions | |
GMWLObservation (void) | |
Void constructor. More... | |
GMWLObservation (const GFilename &filename) | |
File constructor. More... | |
GMWLObservation (const GMWLObservation &obs) | |
Copy constructor. More... | |
virtual | ~GMWLObservation (void) |
Destructor. More... | |
virtual GMWLObservation & | operator= (const GMWLObservation &obs) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear instance. More... | |
virtual GMWLObservation * | clone (void) const |
Clone instance. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual void | response (const GResponse &rsp) |
Set response function. More... | |
virtual const GMWLResponse * | response (void) const |
Return response. More... | |
virtual std::string | instrument (void) const |
Return instrument name. More... | |
virtual double | ontime (void) const |
Return ontime. More... | |
virtual double | livetime (void) const |
Return livetime. More... | |
virtual double | deadc (const GTime &time=GTime()) const |
Return deadtime correction factor. More... | |
virtual void | read (const GXmlElement &xml) |
Read observation from XML element. More... | |
virtual void | write (GXmlElement &xml) const |
Write observation into XML element. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print multi-wavelength information. More... | |
void | load (const GFilename &filename) |
Load observation. More... | |
const GFilename & | filename (void) const |
Return filename. More... | |
void | filename (const GFilename &filename) |
Set filename. More... | |
Public Member Functions inherited from GObservation | |
GObservation (void) | |
Void constructor. More... | |
GObservation (const GObservation &obs) | |
Copy constructor. More... | |
virtual | ~GObservation (void) |
Destructor. More... | |
virtual GObservation & | operator= (const GObservation &obs) |
Assignment operator. More... | |
virtual GEvents * | events (void) |
Return events. More... | |
virtual const GEvents * | events (void) const |
Return events (const version) More... | |
virtual void | events (const GEvents &events) |
Set event container. More... | |
virtual double | likelihood (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Compute likelihood function. More... | |
virtual double | model (const GModels &models, const GEvent &event, GVector *gradients=NULL) const |
Return model value and (optionally) gradients. More... | |
virtual GVector | model (const GModels &models, GMatrixSparse *gradients=NULL) const |
Return vector of model values and (optionally) gradients. More... | |
virtual int | nobserved (void) const |
Return total number of observed events. More... | |
virtual double | npred (const GModels &models, GVector *gradients=NULL) const |
Return total number (and optionally gradients) of predicted counts for all models. More... | |
virtual double | npred (const GModel &model) const |
Return total number of predicted counts for one model. More... | |
virtual double | model_grad (const GModel &model, const GModelPar &par, const GEvent &event) const |
Returns parameter gradient of model for a given event. More... | |
virtual GVector | model_grad (const GModel &model, const GModelPar &par) const |
Returns parameter gradients of model for all events. More... | |
virtual double | npred_grad (const GModel &model, const GModelPar &par) const |
Returns parameter gradient of Npred. More... | |
virtual void | remove_response_cache (const std::string &name) |
Response cache removal hook. More... | |
virtual const double & | grad_step_size (void) const |
Return gradient step size. More... | |
bool | has_events (void) const |
Signal if observation has events. More... | |
bool | has_gradient (const GModel &model, const GModelPar &par) const |
Check whether a model parameter has an analytical gradient. More... | |
void | name (const std::string &name) |
Set observation name. More... | |
void | id (const std::string &id) |
Set observation identifier. More... | |
void | statistic (const std::string &statistic) |
Set optimizer statistic. More... | |
const std::string & | name (void) const |
Return observation name. More... | |
const std::string & | id (void) const |
Return observation identifier. More... | |
const std::string & | statistic (void) const |
Return optimizer statistic. More... | |
void | computed_gradient (const GModel &model, const GModelPar &par) const |
Signals that an analytical gradient was computed for a model parameter. 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 GMWLObservation &obs) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GObservation | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GObservation &obs) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
virtual double | likelihood_poisson_unbinned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Evaluate log-likelihood function for Poisson statistic and unbinned analysis (version with working arrays) More... | |
virtual double | likelihood_poisson_binned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Evaluate log-likelihood function for Poisson statistic and binned analysis (version with working arrays) More... | |
virtual double | likelihood_gaussian_binned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Evaluate log-likelihood function for Gaussian statistic and binned analysis (version with working arrays) More... | |
virtual bool | use_event_for_likelihood (const int &index) const |
Check whether bin should be used for likelihood analysis. More... | |
virtual double | npred_spec (const GModel &model, const GTime &obsTime) const |
Integrates spatially integrated Npred kernel spectrally. More... | |
Protected Attributes | |
std::string | m_instrument |
Instrument name. More... | |
GFilename | m_filename |
Filename. More... | |
GMWLResponse | m_response |
Response function. More... | |
Protected Attributes inherited from GObservation | |
std::string | m_name |
Observation name. More... | |
std::string | m_id |
Observation identifier. More... | |
std::string | m_statistic |
Optimizer statistic. More... | |
GEvents * | m_events |
Pointer to event container. More... | |
double | m_grad_step_size |
Gradient step size. More... | |
std::vector< std::string > | m_pars_with_gradients |
Interface class for multi-wavelength observations.
This class implements a multi-wavelength observation. A multi-wavelength observation contains spectral points obtained with an unspecified instrument. The spectral points are given in physical units.
Definition at line 51 of file GMWLObservation.hpp.
GMWLObservation::GMWLObservation | ( | void | ) |
Void constructor.
Creates instance of an undefined observation.
Definition at line 66 of file GMWLObservation.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | File name. |
Creates instance from file.
Definition at line 83 of file GMWLObservation.cpp.
References init_members(), and load().
GMWLObservation::GMWLObservation | ( | const GMWLObservation & | obs | ) |
Copy constructor.
[in] | obs | Observation. |
Creates instance by copying an existing observation.
Definition at line 103 of file GMWLObservation.cpp.
References copy_members(), and init_members().
|
virtual |
Destructor.
Destroy instance.
Definition at line 121 of file GMWLObservation.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GObservation.
Definition at line 101 of file GMWLObservation.hpp.
|
virtual |
Clear instance.
This method properly resets the instance to an initial state.
Implements GObservation.
Definition at line 179 of file GMWLObservation.cpp.
References free_members(), GObservation::free_members(), init_members(), and GObservation::init_members().
|
virtual |
Clone instance.
Implements GObservation.
Definition at line 197 of file GMWLObservation.cpp.
References GMWLObservation().
|
protected |
Copy class members.
[in] | obs | Observation to be copied |
Definition at line 403 of file GMWLObservation.cpp.
References m_filename, m_instrument, and m_response.
Referenced by GMWLObservation(), and operator=().
Return deadtime correction factor.
Implements GObservation.
Definition at line 161 of file GMWLObservation.hpp.
|
inline |
Return filename.
Definition at line 173 of file GMWLObservation.hpp.
References m_filename.
Referenced by filename(), load(), and read().
|
inline |
Set filename.
[in] | filename | Filename. |
Definition at line 185 of file GMWLObservation.hpp.
References filename(), and m_filename.
|
protected |
Delete class members.
Definition at line 418 of file GMWLObservation.cpp.
Referenced by clear(), operator=(), and ~GMWLObservation().
|
protected |
Initialise class members.
The instrument name is set here to "MWL" so that the registry has an instrument type with that name. This may be later overwritten by a specific instrument.
Definition at line 383 of file GMWLObservation.cpp.
References GMWLResponse::clear(), GFilename::clear(), m_filename, m_instrument, m_response, and GObservation::m_statistic.
Referenced by clear(), GMWLObservation(), and operator=().
|
inlinevirtual |
Return instrument name.
Implements GObservation.
Definition at line 125 of file GMWLObservation.hpp.
Referenced by print().
|
inlinevirtual |
Return livetime.
Implements GObservation.
Definition at line 149 of file GMWLObservation.hpp.
void GMWLObservation::load | ( | const GFilename & | filename | ) |
Load observation.
[in] | filename | File name. |
Definition at line 310 of file GMWLObservation.cpp.
References clear(), filename(), GObservation::id(), GMWLSpectrum::instrument(), GMWLSpectrum::load(), GObservation::m_events, m_filename, m_instrument, and GObservation::name().
Referenced by GMWLObservation(), and read().
|
inlinevirtual |
Return ontime.
Implements GObservation.
Definition at line 137 of file GMWLObservation.hpp.
|
virtual |
Assignment operator.
[in] | obs | Observation. |
Copies observation into the instance.
Definition at line 144 of file GMWLObservation.cpp.
References copy_members(), free_members(), init_members(), and GObservation::operator=().
Print multi-wavelength information.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GObservation.
Definition at line 339 of file GMWLObservation.cpp.
References EXPLICIT, instrument(), GObservation::m_events, GObservation::name(), gammalib::parformat(), GEvents::print(), SILENT, and GObservation::statistic().
|
virtual |
Read observation from XML element.
[in] | xml | XML element. |
Reads information for a multi-wavelength observation from an XML element. The expected format of the XML element is
<observation name="..." id="..." instrument="MWL"> <parameter name="Instrument" value="..."/> <parameter name="Data" file="..."/> </observation>
The extno and extname attributes of the data parameter are optional, and can be used to indicate the extension number or name from which the multi-wavelength data should be loaded. If both are given, the extension number will take precedence and the extension name is ignored.
Implements GObservation.
Definition at line 254 of file GMWLObservation.cpp.
References clear(), filename(), G_READ, load(), m_instrument, gammalib::xml_file_expand(), and gammalib::xml_get_attr().
|
virtual |
Set response function.
[in] | rsp | Response function. |
GException::invalid_argument | Response rsp in not a MWL response. |
Sets the response function for the observation. The argument has to be of type GMWLResponse, otherwise an exception is thrown.
Implements GObservation.
Definition at line 214 of file GMWLObservation.cpp.
References G_RESPONSE, m_response, and GObservation::name().
|
inlinevirtual |
Return response.
Implements GObservation.
Definition at line 113 of file GMWLObservation.hpp.
References m_response.
|
virtual |
Write observation into XML element.
[in] | xml | XML element. |
Writes information for a multi-wavelength observation into an XML element. The format of the XML element is
<observation name="..." id="..." instrument="MWL"> <parameter name="Instrument" value="..."/> <parameter name="Data" file="..."/> </observation>
Implements GObservation.
Definition at line 287 of file GMWLObservation.cpp.
References GXmlElement::attribute(), G_WRITE, m_filename, m_instrument, gammalib::xml_file_reduce(), and gammalib::xml_need_par().
|
protected |
Filename.
Definition at line 90 of file GMWLObservation.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and write().
|
protected |
Instrument name.
Definition at line 89 of file GMWLObservation.hpp.
Referenced by copy_members(), init_members(), load(), read(), and write().
|
protected |
Response function.
Definition at line 91 of file GMWLObservation.hpp.
Referenced by copy_members(), init_members(), and response().