Commit 7925ead4 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libtsxx [WP]: provide debug output for interpolator class and function resamp

parent 9e893568
......@@ -40,6 +40,7 @@
"TF_IPO_CC V1.2"
#include <tsxx/ipo.h>
#include <tsxx/debug.h>
namespace ts {
......@@ -53,6 +54,9 @@ namespace ts {
: Exception(message, file, line, cond)
{ }
/* ----------------------------------------------------------------------
*/
// exception constructor
ExceptionTimeWindowEmpty::ExceptionTimeWindowEmpty(const char* message,
const char* file,
......@@ -61,6 +65,9 @@ namespace ts {
: Exception(message, file, line, cond)
{ }
/* ======================================================================
*/
//! resample a time series
ts::TDsfftimeseries resample(const Interpolator& ip,
const libtime::TAbsoluteTime& first,
......@@ -101,6 +108,14 @@ namespace ts {
"new time window is empty",
ExceptionTimeWindowEmpty);
}
TSXX_debug(ip.debug(), "resample",
"window covered by input series:\n "
<< old_first.timestring() << " - "
<< old_last.timestring());
TSXX_debug(ip.debug(), "resample",
"window requested for output series:\n "
<< new_first.timestring() << " - "
<< new_last.timestring());
TRange inputwindow(old_first, old_last);
TRange outputwindow(new_first, new_last);
TSXX_Xassert((inputwindow.includes(outputwindow)),
......@@ -113,7 +128,7 @@ namespace ts {
TAbsoluteTime it=new_first;
for (int i=0; i<nsamples; ++i) { retval(i)=ip(it); it += dt; }
return(retval);
}
} // ts::TDsfftimeseries resample(...)
} // namespace ipo
......
......@@ -122,10 +122,16 @@ namespace ts {
Theader header() const { return(Mts.header); }
Tconst_series series() const { return(Mts); }
Tconst_timeseries timeseries() const { return(Mts); }
//! indicate whether interpolator is in debug mode
bool debug() const { return(Mdebug); }
protected:
Interpolator(Tconst_timeseries ts): Mts(ts) { }
Interpolator(Tconst_timeseries ts, const bool& debug=false):
Mts(ts), Mdebug(debug) { }
//! here we hold a copy
Tconst_timeseries Mts;
private:
//! produce debug output
bool Mdebug;
}; // class Interpolator
/*! \brief function to resample data
......
......@@ -45,8 +45,7 @@ namespace ts {
*/
LinearInterpolator::LinearInterpolator(const Tconst_timeseries& ts,
const bool& debug):
Tbase(ts),
Mdebug(debug),
Tbase(ts, debug),
Mlast(sff::wid2lastsample(Mts.header)),
Mdt(libtime::double2time(Mts.header.dt)),
Madjustedfirst(Mts.header.date+(Mdt/2)),
......@@ -79,7 +78,7 @@ namespace ts {
"requested sample lies outside time series");
aff::Tsubscript iright= (ileft < s.l()) ? ileft+1 : ileft;
double f=libtime::time2double(t-sff::wid2isample(hd, ileft))/hd.dt;
if (Mdebug)
if (this->debug())
{
std::cout << "DEBUG: LinearInterpolator::operator():" << std::endl;
std::cout << TF_IPOLIN_CC_VERSION << std::endl;
......
......@@ -62,7 +62,6 @@ namespace ts {
~LinearInterpolator() { }
Tvalue operator()(const libtime::TAbsoluteTime& t) const;
private:
bool Mdebug;
libtime::TAbsoluteTime Mlast;
libtime::TRelativeTime Mdt;
libtime::TAbsoluteTime Madjustedfirst;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment