From da75f885186ebdff25041ff5ab3d4cbfb0430fa3 Mon Sep 17 00:00:00 2001 From: Oscar Bates Date: Wed, 30 Jul 2025 10:06:54 +0100 Subject: [PATCH 1/3] Improved path check findomp --- mosaic/cli/findomp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mosaic/cli/findomp.py b/mosaic/cli/findomp.py index a0ccb8aa..15cc7b6b 100755 --- a/mosaic/cli/findomp.py +++ b/mosaic/cli/findomp.py @@ -16,13 +16,13 @@ def go(): comp_path = os.path.join(os.path.join(os.path.dirname(cuda_home), 'compilers'), 'lib') break - if comp_path is None: + if comp_path is None or not os.path.exists(comp_path): hpcsdk_home = os.environ.get('HPCSDK_HOME') if hpcsdk_home: comp_path = os.path.join(os.path.join(hpcsdk_home, 'compilers'), 'lib') # If not, try to get from LD_LIBRARY_PATH - if comp_path is None: + if comp_path is None or not os.path.exists(comp_path): library_path = os.environ.get('LD_LIBRARY_PATH', '') for path in library_path.split(':'): if re.match('.*/nvidia/hpc_sdk/.*/?compilers/lib', path) or \ From 9fbfe4e01e601ceba358d4b4f8173bf0558b39dc Mon Sep 17 00:00:00 2001 From: Oscar Bates Date: Wed, 30 Jul 2025 10:07:16 +0100 Subject: [PATCH 2/3] Geometry plotter using pyplot --- stride/plotting/plot_points.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/stride/plotting/plot_points.py b/stride/plotting/plot_points.py index 771f1d3f..93a30afb 100644 --- a/stride/plotting/plot_points.py +++ b/stride/plotting/plot_points.py @@ -1,6 +1,7 @@ import os import numpy as np +import matplotlib.pyplot as plt __all__ = ['plot_points', 'plot_points_2d', 'plot_points_3d'] @@ -71,6 +72,39 @@ def plot_points_2d(coordinates, axis=None, colour='red', size=15, title=None, def plot_points_3d(coordinates, axis=None, colour='red', size=15, title=None, **kwargs): + """ + Utility function to plot 3D scattered points using matplotlib. + + Parameters + ---------- + coordinates : 2-dimensional array + Coordinates of the points to be plotted, shape should be (n_points, 3). + axis : MayaVi axis, optional + Axis in which to make the plotting, defaults to new empty one. + colour : str + Colour to apply to the points, defaults to red. + size : float + Size of the plotted points, defaults to 15. + title : str, optional + Figure title, defaults to empty title. + """ + fig = plt.figure(figsize=(10, 8)) + ax = fig.add_subplot(111, projection='3d') + ax.set_title('3D View: Tangent Points with Out-of-Plane Displacement') + + ax.plot(coordinates[:, 0], coordinates[:, 1], coordinates[:, 2], 'o') + + ax.set_xlabel('X (mm)') + ax.set_ylabel('Y (mm)') + ax.set_zlabel('Z (mm)') + ax.legend() + ax.grid(True) + ax.set_box_aspect([1, 1, 0.5]) + plt.tight_layout() + plt.show() + + +def plot_points_3d_mayavi(coordinates, axis=None, colour='red', size=15, title=None, **kwargs): """ Utility function to plot 3D scattered points using MayaVi. From ecdd639fda8a0fc89d5e1e536d5b2dfd5873eabe Mon Sep 17 00:00:00 2001 From: Oscar Bates Date: Wed, 3 Dec 2025 13:38:53 +0000 Subject: [PATCH 3/3] Print statements, comments, units --- stride/core.py | 2 ++ stride/optimisation/pipelines/default_pipelines.py | 2 ++ stride/optimisation/pipelines/steps/clip.py | 2 ++ stride/plotting/plot_traces.py | 2 +- stride/problem/acquisitions.py | 2 +- stride/problem/geometry.py | 7 ++++--- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/stride/core.py b/stride/core.py index 536b7b50..50d151c1 100644 --- a/stride/core.py +++ b/stride/core.py @@ -335,6 +335,8 @@ def _dealloc(*args): parallel_returns = [] deallocs = [] for node in self.graph.toposort(self.prev_op): + print('Node') + print(node) kwargs_ = kwargs.copy() if node.method == '__noop__': diff --git a/stride/optimisation/pipelines/default_pipelines.py b/stride/optimisation/pipelines/default_pipelines.py index f7a37b8e..c8e86f2a 100644 --- a/stride/optimisation/pipelines/default_pipelines.py +++ b/stride/optimisation/pipelines/default_pipelines.py @@ -138,6 +138,8 @@ def __init__(self, steps=None, **kwargs): if kwargs.pop('time_weighting', True): steps.append(('time_weighting', False)) + print('Process Traces Steps') + print(steps) super().__init__(steps, **kwargs) diff --git a/stride/optimisation/pipelines/steps/clip.py b/stride/optimisation/pipelines/steps/clip.py index 74582219..075c5b1d 100644 --- a/stride/optimisation/pipelines/steps/clip.py +++ b/stride/optimisation/pipelines/steps/clip.py @@ -32,6 +32,8 @@ def forward(self, field, **kwargs): out_field.extended_data[:] = np.clip(field.extended_data, self.min, self.max) + print('Clip max {} min {}'.format(self.max, self.min)) + return out_field def adjoint(self, d_field, field, **kwargs): diff --git a/stride/plotting/plot_traces.py b/stride/plotting/plot_traces.py index 43d27f04..3f9e84a0 100644 --- a/stride/plotting/plot_traces.py +++ b/stride/plotting/plot_traces.py @@ -252,7 +252,7 @@ def plot_gather(*args, skip=1, time_range=None, norm=True, norm_trace=True, axis.set_ylim(time_axis[-1, 0], time_axis[0, 0]) axis.set_xlabel('trace') - axis.set_ylabel('time') + axis.set_ylabel(r'time ($\mu$s)') if trace_axis is None: trace_axis = np.linspace(0, num_traces-1, num_under_traces, endpoint=True) diff --git a/stride/problem/acquisitions.py b/stride/problem/acquisitions.py index 95124a14..27c6e072 100644 --- a/stride/problem/acquisitions.py +++ b/stride/problem/acquisitions.py @@ -57,7 +57,7 @@ def _select_slice(selection, init_ids, class Shot(ProblemBase): """ - A Shot is an even in which one or more transducers act as sources with a given wavelet and one or more + A Shot is an event in which one or more transducers act as sources with a given wavelet and one or more transducers act as receivers and record some observed data. Therefore a shot object maintains data about the ids of the transducer locations that will act as sources, diff --git a/stride/problem/geometry.py b/stride/problem/geometry.py index dce199e7..a921977d 100644 --- a/stride/problem/geometry.py +++ b/stride/problem/geometry.py @@ -27,7 +27,7 @@ class TransducerLocation(GriddedSaved): Optional name for the transducer location. transducer : Transducer Transducer device to which this location refers. - coordinates : ndarray + coordinates : ndarray, units [m] Coordinates of the transducer in the space grid. orientation : ndarray, optional Orientation of the transducer with respect to its location. @@ -352,8 +352,9 @@ def plot(self, **kwargs): plot = kwargs.pop('plot', True) coordinates = self.coordinates - if self.space.dim > 2: - coordinates = coordinates / np.array(self.space.spacing) + # if self.space.dim > 2: # Note mayavi plots in cells + # coordinates = coordinates / np.array(self.space.spacing) + # coordinates = coordinates / 1e-3 # [m] to [mm] axis = plotting.plot_points(coordinates, title=title, **kwargs)