Logo coherent WaveBurst  
Library Reference Guide
Logo
Regression_H1.C
Go to the documentation of this file.
1 //
2 //How to apply regression to subtract power line at 180Hz
3 
4 //Target channel
5 #define HCHANNEL "H1:LSC-STRAIN"
6 #define FRLIST_NAME "S5_H1_RDS_C03_L2.frl"
7 //Frame list file for auxliary channels
8 #define FRLIST_NAME2 "H-R-8159.frl"
9 //Time
10 #define START 815974300
11 #define LENGHT 1200
12 //Frequency near 180Hz
13 #define F1 175
14 #define F2 185
15 
16 {
17  //Auxiliary channels
18  #define NA 4
19  TString auch[]={"H0:PEM-COIL_MAGZ","H0:PEM-BSC10_MAGX","H0:PEM-BSC10_MAGY","H0:PEM-BSC10_MAGZ"};
20 
21  using namespace CWB;
22  int totalscratch=32;
23 
24  //Fill wavearray h with target channel
26  h.start(START-totalscratch);
27  h.stop(LENGHT+START+totalscratch);
29  frt >> h;
30 
31  //Resample to 2048 Hz
32  Meyer<double> B(1024); // set wavelet for resampling
34  ww.Forward(h,B,2);
35  ww.getLayer(h,0);
36 
37  //Make WDM transform, resolution = 1Hz
38  int lev=h.rate()/2;
39  WDM<double> wdtf(lev, 2*lev, 6, 10);
41  tfmap.Forward(h, wdtf);
42 
43  //Adding target channel on regression object
45  r.add(tfmap,const_cast<char*>("hchannel"));
46  r.mask(0);
47  r.unmask(0,F1,F2);
48 
49  //Adding auxiliary channels
51  x.start(START-totalscratch);
52  x.stop(LENGHT+START+totalscratch);
54  for (int i=0; i<NA; i++)
55  {
56  x=0;
57  frw.setChName(auch[i]);
58  frw >> x;
59  r.add(x,const_cast<char*>(auch[i].Data()));
60  cout << auch[i].Data() << endl;
61  }
62 
63  //Calculate prediction
64  r.setFilter(10);
65  r.setMatrix(totalscratch,.95);
66  r.solve(0.2, 0, 'h');
67  r.apply(0.2);
68 
69  //Draw plot of target and target-prediction
71  plot.goptions(const_cast<char*>("alp logy"), 1, START, START+LENGHT, true, F1, F2, true, 50);
72  h >> plot;
74  hh >> plot;
75  TString ofile = "Regression_H1.png";
76  plot >> ofile;
77 
78  //Write ranking for each frequency layer
81  for (int i=0; i<freq.size(); i++) cout << freq.data[i] << " " << rank.data[i] << endl;
82 }
#define F1
Definition: Regression_H1.C:13
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:425
Definition: ced.hh:42
TString("c")
frame frt(FRLIST_NAME, HCHANNEL)
wavearray< double > rank
Definition: Regression_H1.C:80
#define NA
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:91
virtual void start(double s)
Definition: wavearray.hh:137
i drho i
wavearray< double > hh
Definition: Regression_H1.C:73
#define START
Definition: Regression_H1.C:10
void setChName(TString chName)
Definition: frame.hh:120
virtual size_t size() const
Definition: wavearray.hh:145
watplot plot
Definition: Regression_H1.C:70
wavearray< double > freq
Definition: Regression_H1.C:79
#define F2
Definition: Regression_H1.C:14
wavearray< double > h
Definition: Regression_H1.C:25
void apply(double threshold=0., char c='a')
Definition: regression.cc:709
wavearray< double > getRank(int n)
Definition: regression.hh:152
int getLayer(wavearray< DataType_t > &w, double n)
param: n - layer number
Definition: wseries.cc:193
int totalscratch
Definition: Regression_H1.C:22
void goptions(char *opt=NULL, int col=1, double t1=0., double t2=0., bool fft=false, float f1=0., float f2=0., bool psd=false, float t3=0., bool oneside=false)
Definition: watplot.cc:1221
Meyer< double > B(1024)
#define FRLIST_NAME2
Definition: Regression_H1.C:8
void solve(double th, int nE=0, char c='s')
Definition: regression.cc:610
wavearray< double > vfreq
Definition: regression.hh:189
size_t setFilter(size_t)
Definition: regression.cc:276
wavearray< double > x
Definition: Regression_H1.C:50
wavearray< double > getClean()
Definition: regression.hh:135
WSeries< double > ww
Definition: Regression_H1.C:33
TString ofile
Definition: Regression_H1.C:75
#define LENGHT
Definition: Regression_H1.C:11
regression r
Definition: Regression_H1.C:44
WSeries< double > tfmap
Definition: Regression_H1.C:40
#define HCHANNEL
Definition: Regression_H1.C:5
WDM< double > wdtf(lev, 2 *lev, 6, 10)
Definition: Meyer.hh:36
virtual void stop(double s)
Definition: wavearray.hh:139
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:246
void unmask(int n, double flow=0., double fhigh=0.)
Definition: regression.cc:339
void mask(int n, double flow=0., double fhigh=0.)
Definition: regression.cc:321
#define FRLIST_NAME
Definition: Regression_H1.C:6
DataType_t * data
Definition: wavearray.hh:319
frame frw(FRLIST_NAME2)
int lev
Definition: Regression_H1.C:38