Skip to content

Commit

Permalink
Merge pull request #24 from firasalchalabi/add-makeAnimation
Browse files Browse the repository at this point in the history
Add makeAnimation + check colorrange limits
  • Loading branch information
AtilaSaraiva authored May 31, 2024
2 parents 9694487 + 91de797 commit 93a1748
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/Recipes/SeisImageRecipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function Makie.plot!(img::SeisImagePlot{<:Tuple{AbstractMatrix{<:Real}}})
function update_plot(d, ox, oy, dx, dy, pclip, vmin, vmax)
transposed_d[] = d'


x[] = (ox, ox + size(d,2)*dx)
y[] = (oy, oy + size(d,1)*dy)

Expand All @@ -84,23 +85,10 @@ function Makie.plot!(img::SeisImagePlot{<:Tuple{AbstractMatrix{<:Real}}})

update_plot(img.d[], img.ox[], img.oy[], img.dx[], img.dy[], img.pclip[], img.vmin[], img.vmax[])


# if (isnothing(img.vmin[]) || isnothing(img.vmax[]))
# if (img.pclip[]<=100)
# a = -quantile(abs.(img.d[][:]), (img.pclip[]/100))
# else
# a = -quantile(abs.(img.d[][:]), 1)*img.pclip[]/100
# end
# b = -a
# else
# a = img.vmin[]
# b = img.vmax[]
# end

# x = (img.ox[], img.ox[]+size(img.d[],2)*img.dx[])
# y = (img.oy[], img.oy[]+size(img.d[],1)*img.dy[])

image!(img, x, y, transposed_d, colorrange=colorrange, colormap=img.cmap)

if (colorrange[][1] != colorrange[][2])
image!(img, x, y, transposed_d, colorrange=colorrange, colormap=img.cmap)
else
image!(img, x, y, transposed_d, colormap=img.cmap)
end
img
end
4 changes: 4 additions & 0 deletions src/SeisMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module SeisMakie
include("seisPlotTX.jl")
include("seisPlotAmplitude.jl")

include("makeAnimation.jl")

include("Util.jl")

export seisamplitudeplot
Expand All @@ -34,4 +36,6 @@ module SeisMakie
export seisPlotFK
export seisPlotAmplitude

export makeAnimation

end
29 changes: 29 additions & 0 deletions src/makeAnimation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function makeAnimation(
filename::String,
A::AbstractArray{<:Real};
pclip = 98,
ox = 0,
dx = 1,
oy = 0,
dy = 1,
framerate::Integer=30
)

# Creating an observable that triggers a change in the figure after a change in its value
obs = Observable(A[:, :, 1])

iterations = 1:size(A,3)

fig = Figure()
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)

record(fig, filename, iterations; framerate=30) do it
# modifying the Observable variable to change the plot
obs[] = A[:, :, it]
end

return nothing
end

0 comments on commit 93a1748

Please sign in to comment.