-
Notifications
You must be signed in to change notification settings - Fork 5
/
stokes.jl
101 lines (83 loc) · 2.68 KB
/
stokes.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
module stokes
using stft
using cohenclass
using smethod
import DSP
function get_StokesTFR(W11,W22,W12,W21)
I=W11+W22
Q=W11-W22
U=W12+W21
V=(W21-W12)*(im)
return I,Q,U,V
end
function get_StokesTFR_LR(W11,W22,W12,W21)
I=W11+W22
V=W11-W22
Q=W12+W21
U=(W21-W12)*(im)
return I,Q,U,V
end
function spstokes(y1,y2,t=NaN,N=NaN,f=NaN,itc=NaN,h=NaN,nwindow=4,silent=0,method="mean",def="wolf")
#Stokes Distribution for a spectrogram
z1=stft.tfrstft(y1,t,N,f,itc,h,nwindow,silent);
z2=stft.tfrstft(y2,t,N,f,itc,h,nwindow,silent);
W11=z1.*conj(z1)
W22=z2.*conj(z2)
W12=z2.*conj(z1)
W21=z1.*conj(z2)
if def == "wolf"
I,Q,U,V=get_StokesTFR(W11,W22,W12,W21)
elseif def == "LR"
I,Q,U,V=get_StokesTFR_LR(W11,W22,W12,W21)
end
return I,Q,U,V
end
function wvstokes(y1,y2,t=NaN,f=NaN,itc=NaN,silent=0,method="mean",def="wolf")
#Stokes Distribution for the Wigner Ville Distribution
z1=DSP.Util.hilbert(y1)
z2=DSP.Util.hilbert(y2)
W11=cohenclass.tfrwv(z1,NaN,t,f,itc,silent,method)
W22=cohenclass.tfrwv(z2,NaN,t,f,itc,silent,method)
W12=cohenclass.tfrwv(z2,z1,t,f,itc,silent,method)
W21=cohenclass.tfrwv(z1,z2,t,f,itc,silent,method)
if def == "wolf"
I,Q,U,V=get_StokesTFR(W11,W22,W12,W21)
elseif def == "LR"
I,Q,U,V=get_StokesTFR_LR(W11,W22,W12,W21)
end
return I,Q,U,V
end
function pwvstokes(y1,y2,t=NaN,f=NaN,itc=NaN,h=NaN,silent=0,method="fft",nwindow=4,Nz=1,def="wolf")
#Stokes Distribution for pseudo Wigner Ville Distribution
if def=="wolf"
z1=DSP.Util.hilbert(y1)
z2=DSP.Util.hilbert(y2)
elseif def == "LR"
z1=(y1)
z2=(y2)
end
W11=cohenclass.tfrpwv(z1,NaN,t,f,itc,h,silent,method,nwindow,Nz)
W22=cohenclass.tfrpwv(z2,NaN,t,f,itc,h,silent,method,nwindow,Nz)
W12=cohenclass.tfrpwv(z2,z1,t,f,itc,h,silent,method,nwindow,Nz)
W21=cohenclass.tfrpwv(z1,z2,t,f,itc,h,silent,method,nwindow,Nz)
if def == "wolf"
I,Q,U,V=get_StokesTFR(W11,W22,W12,W21)
elseif def == "LR"
I,Q,U,V=get_StokesTFR_LR(W11,W22,W12,W21)
end
return I,Q,U,V
end
function smstokes(y1,y2,Lp=6,f=NaN,silent=0,nwindow=4,fps=NaN,fpe=NaN,itc=NaN,def="wolf")
#Stokes Distribution for S-method
sm11=smethod.tfrsm(y1,NaN,Lp,f,nwindow,silent,fps,fpe,itc)
sm22=smethod.tfrsm(y2,NaN,Lp,f,nwindow,silent,fps,fpe,itc)
sm12=smethod.tfrsm(y2,y1,Lp,f,nwindow,silent,fps,fpe,itc)
sm21=smethod.tfrsm(y1,y2,Lp,f,nwindow,silent,fps,fpe,itc)
if def == "wolf"
I,Q,U,V=get_StokesTFR(sm11,sm22,sm12,sm21)
elseif def == "LR"
I,Q,U,V=get_StokesTFR_LR(sm11,sm22,sm12,sm21)
end
return I,Q,U,V
end
end