44 #define G_READ "GModelTemporalLightCurve::read(GXmlElement&)"
45 #define G_WRITE "GModelTemporalLightCurve::write(GXmlElement&)"
46 #define G_LOAD_NODES "GModelTemporalLightCurve::load_nodes(GFilename&)"
172 if (
this != &model) {
255 const bool& gradients)
const
322 int ntimes = int(ran.
poisson(lambda)+0.5);
325 for (
int i = 0; i < ntimes; ++i) {
331 for (inx =
m_mc_cum.size()-1; inx > 0; --inx) {
438 result.append(
"=== GModelTemporalLightCurve ===");
445 for (
int i = 0; i <
size(); ++i) {
454 result.append(
" - ");
586 const double max_norm = 1.0 + 1.0e-8;
612 if (time_col->
nrows() < 2) {
613 std::string msg =
"\"TIME\" column contains "+
615 "least two rows are required. Please specify a valid "
616 "temporal file function.";
622 std::string msg =
"\"TIME\" and \"NORM\" columns have inconsistent "
626 "specify a valid temporal file function.";
631 int nodes = time_col->
nrows();
635 double last_time = -1.0;
636 for (
int i = 0; i < nodes; ++i) {
639 if (last_time >= 0.0 && time_col->
real(i) <= last_time) {
642 "column is equal to or smaller than preceeding "
643 "value. Please provide a light curve file with "
644 "monotonically increasing times.";
649 if (norm_col->
real(i) > max_norm) {
652 "larger than 1. Please provide a light curve file "
653 "with normalizations not exceeding 1.";
660 for (
int i = 0; i < nodes; ++i) {
666 for (
int i = 0; i <
m_values.size(); ++i) {
696 const GTime& tmax)
const
719 if (tmax >
m_tmin && tmin < m_tmax && tmax > tmin) {
738 if (tstart >= tstop) {
743 double rstart =
eval(tstart);
744 double rstop =
eval(tstop);
747 double norm = 0.5 * (rstart + rstop);
750 double dt = tstop - tstart;
751 double cum = norm * dt;
754 double slope = (rstop - rstart) / dt;
755 double offset = rstart;
756 double renorm = (0.5 * slope * dt + offset) * dt;
773 for (
int i = 1; i <
m_mc_cum.size(); ++i) {
777 for (
int i = 0; i <
m_mc_cum.size(); ++i) {
void clear(void)
Clear time reference.
int size(void) const
Return number of nodes in node array.
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.
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.
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.
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.
void nrows(const int &nrows)
Set number of rows in column.
void clear(void)
Clear node array.
void clear(void)
Clear time.
Random number generator class.
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.
void free_members(void)
Delete class members.
bool is_free(void) const
Signal if parameter is free.
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.
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.
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.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void clear(void)
Clear parameter.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
const std::string & timesys(void) const
Return time system.
Abstract interface for FITS table.
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.
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)
void clear(void)
Clear file name.
Temporal model registry class definition.
virtual double real(const int &row, const int &inx=0) const =0
virtual GModelTemporalLightCurve & operator=(const GModelTemporalLightCurve &model)
Assignment operator.
double poisson(const double &lambda)
Returns Poisson deviates.
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.
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.
virtual std::string type(void) const
Return model type.
GTime m_mc_tmin
Minimum time.
void init_members(void)
Initialise class members.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void append(const double &node)
Append one node to array.
double norm(void) const
Return normalization factor.
void close(void)
Close FITS file.
GTime m_mc_tmax
Maximum time.
std::vector< double > m_mc_dt
Length of interval.
void set(const double &time, const GTimeReference &ref)
Set time given in specified reference.
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.
double convert(const GTimeReference &ref) const
Return time in specified reference.
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.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.