diff --git a/README.md b/README.md index 34c8f4a..39f6c48 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/images/beam_energy_map.png b/images/beam_energy_map.png index e294515..675f41b 100644 Binary files a/images/beam_energy_map.png and b/images/beam_energy_map.png differ diff --git a/images/transmit_time_map.png b/images/transmit_time_map.png index c64fc59..5706983 100644 Binary files a/images/transmit_time_map.png and b/images/transmit_time_map.png differ diff --git a/images/wave_propagation.gif b/images/wave_propagation.gif index f533cc4..0fe4a17 100644 Binary files a/images/wave_propagation.gif and b/images/wave_propagation.gif differ diff --git a/src/WaveSim.jl b/src/WaveSim.jl index e65ae08..70aaa76 100644 --- a/src/WaveSim.jl +++ b/src/WaveSim.jl @@ -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 diff --git a/src/main.jl b/src/main.jl index 9e72624..8cfa47f 100644 --- a/src/main.jl +++ b/src/main.jl @@ -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") diff --git a/src/save.jl b/src/save.jl index 11a714e..1569a78 100644 --- a/src/save.jl +++ b/src/save.jl @@ -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 @@ -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 @@ -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 diff --git a/src/view.jl b/src/view.jl index 99fe30a..b67d169 100644 --- a/src/view.jl +++ b/src/view.jl @@ -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