GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelTemporalLightCurve.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelTemporalLightCurve.cpp - Temporal light curve model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-2021 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GModelTemporalLightCurve.cpp
23  * @brief Light curve model class interface implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GTools.hpp"
32 #include "GException.hpp"
35 #include "GFits.hpp"
36 
37 /* __ Constants __________________________________________________________ */
38 
39 /* __ Globals ____________________________________________________________ */
41 const GModelTemporalRegistry g_temporal_lightcurve_registry(&g_temporal_lightcurve_seed);
42 
43 /* __ Method name definitions ____________________________________________ */
44 #define G_READ "GModelTemporalLightCurve::read(GXmlElement&)"
45 #define G_WRITE "GModelTemporalLightCurve::write(GXmlElement&)"
46 #define G_LOAD_NODES "GModelTemporalLightCurve::load_nodes(GFilename&)"
47 
48 /* __ Macros _____________________________________________________________ */
49 
50 /* __ Coding definitions _________________________________________________ */
51 
52 /* __ Debug definitions __________________________________________________ */
53 
54 
55 /*==========================================================================
56  = =
57  = Constructors/destructors =
58  = =
59  ==========================================================================*/
60 
61 /***********************************************************************//**
62  * @brief Void constructor
63  ***************************************************************************/
65 {
66  // Initialise members
67  init_members();
68 
69  // Return
70  return;
71 }
72 
73 
74 /***********************************************************************//**
75  * @brief File constructor
76  *
77  * @param[in] filename File name of nodes.
78  * @param[in] norm Normalization factor.
79  *
80  * Constructs light curve model from a list of nodes that is found in the
81  * specified FITS file. See the load_nodes() method for more information
82  * about the expected structure of the file.
83  ***************************************************************************/
85  const double& norm) :
87 {
88  // Initialise members
89  init_members();
90 
91  // Load nodes
92  load_nodes(filename);
93 
94  // Set normalization
95  m_norm.value(norm);
96 
97  // Return
98  return;
99 }
100 
101 
102 /***********************************************************************//**
103  * @brief XML constructor
104  *
105  * @param[in] xml XML element.
106  *
107  * Constructs light curve model by extracting information from an XML
108  * element. See the read() method for more information about the expected
109  * structure of the XML element.
110  ***************************************************************************/
113 {
114  // Initialise members
115  init_members();
116 
117  // Read information from XML element
118  read(xml);
119 
120  // Return
121  return;
122 }
123 
124 
125 /***********************************************************************//**
126  * @brief Copy constructor
127  *
128  * @param[in] model Light curve model.
129  ***************************************************************************/
131  GModelTemporal(model)
132 {
133  // Initialise members
134  init_members();
135 
136  // Copy members
137  copy_members(model);
138 
139  // Return
140  return;
141 }
142 
143 
144 /***********************************************************************//**
145  * @brief Destructor
146  ***************************************************************************/
148 {
149  // Free members
150  free_members();
151 
152  // Return
153  return;
154 }
155 
156 
157 /*==========================================================================
158  = =
159  = Operators =
160  = =
161  ==========================================================================*/
162 
163 /***********************************************************************//**
164  * @brief Assignment operator
165  *
166  * @param[in] model Light curve model.
167  * @return Light curve model.
168  ***************************************************************************/
170 {
171  // Execute only if object is not identical
172  if (this != &model) {
173 
174  // Copy base class members
175  this->GModelTemporal::operator=(model);
176 
177  // Free members
178  free_members();
179 
180  // Initialise members
181  init_members();
182 
183  // Copy members
184  copy_members(model);
185 
186  } // endif: object was not identical
187 
188  // Return
189  return *this;
190 }
191 
192 
193 /*==========================================================================
194  = =
195  = Public methods =
196  = =
197  ==========================================================================*/
198 
199 /***********************************************************************//**
200  * @brief Clear light curve model
201  ***************************************************************************/
203 {
204  // Free class members (base and derived classes, derived class first)
205  free_members();
207 
208  // Initialise members
210  init_members();
211 
212  // Return
213  return;
214 }
215 
216 
217 /***********************************************************************//**
218  * @brief Clone light curve model
219  *
220  * @return Pointer to deep copy of light curve model.
221  ***************************************************************************/
223 {
224  // Clone constant temporal model
225  return new GModelTemporalLightCurve(*this);
226 }
227 
228 
229 /***********************************************************************//**
230  * @brief Evaluate function
231  *
232  * @param[in] srcTime True photon arrival time (not used).
233  * @param[in] gradients Compute gradients?
234  * @return Value of light curve model.
235  *
236  * Computes
237  *
238  * \f[
239  * S_{\rm t}(t) = r(t) \times {\tt m\_norm}
240  * \f]
241  *
242  * where
243  * \f$r(t)\f$ is the light curve, computed by linear interpolation between
244  * the nodes in a FITS file, and \f${\tt m\_norm}\f$ is the normalization
245  * constant.
246  *
247  * If the @p gradients flag is true the method will also evaluate the partial
248  * derivatives of the model with respect to the normalization parameter using
249  *
250  * \f[
251  * \frac{\delta S_{\rm t}(t)}{\delta {\tt m\_norm}} = r(t)
252  * \f]
253  ***************************************************************************/
254 double GModelTemporalLightCurve::eval(const GTime& srcTime,
255  const bool& gradients) const
256 {
257  // Initialise value
258  double value = 0.0;
259 
260  // Optionally initialise gradient
261  if (gradients) {
262  m_norm.factor_gradient(0.0);
263  }
264 
265  // Set value if the time is within the validity range
266  if (srcTime >= m_tmin && srcTime <= m_tmax) {
267 
268  // Interpolate file function
269  double func = m_nodes.interpolate(srcTime.convert(m_timeref), m_values);
270 
271  // Compute function value
272  value = m_norm.value() * func;
273 
274  // Optionally compute gradients
275  if (gradients) {
276 
277  // Compute partial derivatives of the parameter values
278  double g_norm = (m_norm.is_free()) ? m_norm.scale() * func : 0.0;
279 
280  // Set gradients
281  m_norm.factor_gradient(g_norm);
282 
283  } // endif: gradient computation was requested
284 
285  } // endif: time was within the validity range
286 
287  // Return
288  return value;
289 }
290 
291 
292 /***********************************************************************//**
293  * @brief Returns vector of random event times
294  *
295  * @param[in] rate Mean event rate (events per second).
296  * @param[in] tmin Minimum event time.
297  * @param[in] tmax Maximum event time.
298  * @param[in,out] ran Random number generator.
299  *
300  * This method returns a vector of random event times between @p tmin and
301  * @p tmax assuming a light curve specified in a FITS file.
302  ***************************************************************************/
303 GTimes GModelTemporalLightCurve::mc(const double& rate, const GTime& tmin,
304  const GTime& tmax, GRan& ran) const
305 {
306  // Allocates empty vector of times
307  GTimes times;
308 
309  // Update Monte Carlo cache
310  mc_update(tmin, tmax);
311 
312  // Continue only if effective duration is positive and cache is not empty
313  if (m_mc_eff_duration > 0.0 && m_mc_cum.size() > 0) {
314 
315  // Compute mean number of times by multiplying the rate with the
316  // effective duration. Note that the light curve normalization factor
317  // is already included in the effective rate, hence we should not
318  // multiply it here again (see #2181).
319  double lambda = rate * m_mc_eff_duration;
320 
321  // Compute number of times to be sampled
322  int ntimes = int(ran.poisson(lambda)+0.5);
323 
324  // Loop over number of times
325  for (int i = 0; i < ntimes; ++i) {
326 
327  // Determine in which bin we reside
328  int inx = 0;
329  if (m_mc_cum.size() > 1) {
330  double u = ran.uniform();
331  for (inx = m_mc_cum.size()-1; inx > 0; --inx) {
332  if (m_mc_cum[inx-1] <= u) {
333  break;
334  }
335  }
336  }
337 
338  // Get random time
339  double seconds;
340  if (m_mc_slope[inx] == 0.0) {
341  seconds = m_mc_dt[inx] * ran.uniform() + m_mc_time[inx];
342  }
343  else {
344  seconds = (std::sqrt(m_mc_offset[inx]*m_mc_offset[inx] +
345  2.0 * m_mc_slope[inx] * ran.uniform()) -
346  m_mc_offset[inx]) / m_mc_slope[inx] + m_mc_time[inx];
347  }
348 
349  // Append random time
350  GTime time(seconds, m_timeref);
351  times.append(time);
352 
353  } // endfor: looped over times
354 
355  } // endif: cache was valid
356 
357  // Return vector of times
358  return times;
359 }
360 
361 
362 /***********************************************************************//**
363  * @brief Read model from XML element
364  *
365  * @param[in] xml XML element.
366  *
367  * Reads the temporal information from an XML element. The XML element should
368  * have the format
369  *
370  * <temporalModel type="LightCurve" file="..">
371  * <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="1"/>
372  * </temporalModel>
373  ***************************************************************************/
375 {
376  // Verify number of model parameters
378 
379  // Get parameter pointers
381 
382  // Read parameters
383  m_norm.read(*norm);
384 
385  // Load nodes from file
387 
388  // Return
389  return;
390 }
391 
392 
393 /***********************************************************************//**
394  * @brief Write model into XML element
395  *
396  * @param[in] xml XML element.
397  *
398  * Writes the temporal information into an XML element in the format
399  *
400  * <temporalModel type="LightCurve" file="..">
401  * <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="1"/>
402  * </temporalModel>
403  ***************************************************************************/
405 {
406  // Verify model type
408 
409  // Get XML parameters
411 
412  // Write parameters
413  m_norm.write(*norm);
414 
415  // Set file attribute
417 
418  // Return
419  return;
420 }
421 
422 
423 /***********************************************************************//**
424  * @brief Print light curve information
425  *
426  * @param[in] chatter Chattiness.
427  * @return String containing light curve information.
428  ***************************************************************************/
429 std::string GModelTemporalLightCurve::print(const GChatter& chatter) const
430 {
431  // Initialise result string
432  std::string result;
433 
434  // Continue only if chatter is not silent
435  if (chatter != SILENT) {
436 
437  // Append header
438  result.append("=== GModelTemporalLightCurve ===");
439 
440  // Append information
441  result.append("\n"+gammalib::parformat("Light curve file"));
442  result.append(m_filename.url());
443  result.append("\n"+gammalib::parformat("Number of parameters"));
444  result.append(gammalib::str(size()));
445  for (int i = 0; i < size(); ++i) {
446  result.append("\n"+m_pars[i]->print(chatter));
447  }
448 
449  // Append reference MJD and time range
450  result.append("\n"+gammalib::parformat("Reference MDJ"));
451  result.append(gammalib::str(m_timeref.mjdref()));
452  result.append("\n"+gammalib::parformat("Time range"));
453  result.append(gammalib::str(m_tmin.convert(m_timeref)));
454  result.append(" - ");
455  result.append(gammalib::str(m_tmax.convert(m_timeref)));
456  result.append(" "+m_timeref.timeunit());
457  result.append(" ("+m_timeref.timesys()+")");
458 
459  // Append node information
460  result.append("\n"+gammalib::parformat("Number of nodes"));
461  result.append(gammalib::str(m_nodes.size()));
462  for (int i = 0; i < m_nodes.size(); ++i) {
463  result.append("\n");
464  result.append(gammalib::parformat(" Time "+gammalib::str(m_nodes[i])+" s"));
465  result.append(gammalib::str(m_values[i]));
466  }
467 
468  } // endif: chatter was not silent
469 
470  // Return result
471  return result;
472 }
473 
474 
475 /*==========================================================================
476  = =
477  = Private methods =
478  = =
479  ==========================================================================*/
480 
481 /***********************************************************************//**
482  * @brief Initialise class members
483  ***************************************************************************/
485 {
486  // Initialise normalisation parameter
487  m_norm.clear();
488  m_norm.name("Normalization");
489  m_norm.unit("(relative value)");
490  m_norm.scale(1.0);
491  m_norm.value(1.0);
492  m_norm.range(0.0,1000.0);
493  m_norm.fix();
494  m_norm.gradient(0.0);
495  m_norm.has_grad(true);
496 
497  // Set parameter pointer(s)
498  m_pars.clear();
499  m_pars.push_back(&m_norm);
500 
501  // Initialise members
502  m_nodes.clear();
503  m_values.clear();
504  m_filename.clear();
505  m_timeref.clear();
506  m_tmin.clear();
507  m_tmax.clear();
508 
509  // Initialise cache
510  m_mc_tmin.clear();
511  m_mc_tmax.clear();
512  m_mc_norm = 0.0;
513  m_mc_eff_duration = 0.0;
514  m_mc_cum.clear();
515  m_mc_slope.clear();
516  m_mc_offset.clear();
517  m_mc_time.clear();
518  m_mc_dt.clear();
519 
520  // Return
521  return;
522 }
523 
524 
525 /***********************************************************************//**
526  * @brief Copy class members
527  *
528  * @param[in] model Light curve model.
529  ***************************************************************************/
531 {
532  // Copy members
533  m_norm = model.m_norm;
534  m_nodes = model.m_nodes;
535  m_values = model.m_values;
536  m_filename = model.m_filename;
537  m_timeref = model.m_timeref;
538  m_tmin = model.m_tmin;
539  m_tmax = model.m_tmax;
540 
541  // Copy cache
542  m_mc_tmin = model.m_mc_tmin;
543  m_mc_tmax = model.m_mc_tmax;
544  m_mc_norm = model.m_mc_norm;
546  m_mc_cum = model.m_mc_cum;
547  m_mc_slope = model.m_mc_slope;
548  m_mc_offset = model.m_mc_offset;
549  m_mc_time = model.m_mc_time;
550  m_mc_dt = model.m_mc_dt;
551 
552  // Set parameter pointer(s)
553  m_pars.clear();
554  m_pars.push_back(&m_norm);
555 
556  // Return
557  return;
558 }
559 
560 
561 /***********************************************************************//**
562  * @brief Delete class members
563  ***************************************************************************/
565 {
566  // Return
567  return;
568 }
569 
570 
571 /***********************************************************************//**
572  * @brief Load nodes from file
573  *
574  * @param[in] filename File name.
575  *
576  * @exception GException::invalid_value
577  * File function FITS file is invalid
578  *
579  * Load the light curve nodes from a FITS file. The light curve nodes are
580  * expected in the first extension of the FITS file, containing two mandatory
581  * columns with names "TIME" and "NORM".
582  ***************************************************************************/
584 {
585  // Set maximum light curve normalization value, including a small margin
586  const double max_norm = 1.0 + 1.0e-8;
587 
588  // Clear nodes and values
589  m_nodes.clear();
590  m_values.clear();
591 
592  // Set filename
594 
595  // Continue only if filename is not empty
596  if (!filename.is_empty()) {
597 
598  // Load FITS file
599  GFits fits = GFits(filename);
600 
601  // Extract binary table (so far always load extension 1 as table)
602  GFitsTable* table = fits.table(1);
603 
604  // Read time reference from binary table
605  m_timeref.read(*table);
606 
607  // Extract columns
608  GFitsTableCol* time_col = (*table)["TIME"];
609  GFitsTableCol* norm_col = (*table)["NORM"];
610 
611  // Check that there are at least two nodes in table
612  if (time_col->nrows() < 2) {
613  std::string msg = "\"TIME\" column contains "+
614  gammalib::str(time_col->nrows())+" rows but at "
615  "least two rows are required. Please specify a valid "
616  "temporal file function.";
618  }
619 
620  // Check that both columns are consistent
621  if (time_col->nrows() != norm_col->nrows()) {
622  std::string msg = "\"TIME\" and \"NORM\" columns have inconsistent "
623  "number of rows ("+
624  gammalib::str(time_col->nrows())+", "+
625  gammalib::str(norm_col->nrows())+"). Please "
626  "specify a valid temporal file function.";
628  }
629 
630  // Set number of nodes
631  int nodes = time_col->nrows();
632 
633  // Check that time values are in ascending order and that no node is
634  // larger than 1
635  double last_time = -1.0;
636  for (int i = 0; i < nodes; ++i) {
637 
638  // Check if time has increased
639  if (last_time >= 0.0 && time_col->real(i) <= last_time) {
640  std::string msg = "Time "+gammalib::str(time_col->real(i))+
641  " in row "+gammalib::str(i+1)+" of \"TIME\" "
642  "column is equal to or smaller than preceeding "
643  "value. Please provide a light curve file with "
644  "monotonically increasing times.";
646  }
647 
648  // Check if value is smaller than maximum allowed normalisation
649  if (norm_col->real(i) > max_norm) {
650  std::string msg = "Value "+gammalib::str(norm_col->real(i))+" at "
651  "time "+gammalib::str(time_col->real(i))+" is "
652  "larger than 1. Please provide a light curve file "
653  "with normalizations not exceeding 1.";
655  }
656 
657  } // endfor: looped over nodes
658 
659  // Extract nodes
660  for (int i = 0; i < nodes; ++i) {
661  m_nodes.append(time_col->real(i));
662  m_values.push_back(norm_col->real(i));
663  }
664 
665  // Make sure that no node exceeds 1
666  for (int i = 0; i < m_values.size(); ++i) {
667  if (m_values[i] > 1.0) {
668  m_values[i] = 1.0;
669  }
670  }
671 
672  // Set minimum and maximum times (assumes that times are ordered)
673  m_tmin.set(time_col->real(0), m_timeref);
674  m_tmax.set(time_col->real(time_col->nrows()-1), m_timeref);
675 
676  // Close FITS file
677  fits.close();
678 
679  } // endif: filename was not empty
680 
681  // Return
682  return;
683 }
684 
685 
686 /***********************************************************************//**
687  * @brief Set MC pre-computation cache
688  *
689  * @param[in] tmin Minimum time of time interval.
690  * @param[in] tmax Maximum time of time interval.
691  *
692  * This method sets up an array of indices and the cumulative distribution
693  * function needed for MC simulations.
694  ***************************************************************************/
696  const GTime& tmax) const
697 {
698  // Get light curve normalisation value to see whether it has changed
699  double norm = m_norm.value();
700 
701  // Update the cache only if the time interval or normalisation has changed
702  if (tmin != m_mc_tmin || tmax != m_mc_tmax || norm != m_mc_norm) {
703 
704  // Store new time interval and normalisation value
705  m_mc_tmin = tmin;
706  m_mc_tmax = tmax;
707  m_mc_norm = norm;
708 
709  // Initialise cache
710  m_mc_eff_duration = 0.0;
711  m_mc_cum.clear();
712  m_mc_slope.clear();
713  m_mc_offset.clear();
714  m_mc_time.clear();
715  m_mc_dt.clear();
716 
717  // Continue only if time interval overlaps with temporal file function
718  // and if time interval is valid
719  if (tmax > m_tmin && tmin < m_tmax && tmax > tmin) {
720 
721  // Loop over all intervals between the nodes
722  for (int i = 0; i < m_nodes.size()-1; ++i) {
723 
724  // Get start and stop time of interval
725  GTime tstart(m_nodes[i], m_timeref);
726  GTime tstop(m_nodes[i+1], m_timeref);
727 
728  // Make sure that we only consider the interval that overlaps
729  // with the requested time interval
730  if (tmin > tstart) {
731  tstart = tmin;
732  }
733  if (tmax < tstop) {
734  tstop = tmax;
735  }
736 
737  // If time interval is empty then skip this node
738  if (tstart >= tstop) {
739  continue;
740  }
741 
742  // Evaluate rate at start and stop time
743  double rstart = eval(tstart);
744  double rstop = eval(tstop);
745 
746  // Compute mean normalization for this interval
747  double norm = 0.5 * (rstart + rstop);
748 
749  // Compute integral for this interval
750  double dt = tstop - tstart;
751  double cum = norm * dt;
752 
753  // Compute slope, offset and start time of interval
754  double slope = (rstop - rstart) / dt;
755  double offset = rstart;
756  double renorm = (0.5 * slope * dt + offset) * dt;
757  slope /= renorm;
758  offset /= renorm;
759 
760  // Update effective duration
761  m_mc_eff_duration += cum;
762 
763  // Put mean normalization and integral on stack
764  m_mc_cum.push_back(cum);
765  m_mc_slope.push_back(slope);
766  m_mc_offset.push_back(offset);
767  m_mc_time.push_back(tstart.convert(m_timeref));
768  m_mc_dt.push_back(dt);
769 
770  } // endfor: next interval
771 
772  // Build cumulative distribution
773  for (int i = 1; i < m_mc_cum.size(); ++i) {
774  m_mc_cum[i] += m_mc_cum[i-1];
775  }
776  double norm = m_mc_cum[m_mc_cum.size()-1];
777  for (int i = 0; i < m_mc_cum.size(); ++i) {
778  m_mc_cum[i] /= norm;
779  }
780 
781  } // endif: time interval overlaps
782 
783  } // endif: Update was required
784 
785  // Return
786  return;
787 }
void clear(void)
Clear time reference.
int size(void) const
Return number of nodes in node array.
Definition: GNodeArray.hpp:192
std::vector< double > m_mc_time
Start time of interval.
std::vector< double > m_mc_cum
Cumulative distribution.
void copy_members(const GModelTemporalLightCurve &model)
Copy class members.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Definition: GFits.cpp:482
GTime m_tmax
Maximum time of model.
std::vector< double > m_mc_slope
Slope of interval.
const double & factor_gradient(void) const
Return parameter factor gradient.
GTimeReference m_timeref
Time reference.
double norm(const GVector &vector)
Computes vector norm.
Definition: GVector.cpp:864
const std::string & timeunit(void) const
Return time unit.
std::vector< double > m_mc_offset
Offset of interval.
void mc_update(const GTime &tmin, const GTime &tmax) const
Set MC pre-computation cache.
GModelTemporalLightCurve(void)
Void constructor.
std::vector< GModelPar * > m_pars
Parameter pointers.
const std::string & name(void) const
Return parameter name.
double gradient(void) const
Return parameter gradient.
Abstract temporal model base class.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print light curve information.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
Definition: GModelPar.cpp:351
const GFilename & filename(void) const
Return file name.
void read(const GFitsHDU &hdu)
Read time reference from FITS header.
virtual ~GModelTemporalLightCurve(void)
Destructor.
bool is_empty(void) const
Signal if filename is empty.
Definition: GFilename.hpp:160
XML element node class.
Definition: GXmlElement.hpp:48
void nrows(const int &nrows)
Set number of rows in column.
void clear(void)
Clear node array.
Definition: GNodeArray.cpp:235
void clear(void)
Clear time.
Definition: GTime.cpp:252
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
Gammalib tools definition.
FITS file class.
Definition: GFits.hpp:63
FITS file class interface definition.
double m_mc_norm
Light curve normalisation.
GFilename m_filename
Name of file function.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
Definition: GTools.cpp:1946
void free_members(void)
Delete class members.
bool is_free(void) const
Signal if parameter is free.
Time container class.
Definition: GTimes.hpp:45
std::vector< double > m_values
Function values at nodes.
virtual GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const
Returns vector of random event times.
const double & scale(void) const
Return parameter scale.
GModelPar m_norm
Normalization factor.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
Definition: GVector.cpp:1358
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
virtual void read(const GXmlElement &xml)
Read model from XML element.
const double & mjdref(void) const
Return MJD reference (units: days)
const GXmlAttribute * attribute(const int &index) const
Return attribute.
#define G_WRITE
Filename class.
Definition: GFilename.hpp:62
Abstract interface for FITS table column.
void fix(void)
Fix a parameter.
virtual void clear(void)
Clear light curve model.
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.
Definition: GTools.cpp:1637
double uniform(void)
Returns random double precision floating value in range 0 to 1.
Definition: GRan.cpp:242
void clear(void)
Clear parameter.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
Definition: GNodeArray.cpp:536
const std::string & timesys(void) const
Return time system.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
virtual double eval(const GTime &srcTime, const bool &gradients=false) const
Evaluate function.
const GModelTemporalLightCurve g_temporal_lightcurve_seed
GTime m_tmin
Minimum time of model.
void load_nodes(const GFilename &filename)
Load nodes from file.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
Definition: GTools.cpp:1777
Interface definition for the temporal model registry class.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GModelTemporalLightCurve * clone(void) const
Clone light curve model.
std::string url(void) const
Return Uniform Resource Locator (URL)
Definition: GFilename.hpp:189
void clear(void)
Clear file name.
Definition: GFilename.cpp:188
Temporal model registry class definition.
virtual double real(const int &row, const int &inx=0) const =0
Light curve model class.
virtual GModelTemporalLightCurve & operator=(const GModelTemporalLightCurve &model)
Assignment operator.
double poisson(const double &lambda)
Returns Poisson deviates.
Definition: GRan.cpp:316
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
GNodeArray m_nodes
Time nodes of function.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
Definition: GModelPar.cpp:229
double value(void) const
Return parameter value.
virtual GModelTemporal & operator=(const GModelTemporal &model)
Assignment operator.
#define G_READ
const std::string & unit(void) const
Return parameter unit.
Exception handler interface definition.
virtual std::string type(void) const
Return model type.
void init_members(void)
Initialise class members.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1143
void append(const double &node)
Append one node to array.
Definition: GNodeArray.cpp:351
double norm(void) const
Return normalization factor.
void close(void)
Close FITS file.
Definition: GFits.cpp:1342
std::vector< double > m_mc_dt
Length of interval.
void set(const double &time, const GTimeReference &ref)
Set time given in specified reference.
Definition: GTime.cpp:1005
#define G_LOAD_NODES
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.
Definition: GTools.cpp:1689
void append(const GTime &time)
Append time to container.
Definition: GTimes.cpp:216
double convert(const GTimeReference &ref) const
Return time in specified reference.
Definition: GTime.cpp:698
void init_members(void)
Initialise class members.
double m_mc_eff_duration
Effective duration.
Light curve model class interface definition.
void free_members(void)
Delete class members.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.
Definition: GTools.cpp:1889
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:489
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.
Definition: GTools.cpp:1819