TS++ library: time series library

◆ trim_to_date()

template<typename T >
void ts::TimeSeriesCollection< T >::trim_to_date ( )

Trim to same start time.

Set all start dates to the latest found in the collection.

Definition at line 181 of file tscollection.h.

References TSXX_assert.

182  {
183  if (this->size() > 1)
184  {
185  // find lastest start date
186  typename Tbase::iterator i_series=this->begin();
187  Theader header=i_series->header;
188  libtime::TAbsoluteTime begin=header.date;
189  ++i_series;
190  while (i_series != this->end())
191  {
192  header=i_series->header;
193  libtime::TAbsoluteTime thisbegin=header.date;
194  begin = thisbegin > begin ? thisbegin : begin;
195  ++i_series;
196  }
197 
198  // adjust series and header
199  i_series=this->begin();
200  while (i_series != this->end())
201  {
202  header=i_series->header;
203  long int index_offset=wid2isample(header, begin);
204  TSXX_assert(index_offset >= 0,
205  "inconsistent header data");
206  TSXX_assert(index_offset < header.nsamples,
207  "time series does not overlap with others");
208  i_series->header.date=wid2isample(header, index_offset);
209  i_series->header.nsamples -= index_offset;
210  i_series->setfirstindex(i_series->f()+index_offset);
211  ++i_series;
212  }
213  }
214  } // void TimeSeriesCollection<T>::trim_to_date()
#define TSXX_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:127