Logo coherent WaveBurst  
Library Reference Guide
Logo
Regression_H1_bic.C
Go to the documentation of this file.
1 //
2 // How to apply regression to subtract power line at 180Hz and related sidebands
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 815974196
11 #define LENGHT 1200
12 //Frequency near 180Hz
13 #define F1 175
14 #define F2 185
15 
16 {
17  //Auxiliary channels for carrier
18  #define NA 1
19  TString auch[]={"H0:PEM-COIL_MAGZ","H0:PEM-BSC10_MAGX","H0:PEM-BSC10_MAGY","H0:PEM-BSC10_MAGZ"};
20 
21  //Auxiliary channels for side-bands
22  #define NB 12
23  TString channels[]={"H1:SUS-ITMX_COIL_UL","H1:SUS-ITMX_COIL_LL",
24  "H1:SUS-ETMX_COIL_UR","H1:SUS-ETMY_COIL_UR",
25  "H1:SUS-ETMY_SENSOR_UL","H1:SUS-ETMY_SENSOR_LL",
26  "H1:SUS-ETMY_SENSOR_UR","H1:SUS-ETMY_SENSOR_LR",
27  "H1:SUS-ETMX_SENSOR_UL","H1:SUS-ETMX_SENSOR_LL",
28  "H1:SUS-ETMX_SENSOR_UR","H1:SUS-ETMX_SENSOR_LR"};
29 
30  using namespace CWB;
31  int totalscratch=32;
32 
33  //Fill wavearray h with target channel
35  h.start(START-totalscratch);
36  h.stop(LENGHT+START+totalscratch);
38  frt >> h;
39 
40  //Resample to 2048 Hz
41  Meyer<double> B(1024); // set wavelet for resampling
43  ww.Forward(h,B,2);
44  ww.getLayer(h,0);
45 
46  //Make WDM transform, resolution = 1Hz
47  int lev=h.rate()/2;
48  WDM<double> wdtf(lev, 2*lev, 6, 10);
50  tfmap.Forward(h, wdtf);
51 
52  //Adding target channel on regression object
54  r.add(tfmap,const_cast<char*>("hchannel"));
55  r.mask(0);
56  r.unmask(0,F1,F2);
57 
58  //Adding auxiliary channels
60  x.start(START-totalscratch);
61  x.stop(LENGHT+START+totalscratch);
63  for (int i=0; i<NA; i++)
64  {
65  x=0;
66  frw.setChName(auch[i]);
67  frw >> x;
68  r.add(x,const_cast<char*>(auch[i].Data()));
69  cout << auch[i].Data() << endl;
70  }
71  for (int j=0; j<NB; j++)
72  {
73  x=0;
74  frw.setChName(channels[j]);
75  frw >> x;
76  r.add(x,const_cast<char*>(channels[j].Data()),0,10);
77  cout << channels[j].Data() << endl;
78  }
79  //Multiply carrier channels for side-bands channels
80  for (int i=0; i<NA; i++) for (int j=0; j<NB; j++) r.add(i+1,NA+1+j,const_cast<char*>(channels[j].Data()));
81  //Mask not useful channels (side-bands)
82  //for (int i=0; i<NA; i++) r.mask(i+1);
83  for (int j=0; j<NB; j++) r.mask(NA+1+j);
84 
85  //Calculate prediction
86  r.setFilter(10);
87  r.setMatrix(totalscratch,.95);
88  r.solve(0.2, 0, 'h');
89  r.apply(0.2);
90 
91  //Draw plot of target and target-prediction
92  watplot plot;
93  plot.goptions(const_cast<char*>("alp logy"), 1, START, START+LENGHT, true, F1, F2,true, 50);
94  h >> plot;
96  hh >> plot;
97  TString ofile = "Regression_H1_bic.png";
98  plot >> ofile;
99 
100  //Write ranking for each frequency layer
103  for (int i=0; i<freq.size(); i++) cout << freq.data[i] << " " << rank.data[i] << endl;
104 }
char ofile[1024]
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:425
WSeries< double > ww
wavearray< double > x
wavearray< double > h
Definition: ced.hh:42
frame frt(FRLIST_NAME, HCHANNEL)
TString("c")
#define FRLIST_NAME2
#define F1
wavearray< double > rank
Definition: Regression_H1.C:80
WDM< double > wdtf(lev, 2 *lev, 6, 10)
#define FRLIST_NAME
WSeries< double > tfmap
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:91
#define NB
virtual void start(double s)
Definition: wavearray.hh:137
int j
Definition: cwb_net.C:28
i drho i
wavearray< double > hh
Definition: Regression_H1.C:73
void setChName(TString chName)
Definition: frame.hh:120
virtual size_t size() const
Definition: wavearray.hh:145
#define F2
wavearray< double > freq
Definition: Regression_H1.C:79
x plot
#define HCHANNEL
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
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
#define NA
void solve(double th, int nE=0, char c='s')
Definition: regression.cc:610
wavearray< double > vfreq
Definition: regression.hh:189
#define LENGHT
size_t setFilter(size_t)
Definition: regression.cc:276
frame frw(FRLIST_NAME2)
wavearray< double > getClean()
Definition: regression.hh:135
int lev
#define START
int totalscratch
Meyer< double > B(1024)
Definition: Meyer.hh:36
virtual void stop(double s)
Definition: wavearray.hh:139
regression r
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
DataType_t * data
Definition: wavearray.hh:319
TString channels[]