47 #define G_READ "GModelTemporalPhaseCurve::read(GXmlElement&)"
48 #define G_WRITE "GModelTemporalPhaseCurve::write(GXmlElement&)"
49 #define G_LOAD_NODES "GModelTemporalPhaseCurve::load_nodes(GFilename&)"
50 #define G_NORMALISE_NODES "GModelTemporalPhaseCurve::normalize_nodes()"
102 const bool& normalize) :
197 if (
this != &model) {
274 const bool& gradients)
const
322 double time = tmin.
secs();
323 double tstop = tmax.
secs();
326 while (time <= tstop) {
329 time += ran.
exp(lambda);
348 if (uniform <= value) {
402 std::string arg = xml.
attribute(
"normalize");
499 const double c1 = 0.5;
500 const double c2 = 1.0 / 6.0;
503 double dt = time -
mjd();
506 double phase = this->
phase() + dt * (
f0() + dt * (c1 *
f1() + c2 *
f2() * dt));
509 phase -= floor(phase);
559 result.append(
"=== GModelTemporalPhaseCurve ===");
565 result.append(
" [normalized]");
569 for (
int i = 0; i <
size(); ++i) {
750 const double max_norm = 1.0 + 1.0e-8;
773 if (phase_col->
nrows() < 2) {
774 std::string msg =
"\"PHASE\" column contains "+
776 "least two rows are required. Please specify a valid "
782 if (phase_col->
nrows() != norm_col->
nrows()) {
783 std::string msg =
"\"PHASE\" and \"NORM\" columns have inconsistent "
787 "specify a valid phase curve file.";
792 int nodes = phase_col->
nrows();
796 double last_phase = -1.0;
797 for (
int i = 0; i < nodes; ++i) {
800 if (last_phase >= 0.0 && phase_col->
real(i) <= last_phase) {
803 "column is equal to or smaller than preceeding "
804 "value. Please provide a phase curve file with "
805 "monotonically increasing phase values.";
810 if (phase_col->
real(i) < 0.0 || phase_col->
real(i) > 1.0) {
812 " outside range [0,1]. Please provide a phase "
813 "curve file with phase values comprised in the "
819 if (norm_col->
real(i) > max_norm) {
822 "larger than 1. Please provide a phase curve file "
823 "with normalizations not exceeding 1.";
832 if (phase_col->
real(0) > 0.0) {
838 for (
int i = 0; i < nodes; ++i) {
846 if (phase_col->
real(nodes-1) < 1.0) {
852 for (
int i = 0; i <
m_values.size(); ++i) {
899 sum += 0.5 * (b - a) * (fa + fb);
905 std::string msg =
"Integral over phase curve is not positive ("+
915 for (
int i = 0; i <
m_values.size(); ++i) {
int size(void) const
Return number of nodes in node array.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
bool m_has_normalize
XML has normalize attribute.
const double & factor_gradient(void) const
Return parameter factor gradient.
double norm(const GVector &vector)
Computes vector norm.
std::vector< GModelPar * > m_pars
Parameter pointers.
bool normalize(void) const
Return normalization flag.
const std::string & name(void) const
Return parameter name.
GNodeArray m_nodes
Phase values of nodes.
double gradient(void) const
Return parameter gradient.
Abstract temporal model base class.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
GTime mjd(void) const
Return reference Modified Julian Day.
void init_members(void)
Initialise class members.
GModelPar m_f0
Frequency at reference MJD.
bool m_normalize
Normalize phase curve (default: true)
bool is_empty(void) const
Signal if filename is empty.
double m_scale
Scale factor due to normalization.
void nrows(const int &nrows)
Set number of rows in column.
void clear(void)
Clear node array.
double sum(const GVector &vector)
Computes vector sum.
Random number generator class.
std::vector< double > m_values
Function values at nodes.
FITS file class interface definition.
double f2(void) const
Return second frequency derivative at reference Modified Julian Day.
virtual GModelTemporalPhaseCurve & operator=(const GModelTemporalPhaseCurve &model)
Assignment operator.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
virtual GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const
Return vector of random event times.
bool is_free(void) const
Signal if parameter is free.
FITS table column abstract base class definition.
const double & scale(void) const
Return parameter scale.
virtual std::string type(void) const
Return model type.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
void free(void)
Free a parameter.
Temporal phase curve model class interface definition.
Abstract interface for FITS table column.
void fix(void)
Fix a parameter.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
void load_nodes(const GFilename &filename)
Load nodes from file.
int size(void) const
Return number of parameters.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void clear(void)
Clear parameter.
double f0(void) const
Return frequency at reference Modified Julian Day.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
Abstract interface for FITS table.
void copy_members(const GModelTemporalPhaseCurve &model)
Copy class members.
void free_members(void)
Delete class members.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual ~GModelTemporalPhaseCurve(void)
Destructor.
GModelPar m_f1
First freq. derivative at reference MJD.
GModelPar m_norm
Normalization factor.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
double phase(void) const
Return phase at reference Modified Julian Day.
#define G_NORMALISE_NODES
Interface definition for the temporal model registry class.
double value(const double &phase) const
Evaluate phase curve value for a given phase.
const GFilename & filename(void) const
Return file name.
const double & secs(void) const
Return time in seconds in native reference (TT)
std::string url(void) const
Return Uniform Resource Locator (URL)
double norm(void) const
Return normalization factor.
void clear(void)
Clear file name.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print phase curve information.
GModelPar m_f2
Second freq. derivative at reference MJD.
Temporal model registry class definition.
virtual double real(const int &row, const int &inx=0) const =0
GModelTemporalPhaseCurve(void)
Void constructor.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
virtual GModelTemporal & operator=(const GModelTemporal &model)
Assignment operator.
const std::string & unit(void) const
Return parameter unit.
Exception handler interface definition.
double f1(void) const
Return first frequency derivative at reference Modified Julian Day.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const
Evaluate function.
std::string tolower(const std::string &s)
Convert string to lower case.
virtual GModelTemporalPhaseCurve * clone(void) const
Clone phase curve.
void init_members(void)
Initialise class members.
GModelPar m_phase
Phase at reference MJD.
GModelPar m_mjd
Reference MJD.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void normalize_nodes(void)
Normalise nodes.
void append(const double &node)
Append one node to array.
GFilename m_filename
Name of phase file function.
void close(void)
Close FITS file.
Temporal phase curve model class.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
void append(const GTime &time)
Append time to container.
const GModelTemporalPhaseCurve g_temporal_phase_seed
virtual void write(GXmlElement &xml) const
Write model into XML element.
void free_members(void)
Delete class members.
virtual void clear(void)
Clear phase curve.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.
double exp(const double &lambda)
Returns exponential deviates.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.