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

additional taper stuff

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: 2391
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 7c2e24e0
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: filter.cc,v 1.15 2006-03-29 07:42:55 tforb Exp $
* $Id: filter.cc,v 1.16 2007-09-17 09:04:46 tforb Exp $
* \author Thomas Forbriger
* \date 05/07/2005
*
......@@ -41,7 +41,7 @@
#define TF_FILTER_CC_VERSION \
"TF_FILTER_CC V1.2"
#define TF_FILTER_CC_CVSID \
"$Id: filter.cc,v 1.15 2006-03-29 07:42:55 tforb Exp $"
"$Id: filter.cc,v 1.16 2007-09-17 09:04:46 tforb Exp $"
#include <cmath>
#include <sstream>
......@@ -134,7 +134,14 @@ namespace ts {
return s;
}
//! hanning taper
/*! \brief hanning taper
*
* \note
* This taper is normalized:
* \f[
* H_k = \frac{1}{\sqrt{2}} (1-\cos(2\pi k /N))
* \f]
*/
Ttimeseries HanningTaper::operator()(const Ttimeseries& s) const
{
double p=double(2.*M_PI/s.size());
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: filter.h,v 1.15 2006-03-29 07:42:55 tforb Exp $
* $Id: filter.h,v 1.16 2007-09-17 09:04:46 tforb Exp $
* \author Thomas Forbriger
* \date 05/07/2005
*
......@@ -39,7 +39,7 @@
#define TF_FILTER_H_VERSION \
"TF_FILTER_H V1.0 "
#define TF_FILTER_H_CVSID \
"$Id: filter.h,v 1.15 2006-03-29 07:42:55 tforb Exp $"
"$Id: filter.h,v 1.16 2007-09-17 09:04:46 tforb Exp $"
#include<tsxx/filterbase.h>
......@@ -89,7 +89,12 @@ namespace ts {
int Mn;
}; // class RemoveAverage
//! hanning taper
/*! \breif hanning taper.
*
* \note
* There is a Hanning taper available in the taper collection too.
* \sa ts::tapers::Hanning
*/
class HanningTaper: public ts::filter::BasicFilter {
public:
Ttimeseries operator()(const Ttimeseries& s) const;
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tapers.cc,v 1.2 2007-09-07 09:42:34 tforb Exp $
* $Id: tapers.cc,v 1.3 2007-09-17 09:04:46 tforb Exp $
* \author Thomas Forbriger
* \date 06/09/2007
*
......@@ -19,7 +19,7 @@
#define TF_TAPERS_CC_VERSION \
"TF_TAPERS_CC V1.0 "
#define TF_TAPERS_CC_CVSID \
"$Id: tapers.cc,v 1.2 2007-09-07 09:42:34 tforb Exp $"
"$Id: tapers.cc,v 1.3 2007-09-17 09:04:46 tforb Exp $"
#include <tsxx/tapers.h>
#include <cmath>
......@@ -41,6 +41,12 @@ namespace ts {
return (s*s);
} // double Hanning::value(const int& i) const
double Hanning::psdnorm() const
{
const double retval=std::sqrt(3./8.);
return (retval);
} // double Hanning::psdnorm() const
} // namespace tapers
} // namespace ts
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tapers.h,v 1.2 2007-09-07 09:42:34 tforb Exp $
* $Id: tapers.h,v 1.3 2007-09-17 09:04:46 tforb Exp $
* \author Thomas Forbriger
* \date 06/09/2007
*
......@@ -23,7 +23,7 @@
#define TF_TAPERS_H_VERSION \
"TF_TAPERS_H V1.0 "
#define TF_TAPERS_H_CVSID \
"$Id: tapers.h,v 1.2 2007-09-07 09:42:34 tforb Exp $"
"$Id: tapers.h,v 1.3 2007-09-17 09:04:46 tforb Exp $"
namespace ts {
......@@ -42,6 +42,17 @@ namespace ts {
//! apply taper to series container c.
template<class C>
void apply(C c) const;
//! apply taper to series container c for PSD calculation.
template<class C>
void psdapply(C c) const;
/*! \brief return normalization for PSD calculation.
* The taper coefficients \f$w_k\f$ have to be devided by the return
* value \f$W\f$.
* \return
* \f$ W=\sqrt{\frac{\sum\limits_{k=1}^{N} w_k^2}{N}} \f$
* \sa ts::tapers::Taper::psdapply
*/
virtual double psdnorm() const;
private:
//! will be called prior to value to set ranges.
virtual void init(const int& f, const int& l) const =0;
......@@ -73,6 +84,15 @@ namespace ts {
for (int i=c.f(); i<=c.l(); ++i)
{ c(i) *= this->value(i); }
} // template<class C> void Taper::apply(C c)
//! inline function for template argument
template<class C>
void Taper::psdapply(C c) const
{
this->init(c.f(), c.l());
for (int i=c.f(); i<=c.l(); ++i)
{ c(i) *= this->value(i)/this->psdnorm(); }
} // template<class C> void Taper::psdapply(C c)
} // namespace tapers
......
Supports Markdown
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