Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DrawWDM.C
Go to the documentation of this file.
4 
5 void DrawWDM() {
6  //
7  // Instantiation of object CWB::mdc
8  // Get Waveform , WDM Transform - Plot WDM Scalogram using watplot
9  // Author : Gabriele Vedovato
10 
11  //#define WNB_MDC
12  //#define RD_MDC
13  #define SGQ_MDC
14 
15  #define WDM_TF
16  #define WDM_XCHECK
17 
18  MDC = new CWB::mdc;
19 
20 #ifdef WNB_MDC
21  wavearray<double> x = MDC->GetWNB(1000., 1000., 0.01);
22 #endif
23 #ifdef RD_MDC
24  wavearray<double> x = MDC->GetRD(1000., 0.2, 10.);
25 #endif
26 #ifdef SGQ_MDC
27  wavearray<double> x = MDC->GetSGQ(1053., 9);
28 #endif
29 
30  //MDC->Draw(x); // Draw Waveform in time domain
31  //MDC->Draw(x,MDC_FFT); // Draw Waveform in frequency domain
32  //MDC->Draw(x,MDC_TF); // Draw Waveform in time/frequency domain
33 
34  // compute x energy
35  double E=0;
36  double dt=1./x.rate();
37  for(int i=0;i<x.size();i++) E+=x[i]*x[i]*dt;
38  cout << "E = " << E << endl;
39 
40  // perform WDM transform level=512
41  double R = x.rate();
42  int level = 512;
43 
44  double dF = R/(2*level); // frequency resolution
45  double dT = level/R; // time resolution
46 
47  WDM<double> wdtf(level, level, 4, 10);
49  w.Forward(x, wdtf);
50 
51  cout << "WDM Decomposition Level : " << w.getLevel()
52  << " dF : " << dF << " Hz " << " dT : " << 1000*dT << " ms " <<endl;
53 
54  // Compute Energy
56  int M = w.getLevel();
57  int L = wdm->maxLayer();
58  cout << "WDM Decomposition Level : " << M << " Layers " << L << endl;
59 
60  int mF = int(w.size()/wdm->nSTS);
61  int nTC = w.size()/(M+1)/mF; // # of Time Coefficients
62  // Extract map00 & map90 : size = (M+1)*nTC
63  double* map00 = wdm->pWWS;
64  double* map90 = map00 + (mF-1)*(M+1)*nTC;
65 
68  E=0;
69  // this example show the corrispondence between map00,map90 and xx,XX
70  for(int j=0;j<M+1;j++) { // loop over the layers
71  w.getLayer(xx,j); // extract phase 00 @ layer j
72  w.getLayer(XX,-j); // extract phase 90 @ layer j
73  // for phase 00 -> (xx[i] = map00[i*(M+1)+j])
74  // for phase 90 -> (XX[i] = map90[i*(M+1)+j])
75  for(int i=0;i<xx.size();i++) {
76 // cout << j << " P00 " << xx[i] << " " << map00[i*(M+1)+j]
77 // << " P90 " << XX[i] << " " << map90[i*(M+1)+j] << endl;
78  }
79  for(int i=0;i<xx.size();i++) E+=xx[i]*xx[i];
80  //for(int i=0;i<XX.size();i++) E+=XX[i]*XX[i];
81  }
82  cout << "E = " << E << endl;
83 
84 #ifdef WDM_TF
85  // Plot WDM Scalogram
86  WTS = new watplot(const_cast<char*>("wtswrc"));
87  //scalogram maps
88  double start = w.start();
89  double stop = w.start()+w.size()/w.rate();
90  double flow = 64;
91  double fhigh = 2048;
92  WTS->plot(&w, 2, start, stop,const_cast<char*>("COLZ"));
93  WTS->hist2D->GetYaxis()->SetRangeUser(flow, fhigh);
94  // dump spectrum
95  char fname[1024];
96  sprintf(fname,"wdm_scalogram_%d_lev%d.root", int(w.start()),w.getLevel());
97  cout << endl << "Dump WDM Scalogram : " << fname << endl << endl;
98  WTS->canvas->Print(fname);
99 #endif
100 
101 #ifdef WDM_XCHECK
102  // Compare Signal before/after WDM Forward/Inverse Tranform
103  w.Inverse();
105 
106  plot = new watplot(const_cast<char*>("plot"),200,20,800,500);
107  char gtitle[256];
108  sprintf(gtitle,"WDM : Original(black) - After WDM Forward/Inverse Tranform(Red)");
109  plot->gtitle(gtitle,"time(sec)","amplitude");
110  plot->goptions(const_cast<char*>("alp"), 1, 0., 0.);
111  // draw signal
112  //y-=x; // difference
113  x >> *plot;
114  y >> *plot;
115 
116  // save plot to file
117  TString gfile="WDM_time_xcheck.png";
118  *plot >> gfile;
119 #endif
120 
121 }
watplot * plot
Definition: DrawWDM.C:3
virtual size_t size() const
Definition: wavearray.hh:127
void gtitle(TString title="", TString xtitle="", TString ytitle="")
Definition: watplot.cc:1237
virtual void rate(double r)
Definition: wavearray.hh:123
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
TString("c")
wavearray< double > GetSGQ(double frequency, double Q)
Definition: mdc.cc:2976
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
WDM< double > wdm(nLAYERS, nLAYERS, 6, 10)
TString mdc[4]
plot gtitle(gtitle,"frequency (Hz)","strain/#sqrt{Hz}")
watplot * WTS
Definition: DrawWDM.C:2
#define M
Definition: UniqSLagsList.C:3
DataType_t * pWWS
Definition: WaveDWT.hh:123
virtual void start(double s)
Definition: wavearray.hh:119
int j
Definition: cwb_net.C:10
i drho i
void DrawWDM()
Definition: DrawWDM.C:5
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
Definition: watplot.cc:132
CWB::mdc * MDC
Definition: DrawWDM.C:1
TH2F * hist2D
Definition: watplot.hh:175
virtual int maxLayer()
Definition: Wavelet.hh:71
wavearray< double > w
Definition: Test1.C:27
TCanvas * canvas
Definition: watplot.hh:174
int getLevel()
Definition: wseries.hh:91
wavearray< double > xx
Definition: TestFrame1.C:11
unsigned long nSTS
Definition: WaveDWT.hh:125
Definition: mdc.hh:216
i() int(T_cor *100))
double fhigh
int getLayer(wavearray< DataType_t > &w, double n)
param: n - layer number
Definition: wseries.cc:175
char fname[1024]
wavearray< double > GetWNB(double frequency, double bandwidth, double duration, int seed=0, bool mode=0)
Definition: mdc.cc:3024
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
double dt
double flow
WDM< double > wdtf(lev, 2 *lev, 6, 10)
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
TString gfile
WaveDWT< DataType_t > * pWavelet
Definition: wseries.hh:438
double dT
Definition: testWDM_5.C:12
wavearray< double > GetRD(double frequency, double tau, double iota, bool polarization=0)
Definition: mdc.cc:3139
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:273
wavearray< double > y
Definition: Test10.C:31