From 4f26ae86849be5e6a54dc02d1316f4d7f0514d69 Mon Sep 17 00:00:00 2001 From: Firas Date: Tue, 4 Jun 2024 14:16:49 -0600 Subject: [PATCH 1/3] Added a function to calculate vmin, vmax values based on pclip --- src/Util.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Util.jl b/src/Util.jl index 14ad5ba..0a2b839 100644 --- a/src/Util.jl +++ b/src/Util.jl @@ -1,4 +1,16 @@ # Creates an Axis object to be used by SeisColor, SeisOverlay, SeisWiggle. function __create_axis(fig) return Axis(fig, yreversed=true, xautolimitmargin=(0,0), yautolimitmargin=(0,0)) +end + +# Calculates the endpoints for pclip +function __calculate_pclip(A::AbstractArray{<:Real}; pclip=98) + if (pclip<=100) + a = -quantile(abs.(A[:]), (pclip/100)) + else + a = -quantile(abs.(A[:]), 1)*pclip/100 + end + b = -a + + return a, b end \ No newline at end of file From f53c097b5080cdf8076c586226b20e1536ca95ac Mon Sep 17 00:00:00 2001 From: Firas Date: Tue, 4 Jun 2024 14:17:23 -0600 Subject: [PATCH 2/3] Calculate vmin and vmax globally for the cube in makeAnimation --- src/makeAnimation.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/makeAnimation.jl b/src/makeAnimation.jl index 0b396c7..302727f 100644 --- a/src/makeAnimation.jl +++ b/src/makeAnimation.jl @@ -9,6 +9,8 @@ function makeAnimation( framerate::Integer=30 ) + a, b = __calculate_pclip(A, pclip=pclip) + # Creating an observable that triggers a change in the figure after a change in its value obs = Observable(A[:, :, 1]) @@ -18,9 +20,9 @@ function makeAnimation( ax = Axis(fig[1,1], yreversed=true, xautolimitmargin=(0,0), yautolimitmargin=(0,0)) # Creating a plot based on observable obs. If obs[] changes the plot automatically changes - seisimageplot!(ax, obs, pclip=pclip, ox=ox, dx=dx, oy=0, dy=1) + seisimageplot!(ax, obs, pclip=pclip, ox=ox, dx=dx, oy=oy, dy=dy, vmin=a, vmax=b) - record(fig, filename, iterations; framerate=30) do it + record(fig, filename, iterations; framerate=framerate) do it # modifying the Observable variable to change the plot obs[] = A[:, :, it] end From c5991764af9fb30f61db9c7713e38ff5e53399c2 Mon Sep 17 00:00:00 2001 From: Firas Date: Tue, 4 Jun 2024 14:18:12 -0600 Subject: [PATCH 3/3] Using the helper function to calculate vmin,vmax instead of calculating directly --- src/Recipes/SeisImageRecipe.jl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Recipes/SeisImageRecipe.jl b/src/Recipes/SeisImageRecipe.jl index e83d9ed..591f5b5 100644 --- a/src/Recipes/SeisImageRecipe.jl +++ b/src/Recipes/SeisImageRecipe.jl @@ -66,12 +66,7 @@ function Makie.plot!(img::SeisImagePlot{<:Tuple{AbstractMatrix{<:Real}}}) y[] = (oy, oy + size(d,1)*dy) if (isnothing(vmin) || isnothing(vmax)) - if (img.pclip[]<=100) - a = -quantile(abs.(d[:]), (pclip/100)) - else - a = -quantile(abs.(d[:]), 1)*pclip/100 - end - b = -a + a, b = __calculate_pclip(d, pclip=pclip) else a = vmin b = vmax