Skip to content

Commit

Permalink
Initial Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
firasalchalabi committed Jan 23, 2024
1 parent df65010 commit 9d6245d
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ uuid = "1618359f-28d0-421c-9c3d-0705aaf8cc0d"
authors = ["Firas <firas_alchalabi@hotmail.com> and contributors"]
version = "1.0.0-DEV"

[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"

[compat]
julia = "1"

Expand Down
24 changes: 24 additions & 0 deletions src/ImageRecipe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@recipe(SeisImage, d) do scene
Attributes(
dx = 1,
dy = 1,
pclip = 98,
)
end

function Makie.plot!(img::SeisImage{<:Tuple{AbstractMatrix{<:Real}}})
d = img.d

x = (1, 100)
y = (1, 500)

function update_plot(d)

end

Makie.Observables.onany(update_plot, d)

image!(x, y, d[]')

img
end
8 changes: 7 additions & 1 deletion src/SeisMakie.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module SeisMakie

# Write your package code here.
# Write your package code here.
using Makie

include("WiggleRecipe.jl")
include("ImageRecipe.jl")

export wiggleplot

end
81 changes: 81 additions & 0 deletions src/WiggleRecipe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# @recipe(Wiggle) do scene
# Attributes(
# # vertical = false,
# )
# end
"""
wiggle(gx, d, dt)
wiggle!(ax, gx, d, dt)
Plots wiggle traces of seismic data.
# Arguments:
- `gx::Vector{<:Real}`: the positions of the seismometers(?) corresponding to the traces in d
- `d::Matrix{<:AbstractFloat}`: the measured seismic traces. Number of columns corresponds to number
of traces whereas number of rows corresponds to the number of times
amplitude was measured for each trace
- `dt`::AbstractFloat: the amount of time between each measurement of amplitude
"""
@recipe(Wiggle, d) do scene
Attributes(
color = :black,
linewidth = 0.7,

gx = "NULL",
ox = 0,
dx = 1,

ot = 0,
dt = 1,
)
end

function Makie.plot!(wp::Wiggle{<:Tuple{AbstractMatrix{<:Real}}})

d = wp.d
gx = wp.gx
ox = wp.ox[]
dx = wp.dx[]

ot = wp.ot[]
dt = wp.dt[]


if gx[] == "NULL"
gx[] = [ox+(i-1)*dx for i in range(start=1, stop=size(d[], 2))]
end

traces = Observable(Vector{Point2f}[])
positive_traces = Observable(Vector{Point2f}[])
zero_lines = Observable(Vector{Point2f}[])
## Add colour functionality

function update_plot(d, gx)
empty!(traces[])
empty!(positive_traces[])
empty!(zero_lines[])

dgx = minimum([gx[i]-gx[i-1] for i in 2:length(gx)])
max_perturb = maximum(abs, d)
times = ot:dt:(dt*(size(d, 1)-1)+ot)
z = zeros(length(size(d, 1)))
for i = 1:length(gx)
trace = Point2.(gx[i] .+ (dgx/max_perturb .* d[:, i]), times)
pos_trace = Point2.(gx[i] .+ max.(dgx/max_perturb .* d[:, i], 0), times)
zero_line = Point2.(gx[i] .+ z, times)
push!(traces[], trace)
push!(positive_traces[], pos_trace)
push!(zero_lines[], zero_line)
end
end

Makie.Observables.onany(update_plot, d, gx)

update_plot(d[], gx[])

for i = 1:length(gx[])
band!(wp, zero_lines[][i], positive_traces[][i], color=wp.color)
lines!(wp, traces[][i], color=wp.color, linewidth=wp.linewidth)
end
wp
end
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using SeisMakie
using Test
using SeisProcessing

@testset "SeisMakie.jl" begin
# Write your tests here.
# Write your tests here
end

0 comments on commit 9d6245d

Please sign in to comment.