From 9fc0770055044022fc74dfa0eee6c006cbb0a573 Mon Sep 17 00:00:00 2001 From: x01dc Date: Mon, 27 Jul 2026 16:58:11 +0200 Subject: [PATCH] feat(LamNI): invalidate X-ray-eye/fine alignment on a new rotation centre Re-running rotation-center calibration after X-ray-eye alignment (or fine alignment) was already done left the stale fit/correction in place, silently calibrated around the old center. Record lamni_center_found_at and cascade-invalidate via the existing reset_xray_eye_correction()/reset_correction() whenever a new center is actually applied, in both find_rotation_center() and find_rotation_center_smear_experimental(). --- .../plugins/LamNI/x_ray_eye_align.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py b/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py index c460077..0b1b41a 100644 --- a/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py +++ b/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py @@ -961,6 +961,7 @@ class XrayEyeAlign: if answer in ("", "y", "yes"): dev.lsamx.update_user_parameter({"center": float(new_lsamx)}) dev.lsamy.update_user_parameter({"center": float(new_lsamy)}) + self._mark_center_found_and_invalidate_downstream() print( f"[rotation-center][smear] lsamx.user_parameter['center'] = " f"{dev.lsamx.user_parameter.get('center')}, " @@ -1116,6 +1117,27 @@ class XrayEyeAlign: f"interferometer rtx/rty now read ({rtx_after:.2f}, {rty_after:.2f}) um" ) + def _mark_center_found_and_invalidate_downstream(self): + """Record that the rotation centre was just (re-)established, and + invalidate any X-ray-eye/fine-alignment state calibrated around the + previous centre. + + Called right after a new lsamx/lsamy centre is actually applied (by + both find_rotation_center() and find_rotation_center_smear_experimental()). + Reuses the LamNI alignment mixin's own reset methods rather than + introducing separate invalidation logic -- see + lamni.xrayeye_alignment_start()/tomo_alignment_scan()/tomo_scan(), + which gate on lamni_center_found_at / tomo_fit_xray_eye / corr_pos_x + respectively. + """ + import datetime + + self.client.set_global_var( + "lamni_center_found_at", datetime.datetime.now().isoformat() + ) + self.lamni.reset_xray_eye_correction() + self.lamni.reset_correction() + def find_rotation_center( self, sample_type: str = "isolated", keep_shutter_open: bool = False, apply: bool = True ): @@ -1271,6 +1293,7 @@ class XrayEyeAlign: if answer in ("", "y", "yes"): dev.lsamx.update_user_parameter({"center": float(new_lsamx)}) dev.lsamy.update_user_parameter({"center": float(new_lsamy)}) + self._mark_center_found_and_invalidate_downstream() print( f"[rotation-center] lsamx.user_parameter['center'] = " f"{dev.lsamx.user_parameter.get('center')}, "