Commit 068cb7b8 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libtsxx [WP]: provide trim functions in TimeSeriesCollection

parent 56c1d03d
......@@ -182,7 +182,7 @@ namespace ts {
if (this->size() > 1)
{
// find lastest start date
typename Tbase::const_iterator i_series=this->begin();
typename Tbase::iterator i_series=this->begin();
Theader header=i_series->header;
libtime::TAbsoluteTime begin=header.date;
++i_series;
......@@ -195,6 +195,20 @@ namespace ts {
}
// adjust series and header
i_series=this->begin();
while (i_series != this->end())
{
header=i_series->header;
long int index_offset=wid2isample(header, begin);
TSXX_assert(index_offset >= 0,
"inconsistent header data");
TSXX_assert(index_offset > header.nsamples,
"time series does not overlap with others");
i_series->header.date=begin;
i_series->header.nsamples -= index_offset;
i_series->data.setfirstindex(i_series.data.f()+index_offset);
++i_series;
}
}
} // void TimeSeriesCollection<T>::trim_to_date()
......@@ -211,7 +225,7 @@ namespace ts {
if (this->size() > 1)
{
// find smallest number of samples in collection
typename Tbase::const_iterator i_series=this->begin();
typename Tbase::iterator i_series=this->begin();
Theader header=i_series->header;
unsigned int nsamples=header.nsamples;
++i_series;
......@@ -222,6 +236,15 @@ namespace ts {
end = thisnsamples < nsamples ? thisnsamples : nsamples;
++i_series;
}
// adjust number of samples
i_series=this->begin();
while (i_series != this->end())
{
i_series->header.nsamples = nsamples;
i_series->data.setlastindex(i_series.data.f()+nsamples-1);
++i_series;
}
}
} // void TimeSeriesCollection<T>::trim_to_nsamples()
......
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