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

Light curve model class. More...

#include <GModelTemporalLightCurve.hpp>

Inheritance diagram for GModelTemporalLightCurve:
GModelTemporal GBase

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 GModelTemporalLightCurveoperator= (const GModelTemporalLightCurve &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear light curve model. More...
 
virtual GModelTemporalLightCurveclone (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 GFilenamefilename (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 GModelTemporaloperator= (const GModelTemporal &model)
 Assignment operator. More...
 
virtual GModelParoperator[] (const int &index)
 Returns model parameter. More...
 
virtual const GModelParoperator[] (const int &index) const
 Returns model parameter (const version) More...
 
virtual GModelParoperator[] (const std::string &name)
 Returns reference to model parameter. More...
 
virtual const GModelParoperator[] (const std::string &name) const
 Returns reference to model parameter (const version) More...
 
GModelParat (const int &index)
 Returns model parameter. More...
 
const GModelParat (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

GModelTemporalLightCurve::GModelTemporalLightCurve ( void  )

Void constructor.

Definition at line 64 of file GModelTemporalLightCurve.cpp.

References init_members().

Referenced by clone().

GModelTemporalLightCurve::GModelTemporalLightCurve ( const GXmlElement xml)
explicit

XML constructor.

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

Parameters
[in]filenameFile name of nodes.
[in]normNormalization 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.

Parameters
[in]modelLight curve model.

Definition at line 130 of file GModelTemporalLightCurve.cpp.

References copy_members(), and init_members().

GModelTemporalLightCurve::~GModelTemporalLightCurve ( void  )
virtual

Destructor.

Definition at line 147 of file GModelTemporalLightCurve.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelTemporal.

Definition at line 131 of file GModelTemporalLightCurve.hpp.

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

GModelTemporalLightCurve * GModelTemporalLightCurve::clone ( void  ) const
virtual

Clone light curve model.

Returns
Pointer to deep copy of light curve model.

Implements GModelTemporal.

Definition at line 222 of file GModelTemporalLightCurve.cpp.

References GModelTemporalLightCurve().

void GModelTemporalLightCurve::copy_members ( const GModelTemporalLightCurve model)
protected

Copy class members.

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

double GModelTemporalLightCurve::eval ( const GTime srcTime,
const bool &  gradients = false 
) const
virtual

Evaluate function.

Parameters
[in]srcTimeTrue photon arrival time (not used).
[in]gradientsCompute gradients?
Returns
Value of light curve model.

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

const GFilename & GModelTemporalLightCurve::filename ( void  ) const
inline

Return file name.

Returns
Name of node file.

Returns the name of the file function node file.

Definition at line 188 of file GModelTemporalLightCurve.hpp.

References m_filename.

Referenced by load_nodes().

void GModelTemporalLightCurve::filename ( const GFilename filename)
inline

Loads nodes from node file and set filename.

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

void GModelTemporalLightCurve::free_members ( void  )
protected

Delete class members.

Definition at line 564 of file GModelTemporalLightCurve.cpp.

Referenced by clear(), operator=(), and ~GModelTemporalLightCurve().

void GModelTemporalLightCurve::load_nodes ( const GFilename filename)
protected

Load nodes from file.

Parameters
[in]filenameFile name.
Exceptions
GException::invalid_valueFile 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().

GTimes GModelTemporalLightCurve::mc ( const double &  rate,
const GTime tmin,
const GTime tmax,
GRan ran 
) const
virtual

Returns vector of random event times.

Parameters
[in]rateMean event rate (events per second).
[in]tminMinimum event time.
[in]tmaxMaximum event time.
[in,out]ranRandom 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().

void GModelTemporalLightCurve::mc_update ( const GTime tmin,
const GTime tmax 
) const
protected

Set MC pre-computation cache.

Parameters
[in]tminMinimum time of time interval.
[in]tmaxMaximum 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().

double GModelTemporalLightCurve::norm ( void  ) const
inline

Return normalization factor.

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

void GModelTemporalLightCurve::norm ( const double &  norm)
inline

Set normalization factor.

Parameters
[in]normNormalization factor.

Sets the normalization factor.

Definition at line 173 of file GModelTemporalLightCurve.hpp.

References m_norm, and GOptimizerPar::value().

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

Assignment operator.

Parameters
[in]modelLight curve model.
Returns
Light curve model.

Definition at line 169 of file GModelTemporalLightCurve.cpp.

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

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

Print light curve information.

Parameters
[in]chatterChattiness.
Returns
String containing light curve information.

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

void GModelTemporalLightCurve::read ( const GXmlElement xml)
virtual

Read model from XML element.

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

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

Return model type.

Returns
"LightCurve".

Returns the type of the temporal model.

Implements GModelTemporal.

Definition at line 145 of file GModelTemporalLightCurve.hpp.

Referenced by write().

void GModelTemporalLightCurve::write ( GXmlElement xml) const
virtual

Write model into XML element.

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

Member Data Documentation

GFilename GModelTemporalLightCurve::m_filename
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().

std::vector<double> GModelTemporalLightCurve::m_mc_cum
mutableprotected

Cumulative distribution.

Definition at line 117 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_update().

std::vector<double> GModelTemporalLightCurve::m_mc_dt
mutableprotected

Length of interval.

Definition at line 121 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_update().

double GModelTemporalLightCurve::m_mc_eff_duration
mutableprotected

Effective duration.

Definition at line 116 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_update().

double GModelTemporalLightCurve::m_mc_norm
mutableprotected

Light curve normalisation.

Definition at line 115 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), and mc_update().

std::vector<double> GModelTemporalLightCurve::m_mc_offset
mutableprotected

Offset of interval.

Definition at line 119 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_update().

std::vector<double> GModelTemporalLightCurve::m_mc_slope
mutableprotected

Slope of interval.

Definition at line 118 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_update().

std::vector<double> GModelTemporalLightCurve::m_mc_time
mutableprotected

Start time of interval.

Definition at line 120 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_update().

GTime GModelTemporalLightCurve::m_mc_tmax
mutableprotected

Maximum time.

Definition at line 114 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), and mc_update().

GTime GModelTemporalLightCurve::m_mc_tmin
mutableprotected

Minimum time.

Definition at line 113 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), init_members(), and mc_update().

GNodeArray GModelTemporalLightCurve::m_nodes
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().

GModelPar GModelTemporalLightCurve::m_norm
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().

GTimeReference GModelTemporalLightCurve::m_timeref
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().

GTime GModelTemporalLightCurve::m_tmax
protected

Maximum time of model.

Definition at line 110 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), eval(), init_members(), load_nodes(), and print().

GTime GModelTemporalLightCurve::m_tmin
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().

std::vector<double> GModelTemporalLightCurve::m_values
protected

Function values at nodes.

Definition at line 106 of file GModelTemporalLightCurve.hpp.

Referenced by copy_members(), eval(), init_members(), load_nodes(), and print().


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