Skip to content

Commit

Permalink
Make peak_to_peak_time_delta_map
Browse files Browse the repository at this point in the history
  • Loading branch information
cmey committed Sep 7, 2024
1 parent 16e8019 commit 4737f85
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ sim_params = WaveSim.autores(sim_params, trans_delays)
# Run the simulation.
images = WaveSim.wavesim(trans_delays, sim_params);
beam_energy_map, transmit_time_map = WaveSim.beam_energy_map_and_transmit_time_map(images, sim_params);
beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map = WaveSim.beam_energy_map_and_transmit_time_map(images, sim_params);
# Display results.
include("src/view.jl")
imshowall(images, beam_energy_map, transmit_time_map, sim_params);
imshowall(images, beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, sim_params);
# Save results.
include("src/save.jl")
saveall(images, beam_energy_map, transmit_time_map, sim_params, "images")
saveall(images, beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, sim_params, "images")
```

Visualize the wave propagating through space, over time:
Expand Down
Binary file modified images/beam_energy_map.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 images/transmit_time_map.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 images/wave_propagation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 13 additions & 6 deletions src/WaveSim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,25 @@ end
function beam_energy_map_and_transmit_time_map(images, sim_params)
@unpack temporal_res = sim_params

maxval, linindices = findmax(images, dims=3)
maxval, maxlinindices = findmax(images, dims=3)
minval, minlinindices = findmin(images, dims=3)

beam_energy_map = dropdims(maxval, dims=3)
beam_energy_map = dropdims(maxval .- minval, dims=3) # peak to peak amplitude

transmit_time_map = similar(beam_energy_map)

for linind in eachindex(linindices)
x, y, t = Tuple(CartesianIndices(images)[linindices[linind]])
for linind in eachindex(maxlinindices)
x, y, t = Tuple(CartesianIndices(images)[maxlinindices[linind]])
transmit_time_map[linind] = t * temporal_res
end

return beam_energy_map, transmit_time_map
peak_to_peak_time_delta_map = similar(beam_energy_map)
for linind in eachindex(maxlinindices)
x, y, tmax = Tuple(CartesianIndices(images)[maxlinindices[linind]])
x, y, tmin = Tuple(CartesianIndices(images)[minlinindices[linind]])
peak_to_peak_time_delta_map[linind] = (tmax - tmin) * temporal_res
end

return beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map
end


Expand Down
14 changes: 7 additions & 7 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ function main()

# Run the simulation.
images = WaveSim.wavesim(trans_delays, sim_params)
beam_energy_map, transmit_time_map = WaveSim.beam_energy_map_and_transmit_time_map(images, sim_params)
beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map = WaveSim.beam_energy_map_and_transmit_time_map(images, sim_params)

return beam_energy_map, transmit_time_map, images, sim_params
return beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, images, sim_params
end

beam_energy_map, transmit_time_map, images, sim_params = main()
beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, images, sim_params = main()

# Display results.
include("view.jl")
imshowall(images, beam_energy_map, transmit_time_map, sim_params)
include("src/view.jl")
imshowall(images, beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, sim_params)

# Save results.
include("save.jl")
saveall(images, beam_energy_map, transmit_time_map, sim_params, "images")
include("src/save.jl")
saveall(images, beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, sim_params, "images")
15 changes: 14 additions & 1 deletion src/save.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ include("bilog.jl")
const wave_propagation_filename = "wave_propagation.gif"
const beam_energy_map_filename = "beam_energy_map.png"
const transmit_time_map_filename = "transmit_time_map.png"
const peak_to_peak_time_delta_map_filename = "peak_to_peak_time_delta_map.png"

function saveall(images, beam_energy_map, transmit_time_map, sim_params, output_path="images")
function saveall(images, beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, sim_params, output_path="images")
mkpath(output_path)

@unpack fov, dbrange, orientation = sim_params
Expand All @@ -24,6 +25,7 @@ function saveall(images, beam_energy_map, transmit_time_map, sim_params, output_
images = mapslices(rotr90, images; dims=[1, 2])
beam_energy_map = rotr90(beam_energy_map)
transmit_time_map = rotr90(transmit_time_map)
peak_to_peak_time_delta_map = rotr90(peak_to_peak_time_delta_map)
end

# Wave propagation movie
Expand Down Expand Up @@ -67,5 +69,16 @@ function saveall(images, beam_energy_map, transmit_time_map, sim_params, output_
resize_to_layout!(fig)
save(joinpath(output_path, transmit_time_map_filename), fig)

# Peak-to-peak time-delta map
peak_to_peak_time_delta_map = peak_to_peak_time_delta_map';
fig = Figure()
ax = Axis(fig[1, 1], width=size(peak_to_peak_time_delta_map)[1], height=size(peak_to_peak_time_delta_map)[2], xlabel=xlabel, ylabel=ylabel, title="Peak-to-peak time-delta map [µs]")
centers_x = range(extent[1], extent[2], length=size(peak_to_peak_time_delta_map)[1])
centers_y = range(extent[3], extent[4], length=size(peak_to_peak_time_delta_map)[2])
hm = heatmap!(ax, centers_x, centers_y, peak_to_peak_time_delta_map .* 1e6)
Colorbar(fig[:, end+1], hm)
resize_to_layout!(fig)
save(joinpath(output_path, peak_to_peak_time_delta_map_filename), fig)

return # nothing
end
4 changes: 3 additions & 1 deletion src/view.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ include("colorize_field.jl")
using ImageView
using Parameters

function imshowall(images, beam_energy_map, transmit_time_map, sim_params)
function imshowall(images, beam_energy_map, transmit_time_map, peak_to_peak_time_delta_map, sim_params)
@unpack dbrange, orientation = sim_params

if orientation == :vertical
images = mapslices(rotr90, images; dims=[1, 2])
beam_energy_map = rotr90(beam_energy_map)
transmit_time_map = rotr90(transmit_time_map)
peak_to_peak_time_delta_map = rotr90(peak_to_peak_time_delta_map)
end

ImageView.imshow(colorize_field(bilog(images, dbrange)))
ImageView.imshow(bilog(beam_energy_map, dbrange))
ImageView.imshow(transmit_time_map)
ImageView.imshow(peak_to_peak_time_delta_map)

return # nothing
end

0 comments on commit 4737f85

Please sign in to comment.