GammaLib
2.1.0.dev
|
Light curve model class. More...
#include <GModelTemporalLightCurve.hpp>
Public Member Functions | |
GModelTemporalLightCurve (void) | |
Void constructor. More... | |
GModelTemporalLightCurve (const GXmlElement &xml) | |
XML constructor. More... | |
GModelTemporalLightCurve (const GFilename &filename, const double &norm=1.0) | |
File constructor. More... | |
GModelTemporalLightCurve (const GModelTemporalLightCurve &model) | |
Copy constructor. More... | |
virtual | ~GModelTemporalLightCurve (void) |
Destructor. More... | |
virtual GModelTemporalLightCurve & | operator= (const GModelTemporalLightCurve &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear light curve model. More... | |
virtual GModelTemporalLightCurve * | clone (void) const |
Clone light curve model. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual std::string | type (void) const |
Return model type. More... | |
virtual double | eval (const GTime &srcTime, const bool &gradients=false) const |
Evaluate function. More... | |
virtual GTimes | mc (const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const |
Returns vector of random event times. More... | |
virtual void | read (const GXmlElement &xml) |
Read model from XML element. More... | |
virtual void | write (GXmlElement &xml) const |
Write model into XML element. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print light curve information. More... | |
const GFilename & | filename (void) const |
Return file name. More... | |
void | filename (const GFilename &filename) |
Loads nodes from node file and set filename. More... | |
double | norm (void) const |
Return normalization factor. More... | |
void | norm (const double &norm) |
Set normalization factor. More... | |
Public Member Functions inherited from GModelTemporal | |
GModelTemporal (void) | |
Void constructor. More... | |
GModelTemporal (const GModelTemporal &model) | |
Copy constructor. More... | |
virtual | ~GModelTemporal (void) |
Destructor. More... | |
virtual GModelTemporal & | operator= (const GModelTemporal &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns model parameter (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns reference to model parameter. More... | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns reference to model parameter (const version) More... | |
GModelPar & | at (const int &index) |
Returns model parameter. More... | |
const GModelPar & | at (const int &index) const |
Returns model parameter (const version) More... | |
bool | has_par (const std::string &name) const |
Checks if parameter name exists. More... | |
int | size (void) const |
Return number of parameters. More... | |
void | autoscale (void) |
Autoscale parameters. 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 GModelTemporalLightCurve &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | load_nodes (const GFilename &filename) |
Load nodes from file. More... | |
void | mc_update (const GTime &tmin, const GTime &tmax) const |
Set MC pre-computation cache. More... | |
Protected Member Functions inherited from GModelTemporal | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModelTemporal &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GModelPar | m_norm |
Normalization factor. More... | |
GNodeArray | m_nodes |
Time nodes of function. More... | |
std::vector< double > | m_values |
Function values at nodes. More... | |
GFilename | m_filename |
Name of file function. More... | |
GTimeReference | m_timeref |
Time reference. More... | |
GTime | m_tmin |
Minimum time of model. More... | |
GTime | m_tmax |
Maximum time of model. More... | |
GTime | m_mc_tmin |
Minimum time. More... | |
GTime | m_mc_tmax |
Maximum time. More... | |
double | m_mc_norm |
Light curve normalisation. More... | |
double | m_mc_eff_duration |
Effective duration. More... | |
std::vector< double > | m_mc_cum |
Cumulative distribution. More... | |
std::vector< double > | m_mc_slope |
Slope of interval. More... | |
std::vector< double > | m_mc_offset |
Offset of interval. More... | |
std::vector< double > | m_mc_time |
Start time of interval. More... | |
std::vector< double > | m_mc_dt |
Length of interval. More... | |
Protected Attributes inherited from GModelTemporal | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. More... | |
Light curve model class.
This class implements a light curve defined by nodes given specified in a FITS file. The model is defined by
\[ S_{\rm t}(t) = r(t) \times {\tt m\_norm} \]
where \(r(t)\) is the rate defined by linear interpolation between the nodes in a FITS file, and \({\tt m\_norm}\) is a normalisation constant.
Definition at line 62 of file GModelTemporalLightCurve.hpp.
GModelTemporalLightCurve::GModelTemporalLightCurve | ( | void | ) |
Void constructor.
Definition at line 64 of file GModelTemporalLightCurve.cpp.
References init_members().
Referenced by clone().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs light curve model by extracting information from an XML element. See the read() method for more information about the expected structure of the XML element.
Definition at line 111 of file GModelTemporalLightCurve.cpp.
References init_members(), and read().
GModelTemporalLightCurve::GModelTemporalLightCurve | ( | const GFilename & | filename, |
const double & | norm = 1.0 |
||
) |
File constructor.
[in] | filename | File name of nodes. |
[in] | norm | Normalization factor. |
Constructs light curve model from a list of nodes that is found in the specified FITS file. See the load_nodes() method for more information about the expected structure of the file.
Definition at line 84 of file GModelTemporalLightCurve.cpp.
References init_members(), load_nodes(), m_norm, and GOptimizerPar::value().
GModelTemporalLightCurve::GModelTemporalLightCurve | ( | const GModelTemporalLightCurve & | model | ) |
Copy constructor.
[in] | model | Light curve model. |
Definition at line 130 of file GModelTemporalLightCurve.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModelTemporal.
Definition at line 131 of file GModelTemporalLightCurve.hpp.
|
virtual |
Clear light curve model.
Implements GModelTemporal.
Definition at line 202 of file GModelTemporalLightCurve.cpp.
References GModelTemporal::free_members(), free_members(), GModelTemporal::init_members(), and init_members().
|
virtual |
Clone light curve model.
Implements GModelTemporal.
Definition at line 222 of file GModelTemporalLightCurve.cpp.
References GModelTemporalLightCurve().
|
protected |
Copy class members.
[in] | model | Light curve model. |
Definition at line 530 of file GModelTemporalLightCurve.cpp.
References m_filename, m_mc_cum, m_mc_dt, m_mc_eff_duration, m_mc_norm, m_mc_offset, m_mc_slope, m_mc_time, m_mc_tmax, m_mc_tmin, m_nodes, m_norm, GModelTemporal::m_pars, m_timeref, m_tmax, m_tmin, and m_values.
Referenced by GModelTemporalLightCurve(), and operator=().
|
virtual |
Evaluate function.
[in] | srcTime | True photon arrival time (not used). |
[in] | gradients | Compute gradients? |
Computes
\[ S_{\rm t}(t) = r(t) \times {\tt m\_norm} \]
where \(r(t)\) is the light curve, computed by linear interpolation between the nodes in a FITS file, and \({\tt m\_norm}\) is the normalization constant.
If the gradients
flag is true the method will also evaluate the partial derivatives of the model with respect to the normalization parameter using
\[ \frac{\delta S_{\rm t}(t)}{\delta {\tt m\_norm}} = r(t) \]
Implements GModelTemporal.
Definition at line 254 of file GModelTemporalLightCurve.cpp.
References GTime::convert(), GOptimizerPar::factor_gradient(), GNodeArray::interpolate(), GOptimizerPar::is_free(), m_nodes, m_norm, m_timeref, m_tmax, m_tmin, m_values, GOptimizerPar::scale(), and GOptimizerPar::value().
Referenced by mc_update().
|
inline |
Return file name.
Returns the name of the file function node file.
Definition at line 188 of file GModelTemporalLightCurve.hpp.
References m_filename.
Referenced by load_nodes().
|
inline |
Loads nodes from node file and set filename.
[in] | filename | Node file name. |
Loads the nodes from a file function node file and sets the filename.
Definition at line 202 of file GModelTemporalLightCurve.hpp.
References load_nodes().
|
protected |
Delete class members.
Definition at line 564 of file GModelTemporalLightCurve.cpp.
Referenced by clear(), operator=(), and ~GModelTemporalLightCurve().
|
protected |
Initialise class members.
Definition at line 484 of file GModelTemporalLightCurve.cpp.
References GNodeArray::clear(), GTimeReference::clear(), GFilename::clear(), GTime::clear(), GOptimizerPar::clear(), GOptimizerPar::fix(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_filename, m_mc_cum, m_mc_dt, m_mc_eff_duration, m_mc_norm, m_mc_offset, m_mc_slope, m_mc_time, m_mc_tmax, m_mc_tmin, m_nodes, m_norm, GModelTemporal::m_pars, m_timeref, m_tmax, m_tmin, m_values, GOptimizerPar::name(), GOptimizerPar::range(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().
Referenced by clear(), GModelTemporalLightCurve(), and operator=().
|
protected |
Load nodes from file.
[in] | filename | File name. |
GException::invalid_value | File function FITS file is invalid |
Load the light curve nodes from a FITS file. The light curve nodes are expected in the first extension of the FITS file, containing two mandatory columns with names "TIME" and "NORM".
Definition at line 583 of file GModelTemporalLightCurve.cpp.
References GNodeArray::append(), GNodeArray::clear(), GFits::close(), filename(), G_LOAD_NODES, GFilename::is_empty(), m_filename, m_nodes, m_timeref, m_tmax, m_tmin, m_values, GFitsTableCol::nrows(), GTimeReference::read(), GFitsTableCol::real(), GTime::set(), gammalib::str(), and GFits::table().
Referenced by filename(), GModelTemporalLightCurve(), and read().
|
virtual |
Returns vector of random event times.
[in] | rate | Mean event rate (events per second). |
[in] | tmin | Minimum event time. |
[in] | tmax | Maximum event time. |
[in,out] | ran | Random number generator. |
This method returns a vector of random event times between tmin
and tmax
assuming a light curve specified in a FITS file.
Implements GModelTemporal.
Definition at line 303 of file GModelTemporalLightCurve.cpp.
References GTimes::append(), m_mc_cum, m_mc_dt, m_mc_eff_duration, m_mc_offset, m_mc_slope, m_mc_time, m_timeref, mc_update(), GRan::poisson(), sqrt(), and GRan::uniform().
Set MC pre-computation cache.
[in] | tmin | Minimum time of time interval. |
[in] | tmax | Maximum time of time interval. |
This method sets up an array of indices and the cumulative distribution function needed for MC simulations.
Definition at line 695 of file GModelTemporalLightCurve.cpp.
References eval(), m_mc_cum, m_mc_dt, m_mc_eff_duration, m_mc_norm, m_mc_offset, m_mc_slope, m_mc_time, m_mc_tmax, m_mc_tmin, m_nodes, m_norm, m_timeref, m_tmin, norm(), GNodeArray::size(), and GOptimizerPar::value().
Referenced by mc().
|
inline |
Return normalization factor.
Returns the normalization factor.
Definition at line 159 of file GModelTemporalLightCurve.hpp.
References m_norm, and GOptimizerPar::value().
Referenced by mc_update(), read(), and write().
|
inline |
Set normalization factor.
[in] | norm | Normalization factor. |
Sets the normalization factor.
Definition at line 173 of file GModelTemporalLightCurve.hpp.
References m_norm, and GOptimizerPar::value().
|
virtual |
Assignment operator.
[in] | model | Light curve model. |
Definition at line 169 of file GModelTemporalLightCurve.cpp.
References copy_members(), free_members(), init_members(), and GModelTemporal::operator=().
Print light curve information.
[in] | chatter | Chattiness. |
Implements GModelTemporal.
Definition at line 429 of file GModelTemporalLightCurve.cpp.
References GTime::convert(), m_filename, m_nodes, GModelTemporal::m_pars, m_timeref, m_tmax, m_tmin, m_values, GTimeReference::mjdref(), gammalib::parformat(), SILENT, GNodeArray::size(), GModelTemporal::size(), gammalib::str(), GTimeReference::timesys(), GTimeReference::timeunit(), and GFilename::url().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
Reads the temporal information from an XML element. The XML element should have the format
<temporalModel type="LightCurve" file=".."> <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="1"/> </temporalModel>
Implements GModelTemporal.
Definition at line 374 of file GModelTemporalLightCurve.cpp.
References GXmlElement::attribute(), G_READ, load_nodes(), m_norm, GOptimizerPar::name(), norm(), GModelPar::read(), gammalib::xml_check_parnum(), gammalib::xml_file_expand(), and gammalib::xml_get_par().
Referenced by GModelTemporalLightCurve().
|
inlinevirtual |
Return model type.
Returns the type of the temporal model.
Implements GModelTemporal.
Definition at line 145 of file GModelTemporalLightCurve.hpp.
Referenced by write().
|
virtual |
Write model into XML element.
[in] | xml | XML element. |
Writes the temporal information into an XML element in the format
<temporalModel type="LightCurve" file=".."> <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="1"/> </temporalModel>
Implements GModelTemporal.
Definition at line 404 of file GModelTemporalLightCurve.cpp.
References GXmlElement::attribute(), G_WRITE, m_filename, m_norm, GOptimizerPar::name(), norm(), type(), GModelPar::write(), gammalib::xml_check_type(), gammalib::xml_file_reduce(), and gammalib::xml_need_par().
|
protected |
Name of file function.
Definition at line 107 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), filename(), init_members(), load_nodes(), print(), and write().
|
mutableprotected |
Cumulative distribution.
Definition at line 117 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Length of interval.
Definition at line 121 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Effective duration.
Definition at line 116 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Light curve normalisation.
Definition at line 115 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), and mc_update().
|
mutableprotected |
Offset of interval.
Definition at line 119 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Slope of interval.
Definition at line 118 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Start time of interval.
Definition at line 120 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_update().
|
mutableprotected |
Maximum time.
Definition at line 114 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), and mc_update().
|
mutableprotected |
Minimum time.
Definition at line 113 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), init_members(), and mc_update().
|
mutableprotected |
Time nodes of function.
Definition at line 105 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), mc_update(), and print().
|
protected |
Normalization factor.
Definition at line 104 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), eval(), GModelTemporalLightCurve(), init_members(), mc_update(), norm(), read(), and write().
|
protected |
Time reference.
Definition at line 108 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), mc(), mc_update(), and print().
|
protected |
Maximum time of model.
Definition at line 110 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), and print().
|
protected |
Minimum time of model.
Definition at line 109 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), mc_update(), and print().
|
protected |
Function values at nodes.
Definition at line 106 of file GModelTemporalLightCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), and print().