fix(flomni): report correct projection count in tomo PDF/SciLog for golden-ratio scans
CI for csaxs_bec / test (push) Failing after 2m7s

write_pdf_report() always derived "Number of projections" (and the
dependent sub-tomogram-count/angular-step fields) from
_tomo_type1_actual_grid(), which is only valid for tomo_type==1. For
golden-ratio scans (tomo_type 2/3) it silently reported a stale,
unrelated type-1 total left over in the persistent tomo_angle_stepsize
global var instead of golden_max_number_of_projections, causing the
PDF/SciLog entry to disagree with the web page's correct progress
display. Branch on tomo_type the same way tomo_parameters() already
does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FFeiCHv3qUxxssmP9Qzhom
This commit is contained in:
x12saandClaude Sonnet 5 committed 2026-09-12 20:31:24 +02:00
1 parent 2dae9441ec
commit 5a22651c46
1 file changed
+53 -9
@@ -3998,10 +3998,55 @@ class Flomni(
stitching = f"{self.stitch_x:.0f}/{self.stitch_y:.0f}"
dataset_id = str(self.client.queue.next_dataset_number)
account = bec.active_account
# Same grid sub_tomo_scan() actually uses -- see
# _tomo_type1_actual_grid()'s docstring for why this can't just
# recompute int((tomo_angle_range/tomo_angle_stepsize)*8) locally.
_, _, tomo_type1_total_projections = self._tomo_type1_actual_grid()
# The correct total-projections / sub-tomogram-count / angular-step
# values depend on which tomography type is actually configured --
# mirrors tomo_parameters()'s tomo_type 1/2/3 branching above. This
# branch used to be missing: write_pdf_report() always called
# _tomo_type1_actual_grid() (int(180/tomo_angle_stepsize)*8), which
# is only meaningful for tomo_type==1. For golden-ratio scans
# (tomo_type==2/3) that silently reported a stale, unrelated
# type-1 total left over in the persistent tomo_angle_stepsize
# global var, instead of self.golden_max_number_of_projections --
# the value the user actually configured and that the web page's
# progress display and tomo_parameters() already use correctly.
if self.tomo_type == 1:
_, achievable_step, total_projections = self._tomo_type1_actual_grid()
subtomo_count_label = "Number of individual sub-tomograms:"
subtomo_count_value = "8"
angle_step_label = "Angular step within sub-tomogram:"
angle_step_value = f"{achievable_step:.2f}"
elif self.tomo_type == 3:
total_projections = (
self.golden_max_number_of_projections
if self.golden_max_number_of_projections > 0
else 0
)
subtomo_count_label = "Number of projections per sub-tomogram:"
subtomo_count_value = f"{180 / self.tomo_angle_stepsize:.1f}"
angle_step_label = "Angular step within sub-tomogram:"
angle_step_value = f"{self.tomo_angle_stepsize:.2f}"
else:
# tomo_type == 2: golden ratio tomography -- there is no fixed
# set of sub-tomograms or a fixed angular step, so report the
# bunch size instead (matches tomo_parameters()'s printout).
total_projections = (
self.golden_max_number_of_projections
if self.golden_max_number_of_projections > 0
else 0
)
subtomo_count_label = "Sorted in bunches of:"
subtomo_count_value = f"{self.golden_ratio_bunch_size}"
angle_step_label = "Angular step within sub-tomogram:"
angle_step_value = "N/A (golden ratio)"
total_projections_str = (
f"{total_projections}" if total_projections else "N/A (manual stop)"
)
last_scan_number_str = (
f"{self.client.queue.next_scan_number + total_projections + 10}"
if total_projections
else "N/A"
)
# Same device ffzp_info() already reads. Defensive: may not be
# configured/available in every session (e.g. simulated configs).
try:
@@ -4051,17 +4096,16 @@ class Flomni(
f"{'Dataset ID:':<{padding}}{dataset_id}\n",
f"{'Sample Info:':<{padding}}Sample Info\n",
f"{'e-account:':<{padding}}{account}\n",
f"{'Number of projections:':<{padding}}{tomo_type1_total_projections}\n",
f"{'Number of projections:':<{padding}}{total_projections_str}\n",
f"{'First scan number:':<{padding}}{self.client.queue.next_scan_number}\n",
f"{'Last scan number approx.:':<{padding}}"
f"{self.client.queue.next_scan_number + tomo_type1_total_projections + 10}\n",
f"{'Last scan number approx.:':<{padding}}{last_scan_number_str}\n",
f"{'Current photon energy:':<{padding}}{energy_str}\n",
f"{'Exposure time:':<{padding}}{self.tomo_countingtime:.2f}\n",
f"{'Fermat spiral step size:':<{padding}}{self.tomo_shellstep:.2f}\n",
f"{'FOV:':<{padding}}{fovxy}\n",
f"{'Stitching:':<{padding}}{stitching}\n",
f"{'Number of individual sub-tomograms:':<{padding}}8\n",
f"{'Angular step within sub-tomogram:':<{padding}}{self.tomo_angle_stepsize:.2f}\n",
f"{subtomo_count_label:<{padding}}{subtomo_count_value}\n",
f"{angle_step_label:<{padding}}{angle_step_value}\n",
f"{'FZP diameter:':<{padding}}{fzp_diameter_um} microns\n",
f"{'FZP outermost zone width:':<{padding}}{fzp_zone_width_nm} nm\n",
f"{'FZP details:':<{padding}}{fzp_details}\n",