Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
regression.hh
Go to the documentation of this file.
1 //**************************************************************
2 // Wavelet Analysis Tool
3 // Sergey Klimenko, University of Florida
4 // class for regression analysis of GW data
5 //**************************************************************
6 
7 #ifndef REGRESSION_HH
8 #define REGRESSION_HH
9 
10 #include <iostream>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <vector>
14 #include "wavearray.hh"
15 #include "wseries.hh"
16 #include "TMatrixDSym.h"
17 #include "TMatrixDSymEigen.h"
18 #include "TVectorD.h"
19 
20 typedef TMatrixTSym<double> TMatrixDSym;
21 typedef std::vector<double> vectorD;
22 
23 struct Wiener { // filter structure for a single target layer
24  std::vector<int> channel; // data channels: 0 - target, >0 witness
25  std::vector<int> layer; // data layers: 0 - target, >0 witness
26  std::vector<double> norm; // normalization factor
27  std::vector<vectorD> filter00; // 0-phase filter:
28  std::vector<vectorD> filter90; // 90-phase filter:
29 };
30 
32 {
33  public:
34 
35  /* ************** */
36  /* constructors */
37  /* ************** */
38 
39  regression();
40 
41  regression(WSeries<double> &, char*, double fL=0., double fH=0.);
42 
43  regression(const regression&);
44 
45  /* ************** */
46  /* destructor */
47  /* ************** */
48 
49  virtual ~regression() {this->clear();}
50 
51  /* ************** */
52  /* operators */
53  /* ************** */
54 
56 
57  /* ************** */
58  /* accessors */
59  /* ************** */
60 
61  size_t add(WSeries<double> & target, char* name, double fL=0., double fH=0.);
62 
63  size_t add(wavearray<double>& witness, char* name, double fL=0., double fH=0.);
64 
65  size_t add(int n, int m, char* name);
66 
67  /* ************** */
68  /* mask frequency */
69  /* ************** */
70 
71  void mask(int n, double flow=0., double fhigh=0.);
72  void unmask(int n, double flow=0., double fhigh=0.);
73 
74  /* ************** */
75  /* compute filter */
76  /* ************** */
77 
78  size_t setFilter(size_t);
79 
80  void setMatrix(double edge=0., double f=1.);
81 
82  void solve(double th, int nE=0, char c='s');
83 
84  void apply(double threshold=0., char c='a');
85 
86  /* ************** */
87  /* get parameters */
88  /* ************** */
89 
90  // extract matrix
91  //
92  // n: channel index
93  //
95  { return n<matrix.size() ? matrix[n] : matrix[0]; }
96 
97  // extract cross vector
98  //
99  // n: channel index
100  //
102  { return n<vCROSS.size() ? vCROSS[n] : vCROSS[0]; }
103 
104  wavearray<double> getVEIGEN(int n=-1);
105 
106  wavearray<double> getFILTER(char c='a', int nT=-1, int nW=-1);
107 
108  // get pointer to TF series
109  WSeries<double>* getTFmap(int n=0) {return n<(int)chList.size() ? &chList[n] : NULL;}
110 
111  wavearray<double> rank(int nbins=0, double fL=0., double fH=0.);
112 
113  //get target-prediction wseries
114  inline WSeries <double> getWNoise() { return WNoise; }
115 
116  // get target-prediction time series
118  wavearray<double> x = this->target;
119  return x -= this->rnoise;
120  }
121 
122  // get prediction time series
123  inline wavearray<double> getNoise() {return rnoise;}
124 
125  // get time series for channel n
126  inline wavearray<double> channel(size_t n) {
127  WSeries<double> w = n<chList.size() ? chList[n] : chList[0];
128  w.Inverse(); return (wavearray<double>)w;
129  }
130 
131  // get rank values for all frequecy layers
132  //
133  // n: channel index
134  inline wavearray<double> getRank(int n) { //RANK
135  int tsize=vrank[n].size(); //RANK
136  wavearray<double> trank(tsize); //RANK
137  for (int i=0; i<tsize; i++) trank.data[i]=sqrt(vrank[n].data[i]); //RANK
138  return trank; //RANK
139  } //RANK
140 
141  // clear channel list
142  inline void clear() {
143  chList.clear(); std::vector< WSeries<double> >().swap(chList);
144  chName.clear(); std::vector< char* >().swap(chName);
145  chMask.clear(); std::vector< wavearray<int> >().swap(chMask);
146  FILTER.clear(); std::vector<Wiener>().swap(FILTER);
147  matrix.clear(); std::vector<TMatrixDSym>().swap(matrix);
148  vCROSS.clear(); std::vector< wavearray<double> >().swap(vCROSS);
149  vEIGEN.clear(); std::vector< wavearray<double> >().swap(vEIGEN);
150  vrank.clear(); std::vector< wavearray<double> >().swap(vrank); //RANK
151  vfreq.resize(0); //RANK
152  }
153 
154  // data members
155 
156  size_t kSIZE; // unit filter half-length
157  double Edge; // time offset at the boundaries
158  bool pOUT; // true/false printout flag
159 
160  std::vector< WSeries<double> > chList; // TF data: 0 - target, >0 - withess
161  std::vector<char*> chName; // channel names: 0 - target, >0-witness
162  std::vector< wavearray<int> > chMask; // layer mask: 0 - target, >0-witness
163  std::vector<Wiener> FILTER; // total Wiener filter
164  std::vector<TMatrixDSym> matrix; // symmetric matrix
165  std::vector< wavearray<double> > vCROSS; // cross-correlation vector
166  std::vector< wavearray<double> > vEIGEN; // vector of eigenvalues
167  wavearray<double> target; // target time series
168  wavearray<double> rnoise; // regressed out noise
169  WSeries<double> WNoise; // Wavelet series for regressed out noise
170  std::vector< wavearray<double> > vrank; //RANK
172 
173 
174 private:
175  void _apply_(int n,
176  std::vector< wavearray<double> > &w,
177  std::vector< wavearray<double> > &W);
178 
179  // used by THtml doc
180  ClassDef(regression,1)
181 
182 }; // class regression
183 
184 #endif // REGRESSION_HH
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:407
void _apply_(int n, std::vector< wavearray< double > > &w, std::vector< wavearray< double > > &W)
Definition: regression.cc:863
tuple f
Definition: cwb_online.py:91
WSeries< double > * getTFmap(int n=0)
Definition: regression.hh:109
WSeries< double > getWNoise()
Definition: regression.hh:114
wavearray< double > target
Definition: regression.hh:167
par[0] name
int n
Definition: cwb_net.C:10
wavearray< double > getNoise()
Definition: regression.hh:123
TMatrixTSym< double > TMatrixDSym
Definition: regression.hh:20
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
TMatrixDSym getMatrix(size_t n=0)
Definition: regression.hh:94
std::vector< wavearray< double > > vCROSS
Definition: regression.hh:165
int m
Definition: cwb_net.C:10
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:73
i drho i
std::vector< wavearray< double > > vEIGEN
Definition: regression.hh:166
nT
Definition: cbc_plots.C:659
std::vector< Wiener > FILTER
Definition: regression.hh:163
std::vector< WSeries< double > > chList
Definition: regression.hh:160
wavearray< double > w
Definition: Test1.C:27
wavearray< double > rank(int nbins=0, double fL=0., double fH=0.)
Definition: regression.cc:807
std::vector< double > vectorD
Definition: regression.hh:21
std::vector< vectorD > filter00
Definition: regression.hh:27
i() int(T_cor *100))
virtual ~regression()
Definition: regression.hh:49
double fhigh
void apply(double threshold=0., char c='a')
Definition: regression.cc:691
wavearray< double > getRank(int n)
Definition: regression.hh:134
std::vector< TMatrixDSym > matrix
Definition: regression.hh:164
std::vector< wavearray< int > > chMask
Definition: regression.hh:162
void solve(double th, int nE=0, char c='s')
Definition: regression.cc:592
std::vector< int > channel
Definition: regression.hh:24
wavearray< double > vfreq
Definition: regression.hh:171
std::vector< vectorD > filter90
Definition: regression.hh:28
size_t setFilter(size_t)
Definition: regression.cc:258
wavearray< double > getVEIGEN(int n=-1)
Definition: regression.cc:339
wavearray< double > getClean()
Definition: regression.hh:117
double Edge
Definition: regression.hh:157
size_t kSIZE
Definition: regression.hh:156
void clear()
Definition: regression.hh:142
std::vector< int > layer
Definition: regression.hh:25
double flow
std::vector< char * > chName
Definition: regression.hh:161
WSeries< double > WNoise
Definition: regression.hh:169
std::vector< double > norm
Definition: regression.hh:26
wavearray< double > getFILTER(char c='a', int nT=-1, int nW=-1)
Definition: regression.cc:355
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
wavearray< double > getVCROSS(size_t n=0)
Definition: regression.hh:101
DataType_t * data
Definition: wavearray.hh:301
std::vector< wavearray< double > > vrank
Definition: regression.hh:170
regression & operator=(const regression &)
Definition: regression.cc:50
wavearray< double > rnoise
Definition: regression.hh:168
virtual void resize(unsigned int)
Definition: wavearray.cc:445
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:273
wavearray< double > channel(size_t n)
Definition: regression.hh:126