Commit f8c1660e authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

implemented normalizer

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 3965
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 4d63b3c6
......@@ -42,11 +42,13 @@
* - added delay filter
* - 19/02/2011 V1.5
* - added rectifier
* - 25/05/2011 V1.6
* - added normalizer
*
* ============================================================================
*/
#define TF_FILTER_CC_VERSION \
"TF_FILTER_CC V1.5"
"TF_FILTER_CC V1.6"
#define TF_FILTER_CC_CVSID \
"$Id$"
......@@ -55,6 +57,7 @@
#include <algorithm>
#include <tsxx/filter.h>
#include <aff/functions/avg.h>
#include <aff/functions/absmax.h>
#include <aff/seriesoperators.h>
#include <aff/subarray.h>
#include <tfxx/misc.h>
......@@ -201,16 +204,22 @@ namespace ts {
return s;
}
/*----------------------------------------------------------------------*/
//! scale sample values
Ttimeseries Scale::operator()(const Ttimeseries& s,
const bool& debug) const
{ s *= Mv; return s; }
/*----------------------------------------------------------------------*/
//! add offset to sample values
Ttimeseries Add::operator()(const Ttimeseries& s,
const bool& debug) const
{ s += Mv; return s; }
/*----------------------------------------------------------------------*/
//! force signal to baseline
Ttimeseries ForceToBase::operator()(const Ttimeseries& s,
const bool& debug) const
......@@ -236,6 +245,8 @@ namespace ts {
return s;
}
/*----------------------------------------------------------------------*/
//! reverse time series
Ttimeseries Reverse::operator()(const Ttimeseries& s,
const bool& debug) const
......@@ -259,6 +270,28 @@ namespace ts {
return s;
}
/*----------------------------------------------------------------------*/
/*! normalize
*/
Ttimeseries Normalize::operator()(const Ttimeseries& s,
const bool& debug) const
{
Ttimeseries::Tseries series=s;
double a=aff::func::absmax(s);
if (a > 1.e-20)
{
series /= a;
}
else
{
series=0;
}
return s;
}
/*----------------------------------------------------------------------*/
/*! delays time series
*/
Ttimeseries Delay::operator()(const Ttimeseries& s,
......@@ -343,6 +376,9 @@ namespace ts {
} else if (ID=="del") {
is >> v;
fh=Tfh(new Delay(v));
} else if (ID=="nrm") {
is >> v;
fh=Tfh(new Normalize(v));
} else {
TFXX_debug(debug, "make_filter", " filter ID " + ID + " is unknown" );
TSXX_UnknownFilterAbort("ts::filter::make_filter", ID.c_str());
......@@ -361,8 +397,8 @@ namespace ts {
os << " (n=0: use all samples)" << std::endl;
os << "han apply hanning taper" << std::endl;
os << "fac f scale with factor f" << std::endl;
os << "del t delay by t seconds"
<< std::endl;
os << "del t delay by t seconds" << std::endl;
os << "nrm v normalize to maximum amplitude v" << std::endl;
os << "add v add v" << std::endl;
os << "fbl n1 n2 n3" << std::endl
<< " force to baseline such that the averages in the range"
......
......@@ -36,6 +36,8 @@
* - added delay filter
* - 19/02/2011 V1.3
* - added rectifier
* - 25/05/2011 V1.4
* - added normalizer
*
* ============================================================================
*/
......@@ -44,7 +46,7 @@
#ifndef TF_FILTER_H_VERSION
#define TF_FILTER_H_VERSION \
"TF_FILTER_H V1.3"
"TF_FILTER_H V1.4"
#define TF_FILTER_H_CVSID \
"$Id$"
......@@ -192,6 +194,20 @@ namespace ts {
/*----------------------------------------------------------------------*/
/*! normalize time series to given maximum amplitude
* \ingroup filter
*/
class Normalize: public ts::filter::BasicFilter {
public:
Normalize(const double& v): Mv(v) { }
Ttimeseries operator()(const Ttimeseries& s,
const bool& debug=false) const;
private:
double Mv;
}; // class Normalize
/*----------------------------------------------------------------------*/
/*! delay time series by linear interpolation
* \ingroup filter
*/
......
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