Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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,"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,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("alp logy", 1, START, START+LENGHT, true, F1, F2, true, 50);
72  h >> plot;
73  r.getClean() >> plot;
74  plot >> "Regression_H1.png";
75 
76  //Write ranking for each frequency layer
77  wavearray<double> freq=r.vfreq;
79  for (int i=0; i<freq.size(); i++) cout << freq.data[i] << " " << rank.data[i] << endl;
80 }
#define F1
Definition: Regression_H1.C:13
virtual size_t size() const
Definition: wavearray.hh:127
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:407
Definition: ced.hh:24
float * rank
TString("c")
frame frt(FRLIST_NAME, HCHANNEL)
#define NA
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:73
virtual void start(double s)
Definition: wavearray.hh:119
i drho i
#define START
Definition: Regression_H1.C:10
void setChName(TString chName)
Definition: frame.hh:102
#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:691
wavearray< double > getRank(int n)
Definition: regression.hh:134
int getLayer(wavearray< DataType_t > &w, double n)
param: n - layer number
Definition: wseries.cc:175
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:1202
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:592
wavearray< double > vfreq
Definition: regression.hh:171
size_t setFilter(size_t)
Definition: regression.cc:258
watplot plot
Definition: Regression_H1.C:70
wavearray< double > x
Definition: Regression_H1.C:50
wavearray< double > getClean()
Definition: regression.hh:117
WSeries< double > ww
Definition: Regression_H1.C:33
#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:18
virtual void stop(double s)
Definition: wavearray.hh:121
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
void unmask(int n, double flow=0., double fhigh=0.)
Definition: regression.cc:321
void mask(int n, double flow=0., double fhigh=0.)
Definition: regression.cc:303
#define FRLIST_NAME
Definition: Regression_H1.C:6
DataType_t * data
Definition: wavearray.hh:301
frame frw(FRLIST_NAME2)
int lev
Definition: Regression_H1.C:38