TS++ library: time series library

◆ make_filter()

ts::filter::Tfilterhandle ts::filter::make_filter ( std::string  s,
const bool &  debug = false 
)

function to generate filter class

create a filter

Definition at line 446 of file filter.cc.

References TSXX_debug, and TSXX_UnknownFilterAbort.

Referenced by make_any_filter().

448  {
449  std::replace(s.begin(),s.end(),',',' ');
450  TSXX_debug(debug, "make_filter", "process " + s );
451  typedef Tfilterhandle Tfh;
452  Tfh fh(new Noop());
453  std::string ID;
454  std::istringstream is(s);
455  is >> ID;
456  TSXX_debug(debug, "make_filter", " filter ID is " + ID );
457  Tvalue v;
458  int n, n2, n3;
459  if (ID=="tre") {
460  is >> n;
461  fh=Tfh(new RemoveTrend(n));
462  } else if (ID=="iset") {
463  is >> n >> n2 >> v;
464  fh=Tfh(new SetByIndex(n,n2,v));
465  } else if (ID=="avg") {
466  is >> n;
467  fh=Tfh(new RemoveAverage(n));
468  } else if (ID=="han") {
469  fh=Tfh(new HanningTaper());
470  } else if (ID=="fac") {
471  is >> v;
472  fh=Tfh(new Scale(v));
473  } else if (ID=="add") {
474  is >> v;
475  TSXX_debug(debug, "make_filter", " filter is: Add(" << v << ")" );
476  fh=Tfh(new Add(v));
477  } else if (ID=="fbl") {
478  is >> n >> n2 >> n3;
479  fh=Tfh(new ForceToBase(n, n2, n3));
480  } else if (ID=="pow") {
481  is >> v;
482  fh=Tfh(new Powerof(v));
483  } else if (ID=="rev") {
484  fh=Tfh(new Reverse());
485  } else if (ID=="sqr") {
486  fh=Tfh(new Square());
487  } else if (ID=="sqt") {
488  fh=Tfh(new SquareRoot());
489  } else if (ID=="rec") {
490  fh=Tfh(new Rectifier());
491  } else if (ID=="cus") {
492  fh=Tfh(new CumSum());
493  } else if (ID=="del") {
494  is >> v;
495  fh=Tfh(new Delay(v));
496  } else if (ID=="noi") {
497  is >> v;
498  fh=Tfh(new GaussianNoise(v));
499  } else if (ID=="nrm") {
500  is >> v;
501  fh=Tfh(new Normalize(v));
502  } else if (ID=="lof") {
503  fh=Tfh(new RemoveFirst());
504  } else if (ID=="rsf") {
505  fh=Tfh(new RestoreFirst());
506  } else if (ID=="pad") {
507  is >> n;
508  fh=Tfh(new Pad(n));
509  } else {
510  TSXX_debug(debug, "make_filter", " filter ID " + ID + " is unknown" );
511  TSXX_UnknownFilterAbort("ts::filter::make_filter", ID.c_str());
512  }
513  return(fh);
514  }
tfxx::Handle< BasicFilter > Tfilterhandle
handle to pass filters
Definition: filterbase.h:93
Ttimeseries::Tvalue Tvalue
we always work in double precision
Definition: filter.cc:83
#define TSXX_debug(C, N, M)
produce debug output
Definition: debug.h:51
#define TSXX_UnknownFilterAbort(M, F)
Definition: filterbase.h:153
Here is the caller graph for this function: