Skip to content

Commit

Permalink
Merge pull request #25 from firasalchalabi/add-makeAnimation
Browse files Browse the repository at this point in the history
Modify makeAnimation() to calculate vmin and vmax value globally for the cube
  • Loading branch information
AtilaSaraiva authored Jun 4, 2024
2 parents eba9b4c + c599176 commit f1ffddf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/Recipes/SeisImageRecipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/Util.jl
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions src/makeAnimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -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
Expand Down

0 comments on commit f1ffddf

Please sign in to comment.