3 #include <boost/bind.hpp> 
    4 #include <boost/numeric/conversion/cast.hpp> 
    8 #include <gsl/gsl_spline.h> 
   24       data(source.data), samplerate(source.samplerate), name(source.name),
 
   25           starttime(source.starttime)
 
   32         boost::posix_time::time_duration time_shift =
 
   33             boost::posix_time::microseconds(boost::numeric_cast<unsigned int>(
 
   34                 npts * 1000000 / samplerate));
 
   37             if (static_cast<size_t> (abs(npts)) > data.size())
 
   40             data.erase(data.begin(), data.begin() + abs(npts));
 
   42             starttime = starttime + time_shift;
 
   46             data.insert(data.begin(), npts, 0);
 
   47             starttime = starttime - time_shift;
 
   55             if (static_cast<size_t> (abs(npts)) > data.size())
 
   57             data.erase(data.end() + npts, data.end());
 
   61             data.insert(data.end(), npts, 0);
 
   70             this->samplerate = source.samplerate;
 
   71             this->name = source.name;
 
   72             this->starttime = source.starttime;
 
   73             this->data.assign(source.data.size(), 0); 
 
   74             std::copy(source.data.begin(), source.data.end(),
 
   83     void TimeSeriesComponent::Resample(
const double newdt)
 
   85         const size_t oldlength = data.size();
 
   86         double *oldtime = 
new double[oldlength];
 
   87         const double dt = 
GetDt();
 
   90         for (
size_t i = 0; i < oldlength; ++i)
 
   92             oldtime[i] = start + i * dt;
 
   95         gsl_interp_accel *acc = gsl_interp_accel_alloc();
 
   96         gsl_spline *spline = gsl_spline_alloc(gsl_interp_cspline, oldlength);
 
   97         gsl_spline_init(spline, oldtime, &data[0], oldlength);
 
   99         const size_t newlength = boost::numeric_cast<
size_t>(oldlength * (dt
 
  104         for (
size_t i = 0; i < newlength; ++i)
 
  106             data.push_back(gsl_spline_eval(spline, start + i * newdt, acc));
 
  108         gsl_spline_free(spline);
 
  109         gsl_interp_accel_free(acc);
 
  110         samplerate = 1. / newdt;
 
  117         std::transform(data.begin(), data.end(), data.begin(), boost::bind(
 
  118             std::multiplies<double>(), factor, _1));
 
  124         const double factor = 1. / numerator;
 
  131         std::transform(data.begin(), data.end(), data.begin(), boost::bind(
 
  132             std::plus<double>(), shift, _1));
 
  139         std::transform(data.begin(), data.end(), other.data.begin(),
 
  140             data.begin(), std::plus<double>());
 
  152         std::transform(data.begin(), data.end(), other.data.begin(),
 
  153             data.begin(), std::minus<double>());
 
TimeSeriesComponent & operator+=(const double shift)
Add a constant shift to each element of the time series. 
 
void ShiftStart(const int npts)
Shift the start of the recording by npts points. 
 
void ShiftEnd(const int npts)
Shift the end of the recording by npts points. 
 
TimeSeriesComponent & operator-=(const double shift)
Substract a constant shift from each element of the time series. 
 
virtual ~TimeSeriesComponent()
 
TimeSeriesComponent & operator/=(const double numerator)
Devide each element of the time series by a constant number. 
 
TimeSeriesComponent is the base storage class for all types of time series data. 
 
TimeSeriesComponent & operator*=(const double factor)
Multiply each element of the time series by a constant factor. 
 
double GetDt() const 
Return dt in s. 
 
The basic exception class for all errors that arise in gplib. 
 
TimeSeriesComponent & operator=(const TimeSeriesComponent &source)