GammaLib
2.1.0.dev
|
Temporal phase curve model class. More...
#include <GModelTemporalPhaseCurve.hpp>
Public Member Functions | |
GModelTemporalPhaseCurve (void) | |
Void constructor. More... | |
GModelTemporalPhaseCurve (const GXmlElement &xml) | |
XML constructor. More... | |
GModelTemporalPhaseCurve (const GFilename &filename, const GTime &mjd, const double &phase, const double &f0, const double &f1, const double &f2, const double &norm=1.0, const bool &normalize=true) | |
File constructor. More... | |
GModelTemporalPhaseCurve (const GModelTemporalPhaseCurve &model) | |
Copy constructor. More... | |
virtual | ~GModelTemporalPhaseCurve (void) |
Destructor. More... | |
virtual GModelTemporalPhaseCurve & | operator= (const GModelTemporalPhaseCurve &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear phase curve. More... | |
virtual GModelTemporalPhaseCurve * | clone (void) const |
Clone phase curve. 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 |
Return 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 phase 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... | |
GTime | mjd (void) const |
Return reference Modified Julian Day. More... | |
void | mjd (const GTime &time) |
Set reference Modified Julian Day. More... | |
double | phase (void) const |
Return phase at reference Modified Julian Day. More... | |
double | phase (const GTime &time) const |
Computes the phase for a given time. More... | |
void | phase (const double &phase) |
Set phase at reference Modified Julian Day. More... | |
double | value (const double &phase) const |
Evaluate phase curve value for a given phase. More... | |
double | f0 (void) const |
Return frequency at reference Modified Julian Day. More... | |
void | f0 (const double &f0) |
Set frequency at reference Modified Julian Day. More... | |
double | f1 (void) const |
Return first frequency derivative at reference Modified Julian Day. More... | |
void | f1 (const double &f1) |
Set first frequency derivative at reference Modified Julian Day. More... | |
double | f2 (void) const |
Return second frequency derivative at reference Modified Julian Day. More... | |
void | f2 (const double &f2) |
Set second frequency derivative at reference Modified Julian Day. More... | |
bool | normalize (void) const |
Return normalization flag. 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 GModelTemporalPhaseCurve &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 | normalize_nodes (void) |
Normalise nodes. 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... | |
GModelPar | m_mjd |
Reference MJD. More... | |
GModelPar | m_phase |
Phase at reference MJD. More... | |
GModelPar | m_f0 |
Frequency at reference MJD. More... | |
GModelPar | m_f1 |
First freq. derivative at reference MJD. More... | |
GModelPar | m_f2 |
Second freq. derivative at reference MJD. More... | |
bool | m_normalize |
Normalize phase curve (default: true) More... | |
bool | m_has_normalize |
XML has normalize attribute. More... | |
GNodeArray | m_nodes |
Phase values of nodes. More... | |
std::vector< double > | m_values |
Function values at nodes. More... | |
double | m_scale |
Scale factor due to normalization. More... | |
GFilename | m_filename |
Name of phase file function. More... | |
Protected Attributes inherited from GModelTemporal | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. More... | |
Temporal phase curve model class.
This class implements a temporal variation based on the phase \(\Phi(t)\) that is computed using
\[ \Phi(t) = \Phi_0 + f(t-t_0) + \frac{1}{2}\dot{f} (t-t_0)^2 + \frac{1}{6}\ddot{f} (t-t_0)^3 \]
where \(t_0\) is a reference time, \(\Phi_0\) is the phase at the reference time, \(f\) is the variation frequency at the reference time, \(\dot{f}\) is the first derivative of the variation frequency at the reference time, and \(\ddot{f}\) is the second derivative of the variation frequency at the reference time.
The temporal variation is then computed using
\[ S_{\rm t}(t) = r(\Phi(t)) \times {\tt m\_norm} \]
where \(r(\Phi(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 76 of file GModelTemporalPhaseCurve.hpp.
GModelTemporalPhaseCurve::GModelTemporalPhaseCurve | ( | void | ) |
Void constructor.
Definition at line 68 of file GModelTemporalPhaseCurve.cpp.
References init_members().
Referenced by clone().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs phase curve 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 136 of file GModelTemporalPhaseCurve.cpp.
References init_members(), and read().
GModelTemporalPhaseCurve::GModelTemporalPhaseCurve | ( | const GFilename & | filename, |
const GTime & | mjd, | ||
const double & | phase, | ||
const double & | f0, | ||
const double & | f1, | ||
const double & | f2, | ||
const double & | norm = 1.0 , |
||
const bool & | normalize = true |
||
) |
File constructor.
[in] | filename | File name of phase curve nodes. |
[in] | mjd | Reference time. |
[in] | phase | Phase at reference time. |
[in] | f0 | Frequency at reference time (Hz). |
[in] | f1 | First frequency derivative at reference time. |
[in] | f2 | Second frequency derivative at reference time. |
[in] | norm | Normalization factor. |
[in] | normalize | Normalize phase curve? |
Constructs phase curve from a list of nodes that is found in the specified FITS file, a reference time and phase information at the reference time. See the load_nodes() method for more information about the expected structure of the file.
Definition at line 95 of file GModelTemporalPhaseCurve.cpp.
References f0(), f1(), f2(), init_members(), load_nodes(), m_normalize, mjd(), norm(), normalize(), and phase().
GModelTemporalPhaseCurve::GModelTemporalPhaseCurve | ( | const GModelTemporalPhaseCurve & | model | ) |
Copy constructor.
[in] | model | Phase curve. |
Definition at line 155 of file GModelTemporalPhaseCurve.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModelTemporal.
Definition at line 160 of file GModelTemporalPhaseCurve.hpp.
|
virtual |
Clear phase curve.
Implements GModelTemporal.
Definition at line 227 of file GModelTemporalPhaseCurve.cpp.
References GModelTemporal::free_members(), free_members(), GModelTemporal::init_members(), and init_members().
Referenced by GCOMSelection::init_members(), and GCOMSelection::orbital_period().
|
virtual |
Clone phase curve.
Implements GModelTemporal.
Definition at line 247 of file GModelTemporalPhaseCurve.cpp.
References GModelTemporalPhaseCurve().
|
protected |
Copy class members.
[in] | model | Phase curve. |
Definition at line 695 of file GModelTemporalPhaseCurve.cpp.
References m_f0, m_f1, m_f2, m_filename, m_has_normalize, m_mjd, m_nodes, m_norm, m_normalize, GModelTemporal::m_pars, m_phase, m_scale, and m_values.
Referenced by GModelTemporalPhaseCurve(), and operator=().
|
virtual |
Evaluate function.
[in] | srcTime | True photon arrival time. |
[in] | gradients | Compute gradients? |
Computes
\[ S_{\rm t}(t) = r(\Phi(t)) \times {\tt m\_norm} \]
where
\(r(\Phi(t))\) is the phase dependent rate, defined by linear interpolation between the nodes in a FITS file, \(\Phi(t)\) is the time dependent phase, and \({\tt m\_norm}\) is a normalisation constant.
Implements GModelTemporal.
Definition at line 273 of file GModelTemporalPhaseCurve.cpp.
References GOptimizerPar::factor_gradient(), GNodeArray::interpolate(), GOptimizerPar::is_free(), m_nodes, m_norm, m_values, phase(), GOptimizerPar::scale(), GOptimizerPar::value(), and value().
Referenced by mc().
|
inline |
Return frequency at reference Modified Julian Day.
Returns the frequency at reference Modified Julian Day.
Definition at line 306 of file GModelTemporalPhaseCurve.hpp.
References m_f0, and GOptimizerPar::value().
Referenced by GModelTemporalPhaseCurve(), GCOMSelection::orbital_period(), phase(), read(), and write().
|
inline |
Set frequency at reference Modified Julian Day.
[in] | f0 | Frequency at reference Modified Julian Day. |
Sets the frequency at reference Modified Julian Day.
Definition at line 320 of file GModelTemporalPhaseCurve.hpp.
References m_f0, and GOptimizerPar::value().
|
inline |
Return first frequency derivative at reference Modified Julian Day.
Returns the first frequency derivative at reference Modified Julian Day.
Definition at line 335 of file GModelTemporalPhaseCurve.hpp.
References m_f1, and GOptimizerPar::value().
Referenced by GModelTemporalPhaseCurve(), GCOMSelection::orbital_period(), phase(), read(), and write().
|
inline |
Set first frequency derivative at reference Modified Julian Day.
[in] | f1 | First frequency derivative at reference Modified Julian Day. |
Sets the first frequency derivative at reference Modified Julian Day.
Definition at line 349 of file GModelTemporalPhaseCurve.hpp.
References m_f1, and GOptimizerPar::value().
|
inline |
Return second frequency derivative at reference Modified Julian Day.
Returns the second frequency derivative at reference Modified Julian Day.
Definition at line 364 of file GModelTemporalPhaseCurve.hpp.
References m_f2, and GOptimizerPar::value().
Referenced by GModelTemporalPhaseCurve(), GCOMSelection::orbital_period(), phase(), read(), and write().
|
inline |
Set second frequency derivative at reference Modified Julian Day.
[in] | f2 | Second frequency derivative at reference Modified Julian Day. |
Sets the second frequency derivative at reference Modified Julian Day.
Definition at line 378 of file GModelTemporalPhaseCurve.hpp.
References m_f2, and GOptimizerPar::value().
|
inline |
Return file name.
Returns the name of the file function node file.
Definition at line 188 of file GModelTemporalPhaseCurve.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 GModelTemporalPhaseCurve.hpp.
References load_nodes().
|
protected |
Delete class members.
Definition at line 728 of file GModelTemporalPhaseCurve.cpp.
Referenced by clear(), operator=(), and ~GModelTemporalPhaseCurve().
|
protected |
Initialise class members.
Definition at line 600 of file GModelTemporalPhaseCurve.cpp.
References GNodeArray::clear(), GFilename::clear(), GOptimizerPar::clear(), GOptimizerPar::fix(), GOptimizerPar::free(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_f0, m_f1, m_f2, m_filename, m_has_normalize, m_mjd, m_nodes, m_norm, m_normalize, GModelTemporal::m_pars, m_phase, m_scale, m_values, GOptimizerPar::name(), GOptimizerPar::range(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().
Referenced by clear(), GModelTemporalPhaseCurve(), and operator=().
|
protected |
Load nodes from file.
[in] | filename | File name. |
GException::invalid_value | Phase curve FITS file is invalid |
Load the phase curve nodes from a FITS file. The information is expected in the first extension of the FITS file, containing two mandatory columns with names "PHASE" and "NORM".
Definition at line 747 of file GModelTemporalPhaseCurve.cpp.
References GNodeArray::append(), GNodeArray::clear(), GFits::close(), filename(), G_LOAD_NODES, GFilename::is_empty(), m_filename, m_nodes, m_normalize, m_values, normalize_nodes(), GFitsTableCol::nrows(), GFitsTableCol::real(), gammalib::str(), and GFits::table().
Referenced by filename(), GModelTemporalPhaseCurve(), and read().
|
virtual |
Return 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. |
Returns a vector of random event times between tmin
and tmax
for the phase curve.
Implements GModelTemporal.
Definition at line 312 of file GModelTemporalPhaseCurve.cpp.
References GTimes::append(), eval(), GRan::exp(), m_scale, norm(), GTime::secs(), GRan::uniform(), and value().
|
inline |
Return reference Modified Julian Day.
Returns the reference Modified Julian Day.
Definition at line 246 of file GModelTemporalPhaseCurve.hpp.
References m_mjd, GTime::mjd(), and GOptimizerPar::value().
Referenced by GModelTemporalPhaseCurve(), GCOMSelection::orbital_period(), phase(), read(), and write().
|
inline |
Set reference Modified Julian Day.
[in] | mjd | Reference Modified Julian Day. |
Sets the reference Modified Julian Day.
Definition at line 262 of file GModelTemporalPhaseCurve.hpp.
References m_mjd, GTime::mjd(), and GOptimizerPar::value().
|
inline |
Return normalization factor.
Returns the normalization factor.
Definition at line 217 of file GModelTemporalPhaseCurve.hpp.
References m_norm, and GOptimizerPar::value().
Referenced by GModelTemporalPhaseCurve(), mc(), read(), and write().
|
inline |
Set normalization factor.
[in] | norm | Normalization factor. |
Sets the normalization factor.
Definition at line 231 of file GModelTemporalPhaseCurve.hpp.
References m_norm, and GOptimizerPar::value().
|
inline |
Return normalization flag.
Signals whether a phase curve has been normalized or not.
Definition at line 393 of file GModelTemporalPhaseCurve.hpp.
References m_normalize.
Referenced by GModelTemporalPhaseCurve(), and print().
|
protected |
Normalise nodes.
GException::invalid_value | Phase curve FITS file is invalid |
Normalise the node values so that the integral over the phase interval [0,1] gives an average normalisation of 1.
Definition at line 882 of file GModelTemporalPhaseCurve.cpp.
References G_NORMALISE_NODES, GNodeArray::interpolate(), m_nodes, m_scale, m_values, GNodeArray::size(), gammalib::str(), and sum().
Referenced by load_nodes().
|
virtual |
Assignment operator.
[in] | model | Phase curve. |
Definition at line 194 of file GModelTemporalPhaseCurve.cpp.
References copy_members(), free_members(), init_members(), and GModelTemporal::operator=().
|
inline |
Return phase at reference Modified Julian Day.
Returns the phase at reference Modified Julian Day.
Definition at line 277 of file GModelTemporalPhaseCurve.hpp.
References m_phase, and GOptimizerPar::value().
Referenced by eval(), GModelTemporalPhaseCurve(), GCOMSelection::orbital_period(), GCOMSelection::orbital_phase(), phase(), read(), and write().
double GModelTemporalPhaseCurve::phase | ( | const GTime & | time | ) | const |
Computes the phase for a given time.
[in] | time | Time. |
Computes
\[ \Phi(t) = \Phi_0 + f(t-t_0) + \frac{1}{2}\dot{f} (t-t_0)^2 + \frac{1}{6}\ddot{f} (t-t_0)^3 \]
where \(t\) is the specified time
in seconds, \(t_0\) is a reference time in seconds, \(\Phi_0\) is the phase at the reference time, \(f\) is the variation frequency at the reference time, \(\dot{f}\) is the first derivative of the variation frequency at the reference time, and \(\dot{f}\) is the second derivative of the variation frequency at the reference time.
The phase \(\Phi(t)\) is in the interval [0,1].
Definition at line 496 of file GModelTemporalPhaseCurve.cpp.
|
inline |
Set phase at reference Modified Julian Day.
[in] | phase | Phase at reference Modified Julian Day. |
Sets the phase at reference Modified Julian Day.
Definition at line 291 of file GModelTemporalPhaseCurve.hpp.
References m_phase, and GOptimizerPar::value().
Print phase curve information.
[in] | chatter | Chattiness. |
Implements GModelTemporal.
Definition at line 550 of file GModelTemporalPhaseCurve.cpp.
References EXPLICIT, m_filename, m_nodes, GModelTemporal::m_pars, m_values, normalize(), gammalib::parformat(), SILENT, GNodeArray::size(), GModelTemporal::size(), gammalib::str(), and GFilename::url().
Referenced by GCOMSelection::print().
|
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="PhaseCurve" file="phase.fits"> <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="0"/> <parameter name="MJD" scale="1" value="51544.5" min="0.0" max="1e10" free="0"/> <parameter name="Phase" scale="1" value="0.0" min="0.0" max="1e10" free="1"/> <parameter name="F0" scale="1" value="1.0" min="0.0" max="1e10" free="1"/> <parameter name="F1" scale="1" value="0.1" min="0.0" max="1e10" free="1"/> <parameter name="F2" scale="1" value="0.01" min="0.0" max="1e10" free="1"/> </temporalModel>
Implements GModelTemporal.
Definition at line 376 of file GModelTemporalPhaseCurve.cpp.
References GXmlElement::attribute(), f0(), f1(), f2(), G_READ, GXmlElement::has_attribute(), load_nodes(), m_f0, m_f1, m_f2, m_has_normalize, m_mjd, m_norm, m_normalize, m_phase, mjd(), GOptimizerPar::name(), norm(), phase(), GModelPar::read(), gammalib::tolower(), gammalib::xml_check_parnum(), gammalib::xml_file_expand(), and gammalib::xml_get_par().
Referenced by GModelTemporalPhaseCurve().
|
inlinevirtual |
Return model type.
Returns the type of the temporal model.
Implements GModelTemporal.
Definition at line 174 of file GModelTemporalPhaseCurve.hpp.
Referenced by write().
double GModelTemporalPhaseCurve::value | ( | const double & | phase | ) | const |
Evaluate phase curve value for a given phase.
[in] | phase | Phase. |
Computes
\[ S_{\rm t}(\Phi) = r(\Phi) \times {\tt m\_norm} \]
where
\(r(\Phi)\) is the phase dependent rate, defined by linear interpolation between the nodes in a FITS file, \(\Phi\) is the phase, and \({\tt m\_norm}\) is a normalisation constant.
Definition at line 534 of file GModelTemporalPhaseCurve.cpp.
References GNodeArray::interpolate(), m_nodes, m_norm, m_values, and GOptimizerPar::value().
|
virtual |
Write model into XML element.
[in] | xml | XML element. |
Writes the temporal information into an XML element. The XML element will have the format
<temporalModel type="PhaseCurve" file="phase.fits"> <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="0"/> <parameter name="MJD" scale="1" value="51544.5" min="0.0" max="1e10" free="0"/> <parameter name="Phase" scale="1" value="0.0" min="0.0" max="1e10" free="1"/> <parameter name="F0" scale="1" value="1.0" min="0.0" max="1e10" free="1"/> <parameter name="F1" scale="1" value="0.1" min="0.0" max="1e10" free="1"/> <parameter name="F2" scale="1" value="0.01" min="0.0" max="1e10" free="1"/> </temporalModel>
Implements GModelTemporal.
Definition at line 433 of file GModelTemporalPhaseCurve.cpp.
References GXmlElement::attribute(), f0(), f1(), f2(), G_WRITE, m_f0, m_f1, m_f2, m_filename, m_has_normalize, m_mjd, m_norm, m_normalize, m_phase, mjd(), GOptimizerPar::name(), norm(), phase(), type(), GModelPar::write(), gammalib::xml_check_type(), gammalib::xml_file_reduce(), and gammalib::xml_need_par().
|
protected |
Frequency at reference MJD.
Definition at line 140 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), f0(), init_members(), read(), and write().
|
protected |
First freq. derivative at reference MJD.
Definition at line 141 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), f1(), init_members(), read(), and write().
|
protected |
Second freq. derivative at reference MJD.
Definition at line 142 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), f2(), init_members(), read(), and write().
|
protected |
Name of phase file function.
Definition at line 150 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), filename(), init_members(), load_nodes(), print(), and write().
|
protected |
XML has normalize attribute.
Definition at line 144 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), init_members(), read(), and write().
|
protected |
Reference MJD.
Definition at line 138 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), init_members(), mjd(), read(), and write().
|
mutableprotected |
Phase values of nodes.
Definition at line 147 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), normalize_nodes(), print(), and value().
|
protected |
Normalization factor.
Definition at line 137 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), eval(), init_members(), norm(), read(), value(), and write().
|
protected |
Normalize phase curve (default: true)
Definition at line 143 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), GModelTemporalPhaseCurve(), init_members(), load_nodes(), normalize(), read(), and write().
|
protected |
Phase at reference MJD.
Definition at line 139 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), init_members(), phase(), read(), and write().
|
protected |
Scale factor due to normalization.
Definition at line 149 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), init_members(), mc(), and normalize_nodes().
|
protected |
Function values at nodes.
Definition at line 148 of file GModelTemporalPhaseCurve.hpp.
Referenced by copy_members(), eval(), init_members(), load_nodes(), normalize_nodes(), print(), and value().