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

proceeding

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: 2189
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 65467bbb
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dropcontainer.h,v 1.2 2006-11-21 15:31:12 tforb Exp $
* $Id: dropcontainer.h,v 1.3 2006-11-22 14:12:18 tforb Exp $
* \author Thomas Forbriger
* \date 21/11/2006
*
......@@ -39,9 +39,11 @@
#define TF_DROPCONTAINER_H_VERSION \
"TF_DROPCONTAINER_H V1.0"
#define TF_DROPCONTAINER_H_CVSID \
"$Id: dropcontainer.h,v 1.2 2006-11-21 15:31:12 tforb Exp $"
"$Id: dropcontainer.h,v 1.3 2006-11-22 14:12:18 tforb Exp $"
#include<string>
#include<tsxx/tsxx.h>
#include<tsxx/firfilters.h>
namespace ts {
......@@ -204,7 +206,7 @@ namespace ts {
typedef typename Tbase::Tvalue Tvalue;
typedef DropContainer<Tvalue>* PDropContainer;
DropDropContainer(const int& n): Mn(n), Mi(0) { }
~DropDropContainer() { }
virtual ~DropDropContainer() { }
virtual void drop(const Tvalue& v)
{
++Mi;
......@@ -241,7 +243,7 @@ namespace ts {
typedef typename Tbase::Tvalue Tvalue;
typedef DropContainer<Tvalue>* PDropContainer;
PassDropContainer() { }
~PassDropContainer() { }
virtual ~PassDropContainer() { }
virtual void drop(const Tvalue& v)
{ attached()->drop(v); }
protected:
......@@ -257,6 +259,35 @@ namespace ts {
/*----------------------------------------------------------------------*/
/*! Decimation FIR drop container
*
* This class decimates the input by applying an FIR filter
*/
template<class T>
class FIRDropContainer: public DropContainer<T> {
public:
typedef DropContainer<T> Tbase;
typedef typename Tbase::Tvalue Tvalue;
typedef DropContainer<Tvalue>* PDropContainer;
typedef ts::fir::FIRfilter<Tvalue> Tfirfilter;
FIRDropContainer(const std::string& name);
virtual ~FIRDropContainer() { delete Mf; }
virtual void drop(const Tvalue& v);
protected:
virtual PDropContainer clone() const
{
FIRDropContainer<T>* retval(new FIRDropContainer(Mf->fir().name));
return(retval);
}
virtual void initializenext(const int& n)
{ Moutput->initialize(n/Mf->fir().decimation_factor); }
private:
Tfirfilter* Mf;
int Mi;
}; // class FIRDropContainer
/*======================================================================*/
template<class T>
void DropContainer<T>::initialize(const int& n)
{
......@@ -265,6 +296,36 @@ namespace ts {
this->initializenext(n);
}
/*----------------------------------------------------------------------*/
template<class T>
FIRDropContainer<T>::FIRDropContainer(const std::string& name)
{
if (name == "MP")
{ Mf=new Tfirfilter(&ts::fir::SeisCompMP); }
else if (name == "LP")
{ Mf=new Tfirfilter(&ts::fir::SeisCompLP); }
else if (name == "VLP")
{ Mf=new Tfirfilter(&ts::fir::SeisCompVLP); }
else
{ TSXX_abort("FIRDropContainer: unknown FIR filter name"); }
Mi=0;
}
/*----------------------------------------------------------------------*/
template<class T>
void FIRDropContainer<T>::drop(const Tvalue& v)
{
Mf->push(v);
++Mi;
if (Mi>=Mf->fir().decimation_factor)
{
Mi=0;
attached()->drop(Mf->pop());
}
}
} // namespace drop
} // namespace ts
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: firfilters.cc,v 1.1 2006-11-21 16:36:55 tforb Exp $
* $Id: firfilters.cc,v 1.2 2006-11-22 14:12:18 tforb Exp $
* \author Thomas Forbriger
* \date 21/11/2006
*
......@@ -35,7 +35,7 @@
#define TF_FIRFILTERS_CC_VERSION \
"TF_FIRFILTERS_CC V1.0 "
#define TF_FIRFILTERS_CC_CVSID \
"$Id: firfilters.cc,v 1.1 2006-11-21 16:36:55 tforb Exp $"
"$Id: firfilters.cc,v 1.2 2006-11-22 14:12:18 tforb Exp $"
#include <tsxx/tsxx.h>
#include <tsxx/firfilters.h>
......@@ -66,6 +66,8 @@ namespace ts {
SeisCompMPc
};
/*----------------------------------------------------------------------*/
const double SeisCompLPc[]=
{
3.23645679E-07, 6.27603639E-07, 5.75629996E-07, -1.00657667E-06,
......@@ -106,6 +108,8 @@ namespace ts {
SeisCompLPc
};
/*----------------------------------------------------------------------*/
const double SeisCompVLPc[]=
{
-1.28828092E-09, 9.14503405E-09, 2.87476904E-08, 7.11241767E-08,
......@@ -171,6 +175,22 @@ namespace ts {
SeisCompVLPc
};
/*======================================================================*/
std::ostream& operator<<(std::ostream& os, const FIR& fir)
{
os << "FIR filter " << fir.name << ":" << std::endl;
os << " " << fir.description << std::endl;
os << " number of coefficients: " << fir.points
<< ", delay: " << fir.delay
<< ", decimation: " << fir.decimation_factor
<< ", gain: " << fir.gain << std::endl;
os << " the filter is ";
if (!fir.symmetric) { os << "non-"; }
os << "symmetric" << std::endl;
return(os);
}
} // namespace fir
} // namespace ts
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: firfilters.h,v 1.2 2006-11-21 16:51:16 tforb Exp $
* $Id: firfilters.h,v 1.3 2006-11-22 14:12:18 tforb Exp $
* \author Thomas Forbriger
* \date 21/11/2006
*
......@@ -39,8 +39,9 @@
#define TF_FIRFILTERS_H_VERSION \
"TF_FIRFILTERS_H V1.0 "
#define TF_FIRFILTERS_H_CVSID \
"$Id: firfilters.h,v 1.2 2006-11-21 16:51:16 tforb Exp $"
"$Id: firfilters.h,v 1.3 2006-11-22 14:12:18 tforb Exp $"
#include<iostream>
#include<aff/series.h>
#include<aff/iterator.h>
......@@ -48,6 +49,8 @@ namespace ts {
namespace fir {
/*! container for FIR filters and their description
*/
struct FIR {
const char* name;
const char* description;
......@@ -65,6 +68,14 @@ namespace ts {
extern const FIR SeisCompLP;
extern const FIR SeisCompVLP;
/*----------------------------------------------------------------------*/
/*! dump filter characteristics
*/
std::ostream& operator<<(std::ostream& os, const FIR& fir);
/*----------------------------------------------------------------------*/
/*! Class to evaluate a FIR filter
*
* Add new sample through member function push().
......@@ -80,7 +91,7 @@ namespace ts {
typedef T Tvalue;
typedef aff::Series<Tvalue> Tseries;
typedef aff::Iterator<Tseries> Titerator;
FIRfilter(FIR* fir): Mfir(fir), Ms(fir.points), Mi(Ms)
FIRfilter(const FIR* fir): Mfir(fir), Ms(fir->points), Mi(Ms)
{ this->clear(); }
void push(const Tvalue& v)
{
......@@ -90,31 +101,33 @@ namespace ts {
Tvalue pop() const
{
Titerator Ml=Mi;
Tvalue sum=0;
double sum=0;
if (Mfir->symmetric)
{
for (int i=0; i<Mfir->points / 2; ++i)
{ sum += *(Ml--) * Mfir->c[i] * Mfir->gain; }
{ sum += *Ml * Mfir->c[i] * Mfir->gain; --Ml; }
for (int i= Mfir->points/2 -1; i>=0; --i)
{ sum += *(Ml--) * Mfir->c[i] * Mfir->gain; }
{ sum += *Ml * Mfir->c[i] * Mfir->gain; --Ml; }
}
else
{
for (int i=0; i<Mfir->points; ++i)
{ sum += *(Ml--) * Mfir->c[i] * Mfir->gain; }
{ sum += *Ml * Mfir->c[i] * Mfir->gain; --Ml; }
}
return(Tvalue(sum));
}
void clear()
{
Mi.tofirst();
while (Mi.valid()) *(Mi++)=0;
while (Mi.valid()) { *Mi = 0; ++Mi; }
Mi.tofirst();
}
const FIR& fir() const { return(*Mfir); }
private:
FIR* Mfir;
const FIR* Mfir;
Tseries Ms;
Titerator Mi;
};
}; // class FIRfilter
} // namespace fir
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tstest.cc,v 1.6 2006-11-21 15:31:13 tforb Exp $
* $Id: tstest.cc,v 1.7 2006-11-22 14:12:18 tforb Exp $
* \author Thomas Forbriger
* \date 20/12/2003
*
......@@ -38,7 +38,7 @@
#define TSTEST_VERSION \
"TSTEST V1.2 test time series modules"
#define TSTEST_CVSID \
"$Id: tstest.cc,v 1.6 2006-11-21 15:31:13 tforb Exp $"
"$Id: tstest.cc,v 1.7 2006-11-22 14:12:18 tforb Exp $"
#include <iostream>
#include <tsxx/tsxx.h>
......@@ -213,6 +213,18 @@ int main(int iargc, char* argv[])
for (int i=a.f(); i<=a.l(); ++i) { d1.drop(a(i)); }
DUMP( a );
DUMP( d1.container() );
cout << ts::fir::SeisCompMP << endl;
cout << ts::fir::SeisCompLP << endl;
cout << ts::fir::SeisCompVLP << endl;
aff::Series<double> b(1,1000);
for (int i=b.f(); i<=b.l(); ++i) { b(i)=i; }
ts::drop::FIRDropContainer<double> d4("MP");
ts::drop::FIRDropContainer<double> d5("LP");
d4.attach(d5);
d4.initialize(b.size());
for (int i=b.f(); i<=b.l(); ++i) { d4.drop(b(i)); }
DUMP( d4.container() );
}
}
......
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