feat(flomni): offer tomo-param reset on account change at session start
At BEC session start, compare bec.active_account against the new global var defaults_applied_for_account. On a genuine account change, interactively offer to reset all tomo scan parameters to their defaults for the new experiment; a client restart within the same account is a silent no-op. Add _set_default_tomo_params() writing all 20 scan parameters via the property setters.
This commit is contained in:
@@ -1718,10 +1718,72 @@ class Flomni(
|
||||
self.align = XrayEyeAlign(self.client, self)
|
||||
self.set_client(client)
|
||||
|
||||
self._maybe_reset_params_on_account_change()
|
||||
|
||||
def set_web_password(self, password: str) -> None:
|
||||
"""Set the web password for the current BEC account."""
|
||||
self._webpage_gen.set_web_password(password)
|
||||
|
||||
def _maybe_reset_params_on_account_change(self) -> None:
|
||||
"""Offer a tomo-parameter reset when the active account has changed.
|
||||
|
||||
Called at BEC session start. The account for which defaults were last
|
||||
applied is stored in the global var ``defaults_applied_for_account`` so
|
||||
it survives client restarts. Only a genuine change of account triggers
|
||||
the (interactive) reset; the same account is a silent no-op, so
|
||||
restarting a client within the same experiment never disturbs tuned
|
||||
parameters.
|
||||
"""
|
||||
bec = builtins.__dict__.get("bec")
|
||||
try:
|
||||
account = bec.active_account
|
||||
except Exception as exc:
|
||||
print(f"account-change check skipped: cannot read active_account: {exc}")
|
||||
return
|
||||
if not account:
|
||||
return
|
||||
|
||||
last_account = self.client.get_global_var("defaults_applied_for_account")
|
||||
if account == last_account:
|
||||
return
|
||||
|
||||
if self.OMNYTools.yesno(
|
||||
f"New account '{account}' detected (previous: '{last_account}').\n"
|
||||
"Reset tomo parameters to defaults for the new experiment?",
|
||||
"y",
|
||||
):
|
||||
self._set_default_tomo_params()
|
||||
print(f"Tomo parameters reset to defaults for account '{account}'.")
|
||||
self.client.set_global_var("defaults_applied_for_account", account)
|
||||
|
||||
def _set_default_tomo_params(self) -> None:
|
||||
"""Write all tomo scan parameters back to their default values.
|
||||
|
||||
These are the same baseline values used as the getter fallbacks. Per-
|
||||
sample alignment state (corrections, alignment offsets) is deliberately
|
||||
not reset here, as it is overwritten by the next alignment anyway.
|
||||
"""
|
||||
self.tomo_shellstep = 1
|
||||
self.tomo_countingtime = 0.1
|
||||
self.manual_shift_y = 0.0
|
||||
self.single_point_random_shift_max = 0.0
|
||||
self.fovx = 20
|
||||
self.fovy = 20
|
||||
self.tomo_type = 1
|
||||
self.corridor_size = -1
|
||||
self.stitch_x = 0
|
||||
self.stitch_y = 0
|
||||
self.ptycho_reconstruct_foldername = "ptycho_reconstruct"
|
||||
self.tomo_angle_stepsize = 10.0
|
||||
self.golden_max_number_of_projections = 1000.0
|
||||
self.tomo_stitch_overlap = 0.2
|
||||
self.tomo_angle_range = 180
|
||||
self.golden_projections_at_0_deg_for_damage_estimation = 0
|
||||
self.zero_deg_reference_at_each_subtomo = False
|
||||
self.golden_ratio_bunch_size = 20
|
||||
self.frames_per_trigger = 1
|
||||
self.single_point_instead_of_fermat_scan = False
|
||||
|
||||
def start_x_ray_eye_alignment(self, keep_shutter_open=False):
|
||||
|
||||
if self.OMNYTools.yesno(
|
||||
|
||||
Reference in New Issue
Block a user