Skip to content

Commit

Permalink
fix q padding with non zero t0
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Mar 20, 2024
1 parent 000d669 commit b2fda78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/TimeModeling/Modeling/python_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function wrapcall_data(func, args...;kw...)
# Unlike standard array we want to keep this ordering in julia (time first) so we need to
# make a wrapper around the pointer, to flip the dimension the re-permute the dimensions.
shot = tup ? out[1] : out
shot = PermutedDimsArray(unsafe_wrap(Array, shot.data, reverse(size(shot))), length(size(shot)):-1:1)
shot = permutedims(unsafe_wrap(Array, shot.data, reverse(size(shot))), length(size(shot)):-1:1)
# Check what to return
out = tup ? (shot, out[2]) : shot
return out
Expand Down Expand Up @@ -56,6 +56,7 @@ function devito_interface(modelPy::PyObject, srcGeometry::Geometry, srcData::Arr
# Interpolate input data to computational grid
dtComp = convert(Float32, modelPy."critical_dt")
qIn = time_resample(srcData, srcGeometry, dtComp)
qIn = _maybe_pad_t0(qIn, srcGeometry, recGeometry)

# Set up coordinates with devito dimensions
src_coords = setup_grid(srcGeometry, modelPy.shape)
Expand Down Expand Up @@ -109,6 +110,7 @@ function devito_interface(modelPy::PyObject, srcGeometry::Geometry, srcData::Arr
# Interpolate input data to computational grid
dtComp = convert(Float32, modelPy."critical_dt")
qIn = time_resample(srcData, srcGeometry, dtComp)
qIn = _maybe_pad_t0(qIn, srcGeometry, recGeometry)

# Set up coordinates with devito dimensions
#origin = get_origin(modelPy)
Expand Down Expand Up @@ -167,6 +169,7 @@ function devito_interface(modelPy::PyObject, recGeometry::Geometry, recData::Arr
dtComp = convert(Float32, modelPy."critical_dt")
dIn = time_resample(recData, recGeometry, dtComp)
qIn = time_resample(srcData, recGeometry, dtComp)
qIn, dIn = _maybe_pad_t0(qIn, recGeometry, dIn, recGeometry)

# Set up coordinates with devito dimensions
rec_coords = setup_grid(recGeometry, modelPy.shape)
Expand Down
3 changes: 3 additions & 0 deletions src/TimeModeling/Utils/time_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ end

_maybe_pad_t0(qIn::judiVector{T, AT}, dObserved::judiVector{T, AT}) where{T<:Number, AT} =
_maybe_pad_t0(get_data(qIn), get_data(dObserved))

_maybe_pad_t0(qIn::Matrix{T}, qGeom::Geometry, dataGeom::Geometry) where T<:Number =
_maybe_pad_t0(qIn, qGeom, zeros(T, dataGeom.nt[1], 1), dataGeom)[1]
2 changes: 1 addition & 1 deletion src/pysource/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def inner_grad(u, v):
v: TimeFunction
Second field
"""
return (grad(u, shift=.5).transpose(inner=False) * grad(v, shift=.5))[0]
return grad(u, shift=.5).dot(grad(v, shift=.5))


fwi_src = lambda *ar, **kw: isic_src(*ar, icsign=-1, **kw)
Expand Down

0 comments on commit b2fda78

Please sign in to comment.