diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py index 5a105b75..f8cda11a 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py @@ -1406,7 +1406,21 @@ class FlomniAlignmentMixin: logger.warning("Not applying any correction.") def reset_tomo_alignment_fit(self): - self.client.delete_global_var("tomo_alignment_fit") + """Reset the alignment fit to all zeros (no offset applied). + + Writes zeros rather than deleting the global var, so that + "tomo_alignment_fit" is always defined and can be tweaked by hand + (see the layout comment above get_alignment_offset). + """ + self.client.set_global_var("tomo_alignment_fit", np.zeros((2, 5)).tolist()) + + def ensure_tomo_alignment_fit(self): + """Define "tomo_alignment_fit" (all zeros) if it does not exist yet. + + An existing fit is left untouched so it survives a client restart. + """ + if self.client.get_global_var("tomo_alignment_fit") is None: + self.reset_tomo_alignment_fit() def read_alignment_offset( self, @@ -1810,6 +1824,7 @@ class Flomni( self.label_printer = PTouchLabelPrinter(host="BRN94DDF8AAB8EC.psi.ch", template_number=1) self.set_client(client) + self.ensure_tomo_alignment_fit() self._maybe_reset_params_on_account_change() def set_web_password(self, password: str) -> None: