TS++ library: time series library

◆ operator()()

LinearInterpolator::Tvalue ts::ipo::LinearInterpolator::operator() ( const libtime::TAbsoluteTime &  t) const
virtual

calculate interpolated value

Parameters
ttime for value to return
Returns
new sample value at time t

Implements ts::ipo::Interpolator.

Definition at line 79 of file ipolin.cc.

References ts::ipo::Interpolator::debug(), ts::TimeSeries< S, H >::header, Madjustedfirst, Mdt, Minputwindow, ts::ipo::Interpolator::Mts, TSXX_assert, TSXX_debug, and TSXX_value.

80  {
81  using libtime::TAbsoluteTime;
82  using libtime::TRelativeTime;
83  const Tconst_series& s=this->Mts;
84  const Theader& hd=this->Mts.header;
85  //aff::Tsubscript ileft=s.f()+int(libtime::time2double(t-first)/hd.dt);
86  /*
87  * Notice that the division in libtime is defined to return the number
88  * of samples that will come closest to the time interval. That means
89  * that the operator round to the nearest integer and not to the lower
90  * integer. For this reason we use the adjusted time of first sample.
91  */
92  aff::Tsubscript ileft=s.first()+(t-Madjustedfirst)/Mdt;
93  TSXX_assert((Minputwindow.includes(t) && (ileft<=s.last())),
94  "requested sample lies outside time series");
95  aff::Tsubscript iright= (ileft < s.last()) ? ileft+1 : ileft;
96  double f=libtime::time2double(t-sff::wid2isample(hd, ileft-s.f()))/hd.dt;
97  TSXX_debug(this->debug(), "LinearInterpolator::operator():",
98  TSXX_value(ileft) << " " <<
99  TSXX_value(iright) << " " <<
100  TSXX_value(s.f()) << " " <<
101  TSXX_value(f) << " " <<
102  TSXX_value(hd.dt) << std::endl <<
103  " " << TSXX_value(Mdt.timestring())
104  << std::endl <<
105  " " << TSXX_value(Madjustedfirst.timestring())
106  << std::endl <<
107  " " << TSXX_value(sff::wid2isample(hd, ileft-s.f()).timestring())
108  << std::endl <<
109  " " << TSXX_value(t.timestring())
110  << std::endl <<
111  " " << TSXX_value(sff::wid2isample(hd, iright-s.f()).timestring())
112  << std::endl <<
113  " " << TSXX_value((t-Madjustedfirst).timestring())
114  << std::endl <<
115  " " << TSXX_value((t-Madjustedfirst)/Mdt)
116  );
117  Tvalue retval=((1.-f)*s(ileft)+f*s(iright));
118  return(retval);
119  }
Tconst_timeseries Mts
here we hold a copy
Definition: ipo.h:131
Tconst_timeseries::Theader Theader
Definition: ipo.h:118
#define TSXX_value(V)
report value
Definition: debug.h:66
libtime::TAbsoluteTime Madjustedfirst
Definition: ipolin.h:67
Ttimeseries::Tvalue Tvalue
Definition: ipo.h:119
#define TSXX_debug(C, N, M)
produce debug output
Definition: debug.h:51
libtime::TRelativeTime Mdt
Definition: ipolin.h:66
libtime::TRange Minputwindow
Definition: ipolin.h:68
Theader header
data header fields
Definition: tsxx.h:134
bool debug() const
indicate whether interpolator is in debug mode
Definition: ipo.h:126
#define TSXX_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:127
Tconst_timeseries::Tseries Tconst_series
Definition: ipo.h:117
Here is the call graph for this function: