From 5f33a6d0848027c4d698ab39db6e0292065dbbd7 Mon Sep 17 00:00:00 2001 From: JaredW40 Date: Tue, 13 Jan 2026 14:07:06 -0800 Subject: [PATCH 1/5] Refactor example to simplify imports and usage Removed unused import of ScatteringPlots and updated example code to use plotSecondLayer directly. --- docs/src/index.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/src/index.md b/docs/src/index.md index bc462b7..c98f0bd 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -15,7 +15,7 @@ For a comparable package in python, see [Kymatio](https://www.kymat.io/). ## Basic Example ```@setup -using ScatteringTransform, ScatteringPlots, Wavelets, Plots +using ScatteringTransform, Wavelets, Plots ``` As an example signal, lets work with the doppler signal: @@ -91,21 +91,12 @@ gif(anim, "sliceBySecond.gif", fps=1) ``` For any fixed second layer frequency, we get approximately the curve in the first layer scalogram, with different portions emphasized, and the overall mass decreasing as the frequency increases, corresponding to the decreasing amplitude of the envelope for the doppler signal. -These plots can also be created using +These plots can also be created using various plotting utilities defined in this package. -From the companion package ScatteringPlots.jl, we have the denser representation: +For eaxample, we have generate a denser representation with the `plotSecondLayer` function: ```@example ex -using ScatteringPlots, LinearAlgebra - -# --- HOTFIX: Monkey-patch ScatteringPlots --- -# The package ScatteringPlots uses 'norm' but didn't declare LinearAlgebra as a dependency. -# We manually define 'norm' inside the ScatteringPlots module pointing to the real one. -Core.eval(ScatteringPlots, :(norm = $(LinearAlgebra.norm))) - -# -------------------------------------------- -# Fix: Explicitly use the function from ScatteringPlots to avoid ambiguity -ScatteringPlots.plotSecondLayer(sf, St) +plotSecondLayer(sf, St) savefig("second.png") #hide ``` From 5676a182fad5486e2281ed7457f6be29bdc9b0b2 Mon Sep 17 00:00:00 2001 From: JaredW40 Date: Tue, 13 Jan 2026 14:08:22 -0800 Subject: [PATCH 2/5] Fix gif frame count and parameterize fps --- src/scatteringplots.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scatteringplots.jl b/src/scatteringplots.jl index 545a588..aa064cc 100644 --- a/src/scatteringplots.jl +++ b/src/scatteringplots.jl @@ -20,11 +20,11 @@ end """ function gifFirstLayer(origLoc, firstSig, saveTo="gradientFigures/tmp.gif", fps=2) anim = Animation() - for j = 1:size(origLoc[1])[end] + for j = 1:size(origLoc[1])[end-1] plotFirstLayer1D(j, origLoc, firstSig) frame(anim) end - gif(anim, saveTo, fps=2) + gif(anim, saveTo, fps=fps) end meanWave(wave) = sum(real.(range(0, stop=1, length=size(wave, 1)) .* wave), dims=1) ./ sum(real.(wave), dims=1) From 42089ce6d247bb31dc73af3dc09c2c64a557d01b Mon Sep 17 00:00:00 2001 From: JaredW40 Date: Tue, 13 Jan 2026 14:21:58 -0800 Subject: [PATCH 3/5] Fix indexing in plotFirstLayer1D function --- src/scatteringplots.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scatteringplots.jl b/src/scatteringplots.jl index aa064cc..7e00386 100644 --- a/src/scatteringplots.jl +++ b/src/scatteringplots.jl @@ -3,13 +3,13 @@ """ function plotFirstLayer1D(j, origLoc, original, cline=:darkrainbow) - space = plot(origLoc[1][:, :, j], line_z=(1:size(origLoc[1], 2))', + space = plot(origLoc[1][:, j, :], line_z=(1:size(origLoc[1], 2))', legend=false, colorbar=true, color=cline, title="first layer gradient wavelet $j varying location") org = plot([original original], line_z=([-20; 1:size(origLoc[1], 2)...])', legend=false, colorbar=true, color=cline) # todo: including the colorbar here is a real hack to get them to line up - ∇h = heatmap(origLoc[1][:, 1:end, j]', xlabel="space", + ∇h = heatmap(origLoc[1][:, j, :]', xlabel="space", ylabel="wavelet location", title="First layer gradient j=$j") - ∇̂h = heatmap(log.(abs.(rfft(origLoc[1][:, 1:end, j], 1)) .^ 2)', xlabel="frequency", + ∇̂h = heatmap(log.(abs.(rfft(origLoc[1][:, j, :], 1)) .^ 2)', xlabel="frequency", ylabel="wavelet location", title="Log Power Frequency domain j=$j") l = Plots.@layout [a; b{0.1h}; [b c]] plot(space, org, ∇h, ∇̂h, layout=l) From a01c783cc36fa14968149695f141675a1287f79c Mon Sep 17 00:00:00 2001 From: JaredW40 Date: Tue, 13 Jan 2026 15:04:31 -0800 Subject: [PATCH 4/5] Fix indexing in plotFirstLayer1D and gifFirstLayer --- src/scatteringplots.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scatteringplots.jl b/src/scatteringplots.jl index 7e00386..3650448 100644 --- a/src/scatteringplots.jl +++ b/src/scatteringplots.jl @@ -3,13 +3,13 @@ """ function plotFirstLayer1D(j, origLoc, original, cline=:darkrainbow) - space = plot(origLoc[1][:, j, :], line_z=(1:size(origLoc[1], 2))', + space = plot(origLoc[1][:, :, j], line_z=(1:size(origLoc[1], 2))', legend=false, colorbar=true, color=cline, title="first layer gradient wavelet $j varying location") org = plot([original original], line_z=([-20; 1:size(origLoc[1], 2)...])', legend=false, colorbar=true, color=cline) # todo: including the colorbar here is a real hack to get them to line up - ∇h = heatmap(origLoc[1][:, j, :]', xlabel="space", + ∇h = heatmap(origLoc[1][:, 1:end, j]', xlabel="space", ylabel="wavelet location", title="First layer gradient j=$j") - ∇̂h = heatmap(log.(abs.(rfft(origLoc[1][:, j, :], 1)) .^ 2)', xlabel="frequency", + ∇̂h = heatmap(log.(abs.(rfft(origLoc[1][:, 1:end, j], 1)) .^ 2)', xlabel="frequency", ylabel="wavelet location", title="Log Power Frequency domain j=$j") l = Plots.@layout [a; b{0.1h}; [b c]] plot(space, org, ∇h, ∇̂h, layout=l) @@ -20,7 +20,7 @@ end """ function gifFirstLayer(origLoc, firstSig, saveTo="gradientFigures/tmp.gif", fps=2) anim = Animation() - for j = 1:size(origLoc[1])[end-1] + for j = 1:size(origLoc[1])[end] plotFirstLayer1D(j, origLoc, firstSig) frame(anim) end From d1ca220b0d5613bb348330b2a2544fcfc70873fb Mon Sep 17 00:00:00 2001 From: JaredW40 Date: Tue, 13 Jan 2026 15:07:17 -0800 Subject: [PATCH 5/5] Update index.md --- docs/src/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/index.md b/docs/src/index.md index c98f0bd..37f33a4 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -93,7 +93,7 @@ gif(anim, "sliceBySecond.gif", fps=1) For any fixed second layer frequency, we get approximately the curve in the first layer scalogram, with different portions emphasized, and the overall mass decreasing as the frequency increases, corresponding to the decreasing amplitude of the envelope for the doppler signal. These plots can also be created using various plotting utilities defined in this package. -For eaxample, we have generate a denser representation with the `plotSecondLayer` function: +For example, we can generate a denser representation with the `plotSecondLayer` function: ```@example ex plotSecondLayer(sf, St)