Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DrawGWSeries.C
Go to the documentation of this file.
1 // This example shows how to produce a scalogram plot of
2 // a signal stored in a wavearray structure
3 
4 {
5  //#define SAVE_PLOT // uncomment to save plot to file
6 
7  #define SIG_FREQ 200 // centra signal frequency
8 
9  // instantiation
10  Meyer<double> S(1024,2); // set wavelet for production
11 
12  wavearray<double> x(16384);
13  x.rate(16384);
14  x.start(0);
15 
16  // add sin gaussian signal
17  double dt=1/x.rate();
18  double f=SIG_FREQ; // frequency (Hz)
19  double s=0.01; // gaussian RMS
20  for(int i=0;i<x.size();i++) {
21  int j=i-x.size()/2;
22  x[i]=exp(-pow(dt*j,2)/2/s/s)*sin(2*PI*f*dt*j);
23  }
24 
26 
27  // do transformation level=8 and assign to gWSeries class
29  gw.Forward(8);
30  // or
31 // w.Forward(8);
32 // gWSeries<double> gw(&w);
33 
34  cout << "level : " << gw.getLevel() << endl;
35 
36 
37  // plot scalogram
38  gw.DrawSG("FULL"); // full time range
39 // gw.DrawSG(); // zoom time range
40 
41 
42  watplot* plot = gw.GetWATPLOT();
43 
44  // set title
45  char gtitle[256];
46  sprintf(gtitle,"Scalogram");
47  plot->gtitle(gtitle,"time(sec)","amplitude");
48 
49  // set the frequency range to be displayed
50  plot->hist2D->GetYaxis()->SetRangeUser(SIG_FREQ-100, SIG_FREQ+100);
51 
52 #ifdef SAVE_PLOT
53  // save plot to file
54  TString gfile="gwavearray_plot.png";
55  plot->canvas->Print(gfile);
56 
57  cout << "created plot file name : " << gfile << endl;
58 
59  exit(0);
60 #endif
61 
62  return plot->canvas; // used by THtml
63 }
virtual size_t size() const
Definition: wavearray.hh:127
void gtitle(TString title="", TString xtitle="", TString ytitle="")
Definition: watplot.cc:1237
double f
Definition: DrawGWSeries.C:18
virtual void rate(double r)
Definition: wavearray.hh:123
wavearray< double > x(16384)
TString("c")
virtual void start(double s)
Definition: wavearray.hh:119
int j
Definition: cwb_net.C:10
i drho i
TH2F * hist2D
Definition: watplot.hh:175
#define PI
Definition: watfun.hh:14
TCanvas * canvas
Definition: watplot.hh:174
gWSeries< double > gw(w)
double dt
Definition: DrawGWSeries.C:17
x plot
WSeries< double > w(x, S)
double s
Definition: DrawGWSeries.C:19
cout<< "level : "<< gw.getLevel()<< endl;gw.DrawSG("FULL");watplot *plot=gw.GetWATPLOT();char gtitle[256];sprintf(gtitle,"Scalogram");plot-> gtitle(gtitle,"time(sec)","amplitude")
#define SIG_FREQ
Definition: Meyer.hh:18
Meyer< double > S(1024, 2)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
TString gfile
exit(0)