From 7bff2724ef4d5146528eef282b99209862509be5 Mon Sep 17 00:00:00 2001 From: David Sinden Date: Mon, 19 Aug 2024 15:09:42 +0200 Subject: [PATCH 1/4] Update kmedium.py --- kwave/kmedium.py | 59 ++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 47 deletions(-) diff --git a/kwave/kmedium.py b/kwave/kmedium.py index f833f897..e94e5460 100644 --- a/kwave/kmedium.py +++ b/kwave/kmedium.py @@ -32,6 +32,18 @@ class kWaveMedium(object): absorbing: bool = False # is the medium absorbing stokes? stokes: bool = False + # compressional sound speed [m/s] + sound_speed_compression: np.array = None + # reference compressional sound speed [m/s] + sound_speed_ref_compression: np.array = None + # pshear wave speed [m/s] + sound_speed_shear: np.array = None + # reference shear wave speed [m/s] + sound_speed_ref_shear: np.array = None + # power law absorption for compressional waves coefficient [dB/(MHz^y cm)] + alpha_coeff_compression: np.array = None + # power law absorption for shearwaves coefficient [dB/(MHz^y cm)] + alpha_coeff_shear: np.array = None # """ # Note: For heterogeneous medium parameters, medium.sound_speed and @@ -181,50 +193,3 @@ def _check_absorbing_with_stokes(self): assert self.alpha_filter is None, ( "Input option medium.alpha_filter is not supported with the axisymmetric code " "or medium.alpha_mode = 'stokes'. " ) - - ########################################## - # Elastic-code related properties - raise error when accessed - ########################################## - _ELASTIC_CODE_ACCESS_ERROR_TEXT_ = "Elastic simulation and related properties are not supported!" - - @property - def sound_speed_shear(self): # pragma: no cover - """ - Shear sound speed (used in elastic simulations | not supported currently!) - """ - raise NotImplementedError(self._ELASTIC_CODE_ACCESS_ERROR_TEXT_) - - @property - def sound_speed_ref_shear(self): # pragma: no cover - """ - Shear sound speed reference (used in elastic simulations | not supported currently!) - """ - raise NotImplementedError(self._ELASTIC_CODE_ACCESS_ERROR_TEXT_) - - @property - def sound_speed_compression(self): # pragma: no cover - """ - Compression sound speed (used in elastic simulations | not supported currently!) - """ - raise NotImplementedError(self._ELASTIC_CODE_ACCESS_ERROR_TEXT_) - - @property - def sound_speed_ref_compression(self): # pragma: no cover - """ - Compression sound speed reference (used in elastic simulations | not supported currently!) - """ - raise NotImplementedError(self._ELASTIC_CODE_ACCESS_ERROR_TEXT_) - - @property - def alpha_coeff_compression(self): # pragma: no cover - """ - Compression alpha coefficient (used in elastic simulations | not supported currently!) - """ - raise NotImplementedError(self._ELASTIC_CODE_ACCESS_ERROR_TEXT_) - - @property - def alpha_coeff_shear(self): # pragma: no cover - """ - Shear alpha coefficient (used in elastic simulations | not supported currently!) - """ - raise NotImplementedError(self._ELASTIC_CODE_ACCESS_ERROR_TEXT_) From a7f9601db2d0c3a65d49b6208c55e39bbbb1a555 Mon Sep 17 00:00:00 2001 From: David Sinden Date: Mon, 19 Aug 2024 15:48:24 +0200 Subject: [PATCH 2/4] Update ivp_photoacoustic_waveforms.ipynb --- .../ivp_photoacoustic_waveforms.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ivp_photoacoustic_waveforms/ivp_photoacoustic_waveforms.ipynb b/examples/ivp_photoacoustic_waveforms/ivp_photoacoustic_waveforms.ipynb index ce336f71..f6e0bd2f 100644 --- a/examples/ivp_photoacoustic_waveforms/ivp_photoacoustic_waveforms.ipynb +++ b/examples/ivp_photoacoustic_waveforms/ivp_photoacoustic_waveforms.ipynb @@ -37,6 +37,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "import matplotlib.pyplot as plt\n", "from kwave.data import Vector\n", "from kwave.kgrid import kWaveGrid\n", "from kwave.kmedium import kWaveMedium\n", @@ -246,7 +247,6 @@ "outputs": [], "source": [ "t_sc, t_scale, t_prefix, _ = scale_SI(t_end)\n", - "import matplotlib.pyplot as plt\n", "_, ax1 = plt.subplots()\n", "ax1.plot(np.squeeze(kgrid2.t_array * t_scale), sensor_data_2D['p'] / np.max(np.abs(sensor_data_2D['p'])), 'r-')\n", "ax1.plot(np.squeeze(kgrid3.t_array * t_scale), sensor_data_3D[\"p\"] / np.max(np.abs(sensor_data_3D[\"p\"])), \"k-\", label=\"3D\")\n", From e0440b180dc5f9b5465ffc894444fc915c7207e2 Mon Sep 17 00:00:00 2001 From: David Sinden Date: Mon, 19 Aug 2024 15:49:20 +0200 Subject: [PATCH 3/4] Update na_controlling_the_pml.ipynb --- examples/na_controlling_the_pml/na_controlling_the_pml.ipynb | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/na_controlling_the_pml/na_controlling_the_pml.ipynb b/examples/na_controlling_the_pml/na_controlling_the_pml.ipynb index 202c3d92..d4ab67c6 100644 --- a/examples/na_controlling_the_pml/na_controlling_the_pml.ipynb +++ b/examples/na_controlling_the_pml/na_controlling_the_pml.ipynb @@ -36,7 +36,6 @@ "source": [ "import os\n", "from copy import deepcopy\n", - "from tempfile import gettempdir\n", "from typing import Dict\n", "\n", "import numpy as np\n", From e1f33057ac9d64c1d151bb2533e9e35bbaa8449a Mon Sep 17 00:00:00 2001 From: David Sinden Date: Mon, 19 Aug 2024 15:54:55 +0200 Subject: [PATCH 4/4] fix in ipynb --- examples/us_defining_transducer/us_defining_transducer.ipynb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/us_defining_transducer/us_defining_transducer.ipynb b/examples/us_defining_transducer/us_defining_transducer.ipynb index d54619f3..a428fae4 100644 --- a/examples/us_defining_transducer/us_defining_transducer.ipynb +++ b/examples/us_defining_transducer/us_defining_transducer.ipynb @@ -28,10 +28,8 @@ "from kwave.kWaveSimulation import SimulationOptions\n", "\n", "from kwave.options.simulation_execution_options import SimulationExecutionOptions\n", - "from kwave.utils.colormap import get_color_map\n", "from kwave.utils.dotdictionary import dotdict\n", "from kwave.utils.filters import spect\n", - "from kwave.utils.kwave_array import kWaveArray\n", "from kwave.utils.plot import voxel_plot\n", "from kwave.utils.signals import tone_burst" ] @@ -239,7 +237,7 @@ "axes[1].plot(f * 1e-6, as_3 / np.max(as_1.flatten()), 'r-', label = 'Sensor Position 3')\n", "axes[1].legend()\n", "axes[1].set_xlabel('Frequency [MHz]')\n", - "axes[1].set_ylabel('Normalised Amplitude Spectrum [au]');\n", + "axes[1].set_ylabel('Normalised Amplitude Spectrum [au]')\n", "f_max = medium.sound_speed / (2 * dx)\n", "axes[1].set_xlim([0, f_max * 1e-6])\n" ]