Skip to content

Commit

Permalink
doc(pm): added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mchitre committed Jan 11, 2025
1 parent a6cd615 commit 7cb991e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pm_pekeris.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ function acoustic_field(pm::PekerisModeSolver, tx::AbstractAcousticSource, rxs::
end
end

function impulse_response(pm::PekerisModeSolver, tx::AbstractAcousticSource, rx::AbstractAcousticReceiver, fs; abstime=false)
# impulse response computation is designed for Pekeris mode solver, but should
# work for any mode solver that returns ModeArrival, and hence is marked as
# a fallback for any AbstractModePropagationModel
function impulse_response(pm::AbstractModePropagationModel, tx::AbstractAcousticSource, rx::AbstractAcousticReceiver, fs; abstime=false)
arr = arrivals(pm, tx, rx)
isempty(arr) && return signal(ComplexF64[], fs)
p1 = location(tx)
Expand All @@ -271,15 +274,15 @@ function impulse_response(pm::PekerisModeSolver, tx::AbstractAcousticSource, rx:
N = ceil(Int, R / minimum(a -> a.v, arr) * fs)
M = ceil(Int, R / maximum(a -> a.v, arr) * fs)
N -= M
N = nextfastfft(2N)
N = nextfastfft(2N) # heuristic to ensure no aliasing
Δf = fs / N
X = map(0:N-1) do i
i == 0 && return complex(0.0)
tx1 = AcousticSource(location(tx), i * Δf)
acoustic_field(pm, tx1, rx) |> conj
end
x = ifft(X)
x = circshift(x, -mod(M, N) + N ÷ 100)
x = circshift(x, -mod(M, N) + N ÷ 100) # heuristic to position first arrival
if abstime
absx = abs.(x)
i = findfirst(>(maximum(absx) / 10), absx)
Expand Down

0 comments on commit 7cb991e

Please sign in to comment.