fix(flomni): always define tomo_alignment_fit

The global var was deleted on stage-in / new alignment and never created
at startup, so manual tweaks like fit[0][2] += 5.0 failed with an
undefined variable. reset_tomo_alignment_fit() now writes an all-zero
2x5 fit instead of deleting, and Flomni.__init__ creates it if missing
(an existing fit is kept so it survives client restarts).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
x12saandClaude Sonnet 5 committed 2026-09-21 14:55:20 +02:00
1 parent 26df688512
commit 5b688df428
1 file changed
+16 -1
@@ -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: