Skip to content

Commit eb53d69

Browse files
Merge pull request #74 from JaredW40/patch-16
Update allInOne.jl
2 parents 32d5a0a + 9692008 commit eb53d69

File tree

1 file changed

+75
-60
lines changed

1 file changed

+75
-60
lines changed

docs/allInOne.jl

Lines changed: 75 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using ContinuousWavelets, Plots, Wavelets, FFTW, Logging
2-
global_logger(SimpleLogger(min_level = Logging.Error))
2+
global_logger(Base.SimpleLogger(stdout, Logging.Info))
33
global_logger(Logging.SimpleLogger(stderr, Logging.Error))
44
n = 2047;
55
t = range(0, n / 2000, length = n); # 2kHz sampling rate
@@ -30,7 +30,7 @@ waveType = Morlet()
3030
Ψ1 = wavelet(waveType, s = 8, β = dRate, averagingLength = 2)
3131
# sketch of how the frequencies are chosen
3232
pyplot()
33-
locs = polySpacing(8, Ψ1);
33+
locs = ContinuousWavelets.polySpacing(8, Ψ1);
3434
#Figure 3.1
3535
scatter(1:length(locs),
3636
locs,
@@ -45,7 +45,7 @@ scatter!(length(locs):length(locs),
4545
markershape = :x,
4646
color = :black,
4747
label = :none)
48-
firstW, lastW, stepS = genSamplePoints(8, Ψ1)
48+
firstW, lastW, stepS = ContinuousWavelets.genSamplePoints(8, Ψ1)
4949
b = (dRate / Ψ1.Q)^(1 ./ dRate) * (8 + Ψ1.averagingLength)^((dRate - 1) / dRate)
5050
t = range(1, stop = length(locs), step = 0.1)
5151
curve = b .*
@@ -123,72 +123,87 @@ gr();
123123
Plots.reset_defaults()
124124
global_logger(Logging.SimpleLogger(stderr, Logging.Error))
125125
n = 2047;
126-
function mapTo(waveType, isReal = true, window = 1:2047; d = 1, kwargs...)
126+
function mapTo(waveType, isReal = true, window = 1:2047; d = 1, γ = 4.0, β = 2.0, cf = 1.0, kwargs...)
127+
if waveType == Morse
128+
morse_wav = Morse(float(γ), float(β), float(cf))
129+
c = wavelet(morse_wav; kwargs...)
130+
else
131+
c = wavelet(waveType; β=d, kwargs...)
132+
end
133+
waves, ω = computeWavelets(n, c)
127134
if isReal
128-
c = wavelet(waveType; β = d, kwargs...)
129-
waves, ω = computeWavelets(n, c)
130-
return circshift(irfft(waves, 2 * n, 1), (1024, 0))[window, :]
135+
return circshift(irfft(waves, 2*n, 1), (1024, 0))[window, :]
131136
else
132-
c = wavelet(waveType; β = d, kwargs...)
133-
waves, ω = computeWavelets(n, c)
134137
waves = cat(waves, zeros(2047, size(waves, 2)), dims = 1)
135138
return circshift(ifft(waves, 1), (1024, 0))[window, :]
136139
end
137140
end
138141
tmp = mapTo(Morlet(π), false; averagingLength = -0.2)[:, 2]
139142
p1 = plot([real.(tmp) imag.(tmp)],
140-
title = "Morlet",
141-
labels = ["real" "imaginary"],
142-
ticks = nothing,
143-
linewidth = 5)
143+
title = "Morlet",
144+
labels = ["real" "imaginary"],
145+
ticks = nothing,
146+
linewidth = 5)
144147
tmp = mapTo(paul2, false, averagingLength = -0.5)[:, 2]
145148
p2 = plot([real.(tmp) imag.(tmp)],
146-
title = "Paul 2",
147-
labels = ["real" "imaginary"],
148-
ticks = nothing,
149-
linewidth = 5)
150-
p3 = plot(mapTo(dog2; averagingLength = -1.5)[:, 2],
151-
title = "derivative of gaussians (dog2)",
152-
legend = false,
153-
ticks = nothing,
154-
linewidth = 5)
155-
p4 = plot(mapTo(cHaar, true; averagingLength = 1)[:, 2],
156-
title = "Haar",
157-
legend = false,
158-
ticks = nothing,
159-
linewidth = 5)
160-
p5 = plot(mapTo(cBeyl, true; d = 1, averagingLength = -0)[:, 2],
161-
title = "Beylkyin",
162-
legend = false,
163-
ticks = nothing,
164-
linewidth = 5)
165-
p6 = plot(mapTo(cVaid, true; d = 1, averagingLength = -0)[:, 2],
166-
title = "Vaidyanathan",
167-
legend = false,
168-
ticks = nothing,
169-
linewidth = 5)
170-
p7 = plot(mapTo(cDb2; d = 1, averagingLength = -0)[:, 2],
171-
title = "Daubhechies 2",
172-
legend = false,
173-
ticks = nothing,
174-
linewidth = 5)
175-
p8 = plot(mapTo(cCoif2, true; d = 1, averagingLength = -0)[:, 2],
176-
title = "Coiflet 2",
177-
legend = false,
178-
ticks = nothing,
179-
linewidth = 5)
180-
p9 = plot(mapTo(cSym4, true; d = 1, averagingLength = -0)[:, 2],
181-
title = "Symlet 4",
182-
legend = false,
183-
ticks = nothing,
184-
linewidth = 5)
149+
title = "Paul 2",
150+
labels = ["real" "imaginary"],
151+
ticks = nothing,
152+
linewidth = 5)
153+
tmpMorse1 = mapTo(Morse, false; β=3, γ=10.0, cf=1.0, averagingLength=-1)[:, 2]
154+
p3 = plot([real.(tmpMorse1) imag.(tmpMorse1)],
155+
title = "Morse (β=3, γ=10)",
156+
labels = ["real" "imaginary"],
157+
ticks = nothing,
158+
linewidth = 4)
159+
tmpMorse2 = mapTo(Morse, false; β=1, γ=3.0, cf=1.0, averagingLength=-2)[:, 2]
160+
p4 = plot([real.(tmpMorse2) imag.(tmpMorse2)],
161+
title = "Morse (β=1, γ=3)",
162+
labels = ["real" "imaginary"],
163+
ticks = nothing,
164+
linewidth = 4)
165+
p5 = plot(mapTo(dog2; averagingLength = -1.5)[:, 2],
166+
title = "derivative of gaussians (dog2)",
167+
legend = false,
168+
ticks = nothing,
169+
linewidth = 5)
170+
p6 = plot(mapTo(cHaar, true; averagingLength = 1)[:, 2],
171+
title = "Haar",
172+
legend = false,
173+
ticks = nothing,
174+
linewidth = 5)
175+
p7 = plot(mapTo(cBeyl, true; d = 1, averagingLength = -0)[:, 2],
176+
title = "Beylkyin",
177+
legend = false,
178+
ticks = nothing,
179+
linewidth = 5)
180+
p8 = plot(mapTo(cVaid, true; d = 1, averagingLength = -0)[:, 2],
181+
title = "Vaidyanathan",
182+
legend = false,
183+
ticks = nothing,
184+
linewidth = 5)
185+
p9 = plot(mapTo(cDb2; d = 1, averagingLength = -0)[:, 2],
186+
title = "Daubhechies 2",
187+
legend = false,
188+
ticks = nothing,
189+
linewidth = 5)
190+
p10 = plot(mapTo(cCoif2, true; d = 1, averagingLength = -0)[:, 2],
191+
title = "Coiflet 2",
192+
legend = false,
193+
ticks = nothing,
194+
linewidth = 5)
195+
p11 = plot(mapTo(cSym4, true; d = 1, averagingLength = -0)[:, 2],
196+
title = "Symlet 4",
197+
legend = false,
198+
ticks = nothing,
199+
linewidth = 5)
185200
k = 0600;
186-
p10 = plot(mapTo(cBatt4, true, 1024-k:1024+k; d = 1, averagingLength = -1)[:, 2],
187-
title = "Battle-Lemarie, 4",
188-
legend = false,
189-
ticks = nothing,
190-
linewidth = 5);
191-
plot(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, layout = (2, 5), size = 300 .* (5, 2.2))
201+
p12 = plot(mapTo(cBatt4, true, 1024-k:1024+k; d = 1, averagingLength = -1)[:, 2],
202+
title = "Battle-Lemarie, 4",
203+
legend = false,
204+
ticks = nothing,
205+
linewidth = 5);
206+
plot(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, layout = (3, 4), size = 300 .* (5, 3.2))
192207
savefig("mothers.svg")#hide
193208
2047 / 2
194209

@@ -250,15 +265,15 @@ p2 = plot(heatmap(identity.(res[:, :, 1])',
250265
l = @layout [a{0.3h}; b{0.7h}]
251266
plot(p1, p2, layout = l)
252267
savefig("multiEx.svg")
253-
getNOctaves(n, wavelet(cCoif2))
268+
ContinuousWavelets.getNOctaves(n, wavelet(cCoif2))
254269
log2(n)
255270
n / 2
256271
c = wavelet(cCoif2, β = 1, Q = 1)
257272
wave, ω = computeWavelets(n, wavelet(cCoif4, β = 1, Q = 1); space = true)
258273
i = 1;
259274
count(abs.(wave[:, i]) / norm(wave[:, i]) .> 1e-7);
260275
plot(wave[1000:1090, end])
261-
calcDepth(c, n)
276+
ContinuousWavelets.calcDepth(c, n)
262277
log2(n)
263278
log2(length(qmf(c.waveType)))
264279
log2(n)

0 commit comments

Comments
 (0)