From 33c9c0e433861a65f3f0c378a9ea98791eaa2bdb Mon Sep 17 00:00:00 2001 From: x01dc Date: Mon, 27 Jul 2026 16:13:10 +0200 Subject: [PATCH] fix(LamNI): stop double-printing the Xeye correction table lamni_compute_additional_correction_xeye_mu() always printed its result. write_alignment_scan_numbers() called it once per angle just to grab the x-offset for the log file, which dumped all 12 corrections up front -- immediately followed by the exact same values reprinted one-by-one as tomo_alignment_scan() actually runs each angle. Add a verbose flag (default True) and pass verbose=False from the lookahead call. --- .../bec_ipython_client/plugins/LamNI/lamni.py | 2 +- .../plugins/LamNI/lamni_alignment_mixin.py | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni.py b/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni.py index f20f8bd..c584804 100644 --- a/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni.py +++ b/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni.py @@ -1183,7 +1183,7 @@ class LamNI(TomoQueueMixin, LamNIAlignmentMixin, LamNIOpticsMixin, LamniGuiTools x_vals = [] for angle in angles: - x, _y = self.lamni_compute_additional_correction_xeye_mu(angle) + x, _y = self.lamni_compute_additional_correction_xeye_mu(angle, verbose=False) x_vals.append(x) zeros = [0] * len(angles) diff --git a/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni_alignment_mixin.py b/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni_alignment_mixin.py index 03a1575..e404710 100644 --- a/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni_alignment_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/LamNI/lamni_alignment_mixin.py @@ -248,15 +248,24 @@ class LamNIAlignmentMixin: f" Y: A={fit[1][0]:.4f}, B={fit[1][1]:.4f}, C={fit[1][2]:.4f}" ) - def lamni_compute_additional_correction_xeye_mu(self, angle): + def lamni_compute_additional_correction_xeye_mu(self, angle, verbose: bool = True): """Evaluate the sinusoidal X-ray eye correction at *angle* degrees. + Args: + verbose: if True (default), print the computed correction. Pass + False for bulk/lookahead uses (e.g. write_alignment_scan_numbers()) + that just need the numbers and would otherwise print the same + values a second time, ahead of and redundant with the + per-projection print that happens when this is actually + applied during the scan. + Returns: tuple: ``(correction_x_mm, correction_y_mm)`` """ tomo_fit_xray_eye = self.client.get_global_var("tomo_fit_xray_eye") if tomo_fit_xray_eye is None: - print("Not applying any X-ray eye correction. No fit data available.") + if verbose: + print("Not applying any X-ray eye correction. No fit data available.") return (0, 0) correction_x = ( @@ -272,10 +281,11 @@ class LamNIAlignmentMixin: + tomo_fit_xray_eye[1][2] ) / 1000 - print( - f"Xeye correction x={correction_x:.6f} mm," - f" y={correction_y:.6f} mm @ angle={angle}" - ) + if verbose: + print( + f"Xeye correction x={correction_x:.6f} mm," + f" y={correction_y:.6f} mm @ angle={angle}" + ) return (correction_x, correction_y) # ------------------------------------------------------------------