diff --git a/examples/at_circular_piston_3D/at_circular_piston_3D.py b/examples/at_circular_piston_3D/at_circular_piston_3D.py index 3945979a..c48c833c 100644 --- a/examples/at_circular_piston_3D/at_circular_piston_3D.py +++ b/examples/at_circular_piston_3D/at_circular_piston_3D.py @@ -18,7 +18,6 @@ from kwave.options.simulation_execution_options import SimulationExecutionOptions from kwave.options.simulation_options import SimulationOptions - # material values c0: float = 1500.0 # sound speed [m/s] rho0: float = 1000.0 # density [kg/m^3] @@ -209,10 +208,10 @@ # plot the source mask (pml is outside the grid in this example) fig2, ax2 = plt.subplots(1, 1) -ax2.pcolormesh(1e3 * np.squeeze(kgrid.x_vec), - 1e3 * np.squeeze(kgrid.y_vec), - source.p_mask[:, :, int(np.ceil(Nz / 2))].T, - shading='gouraud') +ax2.pcolormesh(1e3 * np.squeeze(kgrid.y_vec), + 1e3 * np.squeeze(kgrid.x_vec), + np.flip(source.p_mask[:, :, int(np.ceil(Nz / 2))], axis=0), + shading='nearest') ax2.set(xlabel='y [mm]', ylabel='x [mm]', title='Source Mask') diff --git a/examples/at_focused_annular_array_3D/at_focused_annular_array_3D.py b/examples/at_focused_annular_array_3D/at_focused_annular_array_3D.py index c8f6c428..abadc230 100644 --- a/examples/at_focused_annular_array_3D/at_focused_annular_array_3D.py +++ b/examples/at_focused_annular_array_3D/at_focused_annular_array_3D.py @@ -16,7 +16,8 @@ from kwave.kspaceFirstOrder3D import kspaceFirstOrder3D -from kwave.options import SimulationOptions, SimulationExecutionOptions +from kwave.options.simulation_options import SimulationOptions +from kwave.options.simulation_execution_options import SimulationExecutionOptions verbose: bool = False @@ -199,20 +200,21 @@ grid_weights = karray.get_array_grid_weights(kgrid) fig2, (ax2a, ax2b) = plt.subplots(1, 2) -ax2a.pcolormesh(1e3 * np.squeeze(kgrid.x_vec), - 1e3 * np.squeeze(kgrid.y_vec), - source.p_mask[:, :, int(np.ceil(Nz / 2))].T, - shading='gouraud') +ax2a.pcolormesh(1e3 * np.squeeze(kgrid.y_vec), + 1e3 * np.squeeze(kgrid.x_vec), + np.flip(source.p_mask[:, :, int(np.ceil(Nz / 2))], axis=0), + shading='nearest') ax2a.set(xlabel='y [mm]', ylabel='x [mm]', title='Source Mask') -ax2b.pcolormesh(1e3 * np.squeeze(kgrid.x_vec), - 1e3 * np.squeeze(kgrid.y_vec), - grid_weights[:, :, int(np.ceil(Nz / 2))].T, - shading='gouraud') +ax2b.pcolormesh(1e3 * np.squeeze(kgrid.y_vec), + 1e3 * np.squeeze(kgrid.x_vec), + np.flip(grid_weights[:, :, int(np.ceil(Nz / 2))], axis=0), + shading='nearest') ax2b.set(xlabel='y [mm]', ylabel='x [mm]', title='Off-Grid Source Weights') +plt.tight_layout(pad=1.2) # plot the pressure field fig3, ax3 = plt.subplots(1, 1) diff --git a/examples/at_focused_bowl_3D/at_focused_bowl_3D.py b/examples/at_focused_bowl_3D/at_focused_bowl_3D.py index cf8fd7a7..45b7401f 100644 --- a/examples/at_focused_bowl_3D/at_focused_bowl_3D.py +++ b/examples/at_focused_bowl_3D/at_focused_bowl_3D.py @@ -16,7 +16,8 @@ from kwave.kspaceFirstOrder3D import kspaceFirstOrder3D -from kwave.options import SimulationOptions, SimulationExecutionOptions +from kwave.options.simulation_options import SimulationOptions +from kwave.options.simulation_execution_options import SimulationExecutionOptions def L2_error(x: np.ndarray, y: np.ndarray, ord=None) -> float: @@ -202,16 +203,16 @@ def L2_error(x: np.ndarray, y: np.ndarray, ord=None) -> float: # calculate analytical solution p_ref_axial, _, _ = focused_bowl_oneil(source_roc, - source_diameter, - source_amp / (c0 * rho0), - source_f0, - c0, - rho0, - axial_positions=x_ref) + source_diameter, + source_amp / (c0 * rho0), + source_f0, + c0, + rho0, + axial_positions=x_ref) # calculate analytical solution at exactly the same points as k-Wave p_ref_axial_kw, _, _ = focused_bowl_oneil(source_roc, source_diameter, source_amp / (c0 * rho0), - source_f0, c0, rho0, axial_positions=x_vec) + source_f0, c0, rho0, axial_positions=x_vec) # calculate errors L2 = L2_error(p_ref_axial_kw, amp_on_axis, ord=2) @@ -240,20 +241,21 @@ def L2_error(x: np.ndarray, y: np.ndarray, ord=None) -> float: grid_weights = karray.get_array_grid_weights(kgrid) fig2, (ax2a, ax2b) = plt.subplots(1, 2) -ax2a.pcolormesh(1e3 * np.squeeze(kgrid.x_vec), - 1e3 * np.squeeze(kgrid.y_vec), - source.p_mask[:, :, int(np.ceil(Nz / 2))].T, - shading='gouraud') +ax2a.pcolormesh(1e3 * np.squeeze(kgrid.y_vec), + 1e3 * np.squeeze(kgrid.x_vec), + np.flip(source.p_mask[:, :, int(np.ceil(Nz / 2))], axis=0), + shading='nearest') ax2a.set(xlabel='y [mm]', ylabel='x [mm]', title='Source Mask') -ax2b.pcolormesh(1e3 * np.squeeze(kgrid.x_vec), - 1e3 * np.squeeze(kgrid.y_vec), - grid_weights[:, :, int(np.ceil(Nz / 2))].T, - shading='gouraud') +ax2b.pcolormesh(1e3 * np.squeeze(kgrid.y_vec), + 1e3 * np.squeeze(kgrid.x_vec), + np.flip(grid_weights[:, :, int(np.ceil(Nz / 2))], axis=0), + shading='nearest') ax2b.set(xlabel='y [mm]', ylabel='x [mm]', title='Off-Grid Source Weights') +plt.tight_layout(pad=1.2) # plot the pressure field fig3, ax3 = plt.subplots(1, 1)