Logo coherent WaveBurst  
Library Reference Guide
Logo
DrawClusterWithSkyplot.C
Go to the documentation of this file.
1 {
2  // show how to plot netcluster with watplot class
3 
4  int nifo=1;
5 
6  // create watplot
8 
9  // define wavearray time series
10  int Rate = 512; // sampling rate (Hz)
11  int Duration = 2; // duration (seconds)
12  int N = Rate*Duration; // number of samples
13  wavearray<double> ts(N); // time series container
14  ts.rate(Rate); // set rate
15  ts=0; // set array to zero
16 
17  // time series is filled with SG100Q9:
18  double Q=9.;
19  double amplitude=1.;
20  double frequency=100.;
21  double duration = Q/(TMath::TwoPi()*frequency);
22  CWB::mdc::AddSGBurst(ts,amplitude, frequency, duration,0);
23 
24  // produce the TF map:
25  WDM<double> wdm(32, 64, 4, 8); // define a WDM transform (32 bands)
26  WSeries<double> tfmap; // TF map container
27  tfmap.Forward(ts, wdm); // apply the WDM to the time series
28 
29  int layers = tfmap.maxLayer()+1; // numbers of frequency bins (first & last bins have df/2)
30  int slices = tfmap.sizeZero(); // number of time bins
31 
32  // create netpixel
33  netpixel pix(nifo);
34  pix.core = true;
35  pix.rate = tfmap.wrate();
36  pix.layers = layers;
37 
38  // create netcluster
40  wc.clear();
41  wc.setlow(0);
42  wc.sethigh(Rate/2.);
43  wc.start = tfmap.start();
44  wc.stop = tfmap.stop();
45  wc.rate = tfmap.rate();
46 
47  // fill netcluster with netpixels over the threshold
48  int ifoID=0;
49  int nPix=0;
50  double THRESHOLD = 2;
51  for(int i=0;i<slices;i++) {
52  for(int j=0;j<layers;j++) {
53  // get 00 phase amplitude
54  double A00 = float(tfmap.pWavelet->pWWS[i*(layers)+j]);
55  // get 90 phase amplitude
56  double A90 = float(tfmap.pWavelet->pWWS[i*(layers)+j+tfmap.maxIndex()+1]);
57  // compute energy average of 0 and 90 degree phases (quadratures)
58  double EE = sqrt((A00*A00+A90*A90)/2);
59  // select pixels above the THRESHOLD
60  if(EE>THRESHOLD) {
61  //cout << i << " " << j << " " << EE << endl;
62  // fill netpixel
63  int index = i*layers+j; // sample index
64  pix.data[ifoID].index = index;
65  pix.data[ifoID].asnr = A00;
66  pix.time = index;
67  pix.frequency = j;
68  wc.append(pix); // save pixels in wc
69  nPix++;
70  }
71  }
72  }
73  cout << "Selected Pixels : " << nPix << endl;
74 
75  wc.cluster(1,1); // cluster pixels
76 
77  // plot netcluster
78  wmap->plot(&wc,1,1,'L',0);
79 
80  return wmap->canvas; // used by THtml doc
81 }
double stop
Definition: netcluster.hh:380
int slices
double duration
virtual void rate(double r)
Definition: wavearray.hh:141
double THRESHOLD
size_t frequency
Definition: netpixel.hh:111
size_t maxIndex()
Definition: wseries.hh:149
double frequency
std::vector< pixdata > data
Definition: netpixel.hh:122
double amplitude
netpixel pix(nifo)
int layers
size_t layers
Definition: netpixel.hh:112
DataType_t * pWWS
Definition: WaveDWT.hh:141
virtual void start(double s)
Definition: wavearray.hh:137
int j
Definition: cwb_net.C:28
i drho i
double rate
Definition: netcluster.hh:378
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:150
bool core
Definition: netpixel.hh:120
void setlow(double f)
Definition: netcluster.hh:345
void wrate(double r)
Definition: wseries.hh:120
TCanvas * canvas
Definition: watplot.hh:192
virtual size_t cluster()
return number of clusters
Definition: netcluster.cc:469
void sethigh(double f)
Definition: netcluster.hh:346
double start
Definition: netcluster.hh:379
WSeries< double > tfmap
virtual size_t append(netcluster &wc)
param: input netcluster return size of appended pixel list
Definition: netcluster.cc:769
WDM< double > wdm(32, 64, 4, 8)
size_t time
Definition: netpixel.hh:110
watplot * wmap
int nifo
wavearray< int > index
virtual void stop(double s)
Definition: wavearray.hh:139
int Duration
double Q
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:246
netcluster wc
WaveDWT< DataType_t > * pWavelet
Definition: wseries.hh:456
wavearray< double > ts(N)
float rate
Definition: netpixel.hh:113
size_t sizeZero()
Definition: wseries.hh:144
int maxLayer()
Definition: wseries.hh:139
static void AddSGBurst(wavearray< double > &td, double a, double f, double s, double d=0.)
Definition: mdc.cc:3279
void clear()
Definition: netcluster.hh:427