|
2 | 2 |
|
3 | 3 | [](https://travis-ci.com/dsweber2/ContinuousWavelets.jl) |
4 | 4 | [](https://codecov.io/gh/dsweber2/ContinuousWavelets.jl) |
| 5 | +[](https://dsweber2.github.io/ContinuousWavelets.jl/dev/) |
5 | 6 |
|
6 | | -This package is an offshoot of Wavelets.jl to contain strictly the continuous |
7 | | -wavelets. Thanks to github user @fgerick for the initial implementation there. |
| 7 | +This package is an offshoot of [Wavelets.jl](https://github.com/JuliaDSP/Wavelets.jl) for the continuous wavelets. |
| 8 | +Thanks to [Felix Gerick](https://github.com/fgerick) for the initial implementation there, with extension and further adaptation by David Weber and any other contributors listed on the right. |
| 9 | +Currently, it implements 1D continuous wavelet transforms with the following mother wavelets: |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +Which covers several standard continuous wavelet families, both real and analytic, as well as continuous versions of the orthogonal wavelet transforms implemented in [Wavelets.jl](https://github.com/JuliaDSP/Wavelets.jl). |
| 14 | + |
| 15 | +Basic Usage |
| 16 | +--------- |
| 17 | +Install via the package manager and load with `using` |
| 18 | + |
| 19 | +```julia |
| 20 | +julia> Pkg.add("Wavelets") |
| 21 | +julia> using Wavelets |
| 22 | +``` |
| 23 | + |
| 24 | +Basic usage example on a doppler test function. |
| 25 | +```julia |
| 26 | +using ContinuousWavelets, Plots, Wavelets |
| 27 | +n=2047; |
| 28 | +t = range(0,n/1000,length=n); # 1kHz sampling rate |
| 29 | +f = testfunction(n, "Doppler"); |
| 30 | +p1=plot(t, f,legend=false,title="Doppler",xticks=false) |
| 31 | +c = wavelet(Morlet(π), β=2); |
| 32 | +res = cwt(f, c) |
| 33 | +# plotting |
| 34 | +freqs = getMeanFreq(computeWavelets(n, c)[1]) |
| 35 | +freqs[1] = 0 |
| 36 | +p2=heatmap(t,freqs, abs.(res)', xlabel= "time (s)", ylabel="frequency (Hz)",colorbar=false) |
| 37 | +l=@layout [a{.3h};b{.7h}] |
| 38 | +plot(p1,p2,layout=l) |
| 39 | +``` |
| 40 | + |
| 41 | + |
| 42 | +As the cwt frame is redundant, there are many choices of dual/inverse frames. There are three available in this package, `NaiveDual()`, `PenroseDual()`, and `DualFrame()`. As a toy example: |
| 43 | + |
| 44 | +``` julia |
| 45 | +f = testfunction(n, "Bumps"); |
| 46 | +p1=plot(f,legend=false,title="Bumps",xlims=(0,2000)) |
| 47 | +c = wavelet(dog2, β=2); |
| 48 | +res = cwt(f, c) |
| 49 | +# dropping the middle peaks |
| 50 | +res[620:1100,:] .=0 |
| 51 | +# and smoothing the remaining peaks |
| 52 | +res[:,10:29] .= 0 |
| 53 | +# actually doing the inversion |
| 54 | +dropped = ContinuousWavelets.icwt(res,c,DualFrames()) |
| 55 | + |
| 56 | +p1 = plot([dropped f],legend=false, title="Smoothing and dropping bumps") |
| 57 | +p2=heatmap(abs.(res)', xlabel= "time index", ylabel="frequency index",colorbar=false) |
| 58 | +l=@layout [a{.3h};b{.7h}] |
| 59 | +plot(p1,p2,layout=l) |
| 60 | +``` |
| 61 | + |
| 62 | + |
| 63 | +It can also handle collections of examples at the same time, should you need to do a batch of transforms: |
| 64 | +``` julia |
| 65 | +exs = cat(testfunction(n, "Doppler"),testfunction(n,"Blocks"),testfunction(n,"Bumps"),testfunction(n,"HeaviSine"),dims=2) |
| 66 | +c = wavelet(cDb2, β=2,extraOctaves=-0); |
| 67 | +res = cwt(exs, c) |
| 68 | +``` |
| 69 | + |
| 70 | +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. |
| 71 | +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. |
| 72 | + |
| 73 | +Perhaps somewhat unusually, the averaging function, or father wavelet, is included as an option (the bottom row for the figure above). This can be either the paired averaging function or uniform in frequency (the `Dirac` averaging). The frequency coverage of the wavelets can be adjusted both in total frequency range both below by the `averagingLength` or above by the `extraOctaves` (caveat emptor with how well they will be defined in that case). The frequency density can be adjusted both in terms of the quality/scale factor `Q`, as well as how quickly this density falls off as the frequency goes to zero via `β`. Finally, depending on what kind of norm you want to preserve, `p` determines the norm preserved in the frequency domain (so `p=1` maintains the 1-norm in frequency, while `p=Inf` maintains the 1-norm in time). |
| 74 | + |
| 75 | +Possible extensions |
| 76 | +------------ |
| 77 | +- Higher dimensional wavelets have yet to be implemented. |
| 78 | +- A DCT implementation of the symmetric boundary to halve the space and computational costs. |
| 79 | +- Various additional wavelet families, such as Morse wavelets. |
0 commit comments