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 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 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