Logo coherent WaveBurst  
Library Reference Guide
Logo
TestBandPass.C
Go to the documentation of this file.
1 //
2 // This example show how to apply the band filters
3 // Author : Gabriele Vedovato
4 
5 {
6  //#define WAVELET // comment to select WDM
7  #define FLOW 90. // low frequency cut
8  #define FHIGH 150. // high frequency cut
9 
10  TStopwatch watchJob; // job benchmark
11 
12  double flow = FLOW;
13  double fhigh = FHIGH;
14 
16 
17  double rate = 4096.; // sample rate
18  double length = 600; // sec
19 
20  wavearray<double> x(length*rate); x.rate(rate);
21  for(int i=0;i<x.size();i++) x[i]=gRandom->Gaus(0,1); // fill with gaussian noise
23 
24  watchJob.Start();
25 
26  // decomposition
27 #ifdef WAVELET
28  int level = 11; // df = 1Hz
29  Meyer<double> S(1024,2); // set wavelet for production
30  D.getTFmap().Forward(x,S,level);
31 #else
32  int layers = x.rate()/2;
33  WDM<double> wdm(layers,layers,6,10); // df = (x.rate()/2)/layers = 1Hz
34  D.getTFmap()->Forward(x,wdm);
35 #endif
36 
37  if(D.getTFmap()->pWavelet->m_WaveType==WDMT) cout << "WDM" << endl;
38  else cout << "WAVELET" << endl;
39 
40  D.getTFmap()->setlow(flow);
41  D.getTFmap()->sethigh(fhigh);
42 
43  D.bandPass(flow,fhigh); // band pass filter
44 // D.bandCut(flow,fhigh); // band cut filter
45 // D.lowPass(flow); // low pass filter
46 // D.highPass(fhigh); // high pass filter
47 
48  D.getTFmap()->Inverse(); // return to time domain
49 
50  watchJob.Stop();
51  cout << "Job Elapsed Time - " << watchJob.RealTime() << " sec" << endl;
52 
53  wavearray<double> y = *D.getTFmap(); // get band filtered data
54 
55  gx.Draw(GWAT_FFT,"ALP NOLOGX NOLOGY"); // original data
56  gx.Draw(&y,GWAT_FFT,"SAME NOLOGX NOLOGY",kRed); // band filtered data
57 }
void sethigh(double f)
Definition: wseries.hh:132
detector D
Definition: TestBandPass.C:15
virtual void rate(double r)
Definition: wavearray.hh:141
WDM< double > wdm(nLAYERS, nLAYERS, 6, 10)
void setlow(double f)
Definition: wseries.hh:125
int layers
i drho i
wavearray< double > x(length *rate)
#define FHIGH
virtual size_t size() const
Definition: wavearray.hh:145
double flow
Definition: TestBandPass.C:12
gwavearray< double > * gx
#define FLOW
Definition: Wavelet.hh:49
void bandPass(double f1, double f2, double a=0.)
Definition: detector.hh:283
double rate
Definition: TestBandPass.C:17
Definition: gwat.hh:30
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:179
Definition: Meyer.hh:36
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:246
Meyer< double > S(1024, 2)
enum WAVETYPE m_WaveType
Definition: Wavelet.hh:106
double fhigh
Definition: TestBandPass.C:13
WaveDWT< DataType_t > * pWavelet
Definition: wseries.hh:456
double length
Definition: TestBandPass.C:18
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:291
wavearray< double > y
Definition: Test10.C:31