Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HowToAccessToWSeries.C
Go to the documentation of this file.
1 // This example shows how access to SSeries
2 
3 {
4  #define nLAYERS 32 // number of frequency layers
5  #define RATE 512 // sample rate
6  #define DURATION 2 // duration of data
7 
8  char title[256];
9 
10  // create watplot
12  TCanvas* canvas = plot->canvas;
13  canvas->Divide(1,2);
14 
15  // define wavearray time series
16  int Rate = RATE; // sampling rate (Hz)
17  int Duration = DURATION; // duration (seconds)
18  int N = Rate*Duration; // number of samples
19  wavearray<double> ts(N); // time series container
20  ts.rate(Rate); // set rate
21  ts=0; // set array to zero
22 
23  // time series is filled with SG100Q9:
24  double Q=9.;
25  double amplitude=1.;
26  double frequency=100.;
27  double duration = Q/(TMath::TwoPi()*frequency);
28  CWB::mdc::AddSGBurst(ts,amplitude, frequency, duration,0);
29 
30  // produce the TF map:
31  WDM<double> wdm(nLAYERS, 2*nLAYERS, 4, 8); // define a WDM transform (32 bands)
32  WSeries<double> tfmap; // TF map container
33  tfmap.Forward(ts, wdm); // apply the WDM to the time series
34 
35  // compute dfxdt pixel resolution
36  double df = tfmap.resolution(); // frequency bin resolution (hz)
37  double dt = 1./(2*df); // time bin resolution (sec)
38  char tfres[64]; sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)",2*df,df);
39 
40  // plot the TF map as energy average of 0 and 90 degree phases (quadratures)
41  canvas->cd(1);
42  gPad->SetGridx(); gPad->SetGridy();
43  plot->plot(tfmap);
44  plot->hist2D->SetName("WSeries-1");;
45  sprintf(title,"%s - Res : %s","TF Map : Signal",tfres);
46  plot->hist2D->SetTitle(title);;
47 
48  int layers = tfmap.maxLayer()+1; // numbers of frequency bins (first & last bins have df/2)
49  int slices = tfmap.sizeZero(); // number of time bins
50 
51  // set to 0 the pixels under the THRESHOLD
52  double THRESHOLD = 2;
53  for(int i=0;i<slices;i++) {
54  for(int j=0;j<layers;j++) {
55  // the second parameter is double
56  // epsilon=0.01 is used to select the 0 layer for phase 90
57  float A00 = tfmap.getSample(i,j+0.01); // get phase 00 amplitude
58  float A90 = tfmap.getSample(i,-(j+0.01)); // get phase 90 amplitude
59  // compute energy average of 0 and 90 degree phases (quadratures)
60  double EE = sqrt((A00*A00+A90*A90)/2);
61  if(EE<THRESHOLD) {
62  //cout << i << " " << j << " " << EE << endl;
63  tfmap.putSample(0,i,j+0.01); // set to 0 the phase 00 amplitude
64  tfmap.putSample(0,i,-(j+0.01)); // set to 0 the phase 90 amplitude
65  }
66  }
67  }
68 
69  // plot the TF map as energy average of 0 and 90 degree phases (quadratures)
70  canvas->cd(2);
71  gPad->SetGridx(); gPad->SetGridy();
72  plot->hist2D=NULL;
73  plot->plot(tfmap);
74  plot->hist2D->SetName("WSeries-2");;
75  sprintf(title,"%s - Res : %s - pixels above the threshold (sqrt((A00*A00+A90*A90)/2)>%g","TF Map : Signal",tfres,THRESHOLD);
76  plot->hist2D->SetTitle(title);;
77 
78  return canvas;
79 }
int Rate
virtual void rate(double r)
Definition: wavearray.hh:123
#define RATE
void putSample(DataType_t a, int n, double m)
Definition: wseries.hh:177
wavearray< double > ts(N)
double frequency
int layers
int j
Definition: cwb_net.C:10
i drho i
int Duration
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
double amplitude
TH2F * hist2D
Definition: watplot.hh:175
double duration
TCanvas * canvas
Definition: watplot.hh:174
double Q
TCanvas * canvas
WDM< double > wdm(nLAYERS, 2 *nLAYERS, 4, 8)
watplot * plot
int slices
char title[256]
Definition: SSeriesExample.C:1
#define nLAYERS
#define DURATION
double dt
double resolution(int=0)
Definition: wseries.hh:137
char tfres[64]
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
double df
WSeries< double > tfmap
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
DataType_t getSample(int n, double m)
Definition: wseries.hh:167
size_t sizeZero()
Definition: wseries.hh:126
int maxLayer()
Definition: wseries.hh:121
static void AddSGBurst(wavearray< double > &td, double a, double f, double s, double d=0.)
Definition: mdc.cc:3250
double THRESHOLD