Skip to content

Commit

Permalink
fix surface gather
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jan 16, 2024
1 parent d0f4bf6 commit e5b0341
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "ImageGather"
uuid = "355d8124-6b2e-49b5-aab5-cdbc0a5fccbe"
authors = ["mloubout <mathias.louboutin@gmail.com>"]
version = "0.2.6"
version = "0.2.7"

This comment has been minimized.

Copy link
@mloubout

mloubout Jan 16, 2024

Author Member

[deps]
JUDI = "f3b833dc-6b2e-5b9c-b940-873ed6319979"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
JUDI = "3.3.1"
JUDI = "3.3.9"
julia = "1"

[extras]
Expand Down
Binary file modified docs/img/cig_cdp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/cig_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/layers_cig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ for i=1:12
v[:,25*i+1:end] .= 1.5f0 + i*.25f0
end
v0 = imfilter(v, Kernel.gaussian(5))
v0_low = .95f0 .* imfilter(v, Kernel.gaussian(45))
v0_high = 1.05f0 .* imfilter(v, Kernel.gaussian(45))
v0_low = .95f0 .* imfilter(v, Kernel.gaussian(5))
v0_high = 1.05f0 .* imfilter(v, Kernel.gaussian(5))

# Slowness squared [s^2/km^2]
m = (1f0 ./ v).^2
Expand Down
2 changes: 1 addition & 1 deletion src/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cig_grad(model, src_coords, wavelet, rec_coords, res, offsets, ic="as", spac
hs = tuple(h.shape[0] for h in ohs.values())
hd = tuple(h.indices[0] for h in ohs.values())
gradm = Function(name="gradm", grid=model.grid, shape=(*hs, *u.shape[1:]),
dimensions=(*hd, *model.grid.dimensions))
dimensions=(*hd, *model.grid.dimensions))

uh, vh = shifted_wf(u, v, ohs)
g_expr = grad_expr(gradm, uh, vh, model, ic=ic)
Expand Down
20 changes: 11 additions & 9 deletions src/surface_gather.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JUDI: AbstractModel
import JUDI: AbstractModel, rlock_pycall, devito

export surface_gather, double_rtm_cig

Expand Down Expand Up @@ -42,6 +42,8 @@ Compute the single shot contribution to the surface offset gather via double rtm
"""
function double_rtm_cig(model_full, q::judiVector, data::judiVector, offs, options)
GC.gc(true)
devito.clear_cache()
# Load full geometry for out-of-core geometry containers
data.geometry = Geometry(data.geometry)
q.geometry = Geometry(q.geometry)
Expand All @@ -56,11 +58,11 @@ function double_rtm_cig(model_full, q::judiVector, data::judiVector, offs, optio

# Set up Python model
modelPy = devito_model(model, options)
dtComp = get_dt(model; dt=options.dt_comp)
dtComp = convert(Float32, modelPy."critical_dt")

# Extrapolate input data to computational grid
qIn = time_resample(make_input(q), q.geometry, dtComp)[1]
res = time_resample(make_input(data), data.geometry, dtComp)[1]
qIn = time_resample(make_input(q), q.geometry, dtComp)
res = time_resample(make_input(data), data.geometry, dtComp)

# Set up coordinates
src_coords = setup_grid(q.geometry, model.n) # shifts source coordinates by origin
Expand All @@ -75,10 +77,10 @@ function double_rtm_cig(model_full, q::judiVector, data::judiVector, offs, optio
res_o = res .* off_r'
# Double rtm

rtm, rtmo, illum = JUDI.pylock() do
pycall(impl."double_rtm", Tuple{PyArray, PyArray, PyArray},
modelPy, qIn, src_coords, res, res_o, rec_coords, space_order=options.space_order)
end
rtm, rtmo, illum = rlock_pycall(impl."double_rtm", Tuple{PyArray, PyArray, PyArray},
modelPy, qIn, src_coords, res, res_o, rec_coords,
space_order=options.space_order)

rtm = remove_padding(rtm, modelPy.padsizes)
rtmo = remove_padding(rtmo, modelPy.padsizes)
illum = remove_padding(illum, modelPy.padsizes)
Expand All @@ -94,6 +96,6 @@ function double_rtm_cig(model_full, q::judiVector, data::judiVector, offs, optio
for (i, h) in enumerate(offs)
soffs[:, :, i] .+= rtm .* delta_h(h_map, h, 2*diff(offs)[1])
end
GC.gc()

return soffs
end

1 comment on commit e5b0341

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/98980

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.7 -m "<description of version>" e5b03410b081769b96d1f817920bee9ecdc8ff49
git push origin v0.2.7

Please sign in to comment.