Commit 45c1a95e authored by thomas.forbriger's avatar thomas.forbriger
Browse files

Merge branch 'master' into stf_issue12

parents 58bb24b1 d4190892
......@@ -4,11 +4,11 @@
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 31/07/2015
* \date 19/03/2016
*
* some time series filter classes (implementation)
*
* Copyright (c) 2005, 2015 by Thomas Forbriger (BFO Schiltach)
* Copyright (c) 2005, 2015, 2016 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
......@@ -51,15 +51,18 @@
* - take usage text from text file
* - 31/07/2015 V1.10
* - add filter Powerof
* - 19/03/2016 V1.11
* - add filter GaussianNoise
*
* ============================================================================
*/
#define TF_FILTER_CC_VERSION \
"TF_FILTER_CC V1.10"
"TF_FILTER_CC V1.11"
#include <cmath>
#include <sstream>
#include <algorithm>
#include <tsxx/random.h>
#include <tsxx/filter.h>
#include <tsxx/filter_usage_text.h>
#include <aff/functions/avg.h>
......@@ -195,6 +198,18 @@ namespace ts {
/*----------------------------------------------------------------------*/
//! add Gaussian noise
Ttimeseries GaussianNoise::operator()(const Ttimeseries& s,
const bool& debug) const
{
Tseries x=s;
Tseries n=ts::rnd::dugauss(x.size())*Ma;
x += n;
return s;
}
/*----------------------------------------------------------------------*/
//! rectification
Ttimeseries Rectifier::operator()(const Ttimeseries& s,
const bool& debug) const
......@@ -434,6 +449,9 @@ namespace ts {
} else if (ID=="del") {
is >> v;
fh=Tfh(new Delay(v));
} else if (ID=="noi") {
is >> v;
fh=Tfh(new GaussianNoise(v));
} else if (ID=="nrm") {
is >> v;
fh=Tfh(new Normalize(v));
......
......@@ -4,11 +4,11 @@
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 31/07/2015
* \date 19/03/2016
*
* some time series filter classes (prototypes)
*
* Copyright (c) 2005, 2015 by Thomas Forbriger (BFO Schiltach)
* Copyright (c) 2005, 2015, 2016 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
......@@ -43,6 +43,8 @@
* - added cumsum
* - 31/07/2015 V1.7
* - add filter Powerof
* - 19/03/2016 V1.8
* - add filter GaussianNoise
*
* ============================================================================
*/
......@@ -51,7 +53,7 @@
#ifndef TF_FILTER_H_VERSION
#define TF_FILTER_H_VERSION \
"TF_FILTER_H V1.7"
"TF_FILTER_H V1.8"
#include<tsxx/filterbase.h>
......@@ -306,6 +308,22 @@ namespace ts {
/*----------------------------------------------------------------------*/
/*! \brief Add random Gaussian noise.
* \ingroup filter
*
* \param a rms amplitude of noise to be added
*/
class GaussianNoise: public ts::filter::BasicFilter {
public:
GaussianNoise(const double& a): Ma(a) { }
Ttimeseries operator()(const Ttimeseries& s,
const bool& debug=false) const;
private:
double Ma;
}; // class GaussianNoise
/*----------------------------------------------------------------------*/
/*! create a filter
* \ingroup filter
*/
......
......@@ -6,7 +6,7 @@
# description of filters provided in namespace ts::filter
# as provided through filter.h and defined in filter.cc
#
available filters (version 2015/07/31):
available filters (version 2016/03/19):
tre n remove trend found in first n samples
(n=0: use all samples)
avg n remove average found in first n samples
......@@ -31,5 +31,6 @@ rec rectify signal
cus calculate cumulative sum
iset n1,n2,v
set samples n1-n2 to value v
noi a add Gaussian random noise of rms amplitude a
#
# ----- END OF filter_usage_text.txt -----
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id$
#
# Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
#
......@@ -48,6 +47,7 @@
# 02/01/2014 V1.11 removed signal generators, added tisli suspect
# 01/02/2014 thof: rewrite all linker rules with libraries in
# proper order
# 19/03/2016 thof: tidofi requires libgsl for filter GaussianNoise
#
# ============================================================================
......@@ -202,7 +202,7 @@ sigval sigscale geophone gatherdiff cross autocorr: \
tidofi: \
%: %.o
$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@ \
-ltsxx -lcseife $(LIBDATRWXX) -ltfxx
-ltsxx -lcseife $(LIBDATRWXX) -ltfxx -lgsl -lgslcblas
fidasexx: \
%: %.o
......
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