TS++ library: time series library
filter.h
Go to the documentation of this file.
1 
54 // include guard
55 #ifndef TF_FILTER_H_VERSION
56 
57 #define TF_FILTER_H_VERSION \
58  "TF_FILTER_H V1.9"
59 
60 #include<tsxx/filterbase.h>
61 #include<tsxx/error.h>
62 
63 namespace ts {
64 
74  namespace filter {
75 
87  public:
88  SetByIndex(const int& n1, const int& n2, const double& v):
89  Mn1(n1), Mn2(n2), Mv(v) { }
91  const bool& debug=false) const;
92  private:
93  int Mn1, Mn2;
94  double Mv;
95  }; // class SetByIndex
96 
97  /*----------------------------------------------------------------------*/
98 
111  public:
112  RemoveTrend(const int& n): Mn(n) { }
114  const bool& debug=false) const;
115  private:
116  int Mn;
117  }; // class RemoveTrend
118 
119  /*----------------------------------------------------------------------*/
120 
132  public:
133  RemoveAverage(const int& n): Mn(n) { }
135  const bool& debug=false) const;
136  private:
137  int Mn;
138  }; // class RemoveAverage
139 
140  /*----------------------------------------------------------------------*/
141 
151  public:
153  const bool& debug=false) const;
154  }; // class HanningTaper
155 
156  /*----------------------------------------------------------------------*/
157 
162  public:
163  Scale(const double& v): Mv(v) { }
165  const bool& debug=false) const;
166  private:
167  double Mv;
168  }; // class Scale
169 
170  /*----------------------------------------------------------------------*/
171 
175  class Add: public ts::filter::BasicFilter {
176  public:
177  Add(const double& v): Mv(v) { }
179  const bool& debug=false) const;
180  private:
181  double Mv;
182  }; // class Add
183 
184  /*----------------------------------------------------------------------*/
185 
206  public:
207  ForceToBase(const int& n1, const int& n2, const int& ne):
208  Mn1(n1), Mn2(n2), Mne(ne) { }
210  const bool& debug=false) const;
211  private:
212  int Mn1, Mn2, Mne;
213  }; // class ForceToBase
214 
215  /*----------------------------------------------------------------------*/
216 
221  public:
223  const bool& debug=false) const;
224  }; // class Reverse
225 
226  /*----------------------------------------------------------------------*/
227 
232  public:
233  Normalize(const double& v): Mv(v) { }
235  const bool& debug=false) const;
236  private:
237  double Mv;
238  }; // class Normalize
239 
240  /*----------------------------------------------------------------------*/
241 
246  public:
247  Delay(const double& v): Mv(v) { }
249  const bool& debug=false) const;
250  private:
251  double Mv;
252  }; // class Delay
253 
254  /*----------------------------------------------------------------------*/
255 
260  public:
262  const bool& debug=false) const;
263  }; // class Square
264 
265  /*----------------------------------------------------------------------*/
266 
271  public:
273  const bool& debug=false) const;
274  }; // class SquareRoot
275 
276  /*----------------------------------------------------------------------*/
277 
282  public:
284  const bool& debug=false) const;
285  }; // class Rectifier
286 
287  /*----------------------------------------------------------------------*/
288 
293  public:
295  const bool& debug=false) const;
296  }; // class CumSum
297 
298  /*----------------------------------------------------------------------*/
299 
304  public:
305  Powerof(const double& v): Mv(v) { }
307  const bool& debug=false) const;
308  private:
309  double Mv;
310  }; // class Powerof
311 
312  /*----------------------------------------------------------------------*/
313 
320  public:
321  GaussianNoise(const double& a): Ma(a) { }
323  const bool& debug=false) const;
324  private:
325  double Ma;
326  }; // class GaussianNoise
327 
328  /*----------------------------------------------------------------------*/
329 
339  friend class RestoreFirst;
340  public:
343  const bool& debug=false) const;
344  private:
345  static double Mf;
346  }; // class RemoveFirst
347 
348  /*----------------------------------------------------------------------*/
349 
359  public:
362  const bool& debug=false) const;
363  }; // class RestoreFirst
364 
365  /*----------------------------------------------------------------------*/
366 
374  class Pad: public ts::filter::BasicFilter {
375  public:
376  Pad(const int& n): Mn(static_cast<unsigned int>(n))
377  {
378  TSXX_assert(n>=0,
379  "number of samples to be appended must be positive");
380  }
382  const bool& debug=false) const;
383  private:
384  unsigned int Mn;
385  }; // class Pad
386 
387  /*----------------------------------------------------------------------*/
388 
393  const bool& debug=false);
394 
398  void print_help(std::ostream& os);
399 
400  } // namespace filter
401 
402 } // namespace ts
403 
404 #endif // TF_FILTER_H_VERSION (includeguard)
405 
406 /* ----- END OF filter.h ----- */
hanning taper.
Definition: filter.h:150
tfxx::Handle< BasicFilter > Tfilterhandle
handle to pass filters
Definition: filterbase.h:93
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
take each sample to the power of a given exponent
Definition: filter.cc:193
remove average
Definition: filter.h:131
GaussianNoise(const double &a)
Definition: filter.h:321
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
Definition: filter.cc:406
Scale(const double &v)
Definition: filter.h:163
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
square signal
Definition: filter.cc:181
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
set values selected by index
Definition: filter.cc:153
remove value of first sample from series
Definition: filter.h:338
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
square root of signal
Definition: filter.cc:169
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
add offset to sample values
Definition: filter.cc:284
force signal to a baseline.The filter removes a linear trend from the time series. After this operation the average in the index ranges [i1,i2] and [i3,i4] will vanish. The index range limits are
Definition: filter.h:205
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
Definition: filter.cc:422
Add(const double &v)
Definition: filter.h:177
error handling for libtsxx (prototypes)
Powerof(const double &v)
Definition: filter.h:305
RemoveTrend(const int &n)
Definition: filter.h:112
Delay(const double &v)
Definition: filter.h:247
Add random Gaussian noise.
Definition: filter.h:319
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
remove average
Definition: filter.cc:244
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
Definition: filter.cc:344
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
add Gaussian noise
Definition: filter.cc:205
ForceToBase(const int &n1, const int &n2, const int &ne)
Definition: filter.h:207
Tfilterhandle make_filter(std::string s, const bool &debug)
function to generate filter class
Definition: filter.cc:446
Structure to hold the data samples of a series together with header information to form a time series...
Definition: tsxx.h:83
double Mv
Definition: filter.h:181
base class for all filter classes (prototypes)
remove trend
Definition: filter.h:110
static double Mf
definition of static member data is required
Definition: filter.h:345
Pad(const int &n)
Definition: filter.h:376
All stuff in this library will be placed within namespace ts.
Definition: anyfilter.cc:43
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
hanning taper
Definition: filter.cc:265
#define TSXX_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:127
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
remove trend
Definition: filter.cc:87
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
scale sample values
Definition: filter.cc:277
set sample values selected by index
Definition: filter.h:86
SetByIndex(const int &n1, const int &n2, const double &v)
Definition: filter.h:88
unsigned int Mn
Definition: filter.h:384
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
Definition: filter.cc:365
Normalize(const double &v)
Definition: filter.h:233
RemoveAverage(const int &n)
Definition: filter.h:133
restore value of first sample to series
Definition: filter.h:358
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
rectification
Definition: filter.cc:217
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
force signal to baseline
Definition: filter.cc:291
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
append additional samples
Definition: filter.cc:433
void print_help(std::ostream &os)
print usage information
Definition: filter.cc:517
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
cumulative sum
Definition: filter.cc:229
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
reverse time series
Definition: filter.cc:318