coherent WaveBurst
Library Reference Guide
home
cWB_docker
git
cWB
library
wat
tutorials
testWDM_4.C
Go to the documentation of this file.
1
{
// apply transformation on white noise and produce a power spectral density plot
2
3
int
Rate
= 1024;
// sampling rate (Hz)
4
int
Duration
= 100;
// duration (seconds)
5
int
N
= Rate*
Duration
;
// number of samples
6
wavearray<double>
ts
(N);
//time series container
7
ts
.
rate
(Rate);
8
9
// time series is filled with white noise data:
10
// add a sine wave @ 200Hz:
11
double
T
= 1./
Rate
;
12
double
omega
= TMath::TwoPi()*200;
13
for
(
int
i
=0;
i
<
N
;
i
++)
ts
[
i
] += sin(omega*
i
*T);
14
TRandom3
rnd
(0);
15
for
(
int
i
=0;
i
<
N
;
i
++) {
16
ts
[
i
] =
rnd
.Gaus();
17
ts
[
i
] += sin(omega*
i
*T);
18
}
19
20
// produce the TF map:
21
WDM<double>
wdm
(32, 64, 4, 8);
// define a WDM transform (32 bands)
22
WSeries<double>
tfmap
;
// TF map container
23
tfmap.
Forward
(
ts
,
wdm
, 0);
// apply the WDM to the time series
24
watplot
pl
;
25
26
// fft of original ts
27
pl.
plot
(
ts
,const_cast<char*>(
"APL"
),1,4.,
ts
.
stop
()-4.,
true
,0.,0.,
true
,1./16);
28
29
// compute PSD
30
wavearray<double>
x
;
31
wavearray<double>
psd
(33);
32
psd
.
rate
(1./16);
33
for
(
int
i
=0;
i
<=32; ++
i
){
34
tfmap.
getLayer
(x,
i
);
35
psd
.
data
[
i
] = x.
mean
()/
Rate
;
36
//printf("%d\n", tmp.size());
37
if
(
i
==0 ||
i
==32)
psd
.
data
[
i
] *= 2;
38
psd
.
data
[
i
] = sqrt(
psd
.
data
[
i
]);
39
}
40
pl.
plot
(
psd
,const_cast<char*>(
"SAME"
),2);
41
}
wavearray::rate
virtual void rate(double r)
Definition:
wavearray.hh:141
wavearray< double >
wdm
WDM< double > wdm(32, 64, 4, 8)
Rate
int Rate
Definition:
DrawClusterWithSkyplot.C:10
psd
wavearray< double > psd(33)
i
i drho i
Definition:
cwb_epparameters.C:88
rnd
TRandom3 rnd(1)
watplot::plot
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
watplot
Definition:
watplot.hh:45
WSeries::getLayer
int getLayer(wavearray< DataType_t > &w, double n)
param: n - layer number
Definition:
wseries.cc:193
WSeries< double >
Duration
int Duration
Definition:
testWDM_4.C:4
WDM< double >
T
double T
Definition:
testWDM_4.C:11
pl
watplot pl
Definition:
testWDM_4.C:24
wavearray::mean
virtual double mean() const
Definition:
wavearray.cc:1071
wavearray::stop
virtual void stop(double s)
Definition:
wavearray.hh:139
WSeries::Forward
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition:
wseries.cc:246
omega
double omega
Definition:
testWDM_4.C:12
ts
wavearray< double > ts(N)
wavearray::data
DataType_t * data
Definition:
wavearray.hh:319
tfmap
WSeries< double > tfmap
Definition:
testWDM_4.C:22
x
wavearray< double > x
Definition:
testWDM_4.C:30
N
int N
Definition:
testWDM_4.C:5