Skip to content

Commit

Permalink
updating some figures, ContinuousWavelets.cwt because that still is a…
Browse files Browse the repository at this point in the history
… thing apparently
  • Loading branch information
dsweber2 committed Nov 14, 2021
1 parent 1c6d1f8 commit 712e04c
Show file tree
Hide file tree
Showing 4 changed files with 1,352 additions and 1,407 deletions.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ t = range(0,n/1000,length=n); # 1kHz sampling rate
f = testfunction(n, "Doppler");
p1=plot(t, f,legend=false,title="Doppler",xticks=false)
c = wavelet(Morlet(π), β=2);
res = cwt(f, c)
res = ContinuousWavelets.cwt(f, c)
# plotting
freqs = getMeanFreq(computeWavelets(n, c)[1])
freqs[1] = 0
Expand All @@ -43,30 +43,31 @@ As the cwt frame is redundant, there are many choices of dual/inverse frames. Th

``` julia
f = testfunction(n, "Bumps");
p1=plot(f,legend=false,title="Bumps",xlims=(0,2000))
c = wavelet(dog2, β=2);
res = cwt(f, c)
p1 = plot(f, legend = false, title = "Bumps", xlims = (0, 2000), linewidth = 2)
c = wavelet(dog2, β = 2);
res = ContinuousWavelets.cwt(f, c)
# dropping the middle peaks
res[620:1100,:] .=0
res[620:1100, :] .= 0
# and smoothing the remaining peaks
res[:,10:29] .= 0
# actually doing the inversion
dropped = ContinuousWavelets.icwt(res,c,DualFrames())

p1 = plot([dropped f],legend=false, title="Smoothing and dropping bumps")
p2=heatmap(abs.(res)', xlabel= "time index", ylabel="frequency index",colorbar=false)
l=@layout [a{.3h};b{.7h}]
plot(p1,p2,layout=l)
res[:, 10:end] .= 0
freqs = ContinuousWavelets.getMeanFreq(f, c)
p2 = heatmap(1:n, freqs, abs.(res)', xlabel = "time (ms)", ylabel = "Frequency (Hz)", colorbar = false, c = :viridis)
dropped = ContinuousWavelets.icwt(res, c, DualFrames())
p1 = plot(f, legend = false, title = "Smoothing and dropping bumps", linewidth = 2)
plot!(dropped, linewidth = 3)
l = @layout [a{0.3h}; b{0.7h}]
plot(p1, p2, layout = l)
```
![Bumps](/docs/bumps.svg)

It can also handle collections of examples at the same time, should you need to do a batch of transforms:
``` julia
exs = cat(testfunction(n, "Doppler"),testfunction(n,"Blocks"),testfunction(n,"Bumps"),testfunction(n,"HeaviSine"),dims=2)
c = wavelet(cDb2, β=2,extraOctaves=-0);
res = cwt(exs, c)
exs = cat(testfunction(n, "Doppler"), testfunction(n, "Blocks"), testfunction(n, "Bumps"), testfunction(n, "HeaviSine"), dims = 2)
c = wavelet(cDb2, β = 2, extraOctaves = -0);
res = circshift(ContinuousWavelets.cwt(exs, c), (0,1,0))
```
![parallel transforms](/docs/multiEx.svg)

There are also several boundary conditions, depending on the kind of data given; the default `SymBoundary()` symmetrizes the data, while `PerBoundary()` assumes it is periodic, and `ZPBoundary` pads with zeros.
All wavelets are stored in the Fourier domain, and all transforms consist of performing an fft (possibly an rfft if the data is real) of the input, pointwise multiplication (equivalent to convolution in the time domain), and then returning to the time domain.

Expand Down
20 changes: 11 additions & 9 deletions docs/allInOne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ global_logger(Logging.SimpleLogger(stderr, Logging.Error))
n = 2047;
t = range(0, n / 1000, length = n); # 1kHz sampling rate
f = testfunction(n, "Doppler");
p1 = plot(t, f, legend = false, title = "Doppler", xticks = false)
p1 = plot(t, f, legend = false, title = "Doppler", xticks = false, linewidth = 2)
c = wavelet(Morlet(π), β = 2);
res = cwt(f, c)
res = ContinuousWavelets.cwt(f, c)
# plotting
freqs = getMeanFreq(computeWavelets(n, c)[1])
freqs = getMeanFreq(ContinuousWavelets.computeWavelets(n, c)[1])
freqs[1] = 0
p2 = heatmap(t, freqs, abs.(res)', xlabel = "time (s)", ylabel = "frequency (Hz)", colorbar = false)
p2 = heatmap(t, freqs, abs.(res)', xlabel = "time (s)", ylabel = "frequency (Hz)", colorbar = false, c = :viridis)
l = @layout [a{0.3h}; b{0.7h}]
plot(p1, p2, layout = l)
savefig("../docs/doppler.svg");#hide
Expand Down Expand Up @@ -175,16 +175,18 @@ plot(p1, p2, layout = l)


f = testfunction(n, "Bumps");
p1 = plot(f, legend = false, title = "Bumps", xlims = (0, 2000))
p1 = plot(f, legend = false, title = "Bumps", xlims = (0, 2000), linewidth = 2)
c = wavelet(dog2, β = 2);
res = cwt(f, c)
res = ContinuousWavelets.cwt(f, c)
# dropping the middle peaks
res[620:1100, :] .= 0
# and smoothing the remaining peaks
res[:, 10:29] .= 0
p2 = heatmap(abs.(res)', xlabel = "time index", ylabel = "frequency index", colorbar = false)
res[:, 10:end] .= 0
freqs = ContinuousWavelets.getMeanFreq(f, c)
p2 = heatmap(1:n, freqs, abs.(res)', xlabel = "time (ms)", ylabel = "Frequency (Hz)", colorbar = false, c = :viridis)
dropped = ContinuousWavelets.icwt(res, c, DualFrames())
p1 = plot([dropped f], legend = false, title = "Smoothing and dropping bumps")
p1 = plot(f, legend = false, title = "Smoothing and dropping bumps", linewidth = 2)
plot!(dropped, linewidth = 3)
l = @layout [a{0.3h}; b{0.7h}]
plot(p1, p2, layout = l)
savefig("../docs/bumps.svg")
Expand Down
1,938 changes: 941 additions & 997 deletions docs/bumps.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 712e04c

Please sign in to comment.