Files
csaxs_bec/bin/debug
menzelandClaude Opus 5 90358f5222
CI for csaxs_bec / test (push) Successful in 1m47s
debug: make the scan check work out its own geometry, or say why it cannot
First run against real data (S00473, S00254) found the files but stopped at
"metadata: none of the expected keys found" and "could not work out the line
geometry". Two wrong assumptions, both now fixed.

**Metadata location.** It was looked up at two hard-coded paths. BEC nests this
differently across versions, so it is now found by searching the tree for the
keys by basename, attributes included. Verified against metadata one level
deeper than the original code expected.

**Which signal defines the geometry.** The point count was taken from the
*longest* signal. Real files hold signals of several lengths -- S00473 has
86884 points in something while the per-point arrays are shorter -- so a
monitor on its own clock hijacked the calculation. It now takes the length
shared by the most signals, since per-point data outnumbers everything else.

When the geometry still cannot be inferred, the script no longer just gives up
and asks for --list. It now prints every signal grouped by length, and the
factor pairs that could plausibly be (lines x points-per-line). That turns a
dead end into a readable diagnosis in one run rather than a round trip. If a
length does not factor usefully at all it says so explicitly, because a padded
or truncated per-point array is itself a finding.

Also wires up --lines/--points, which were declared but never reached the
analysis.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-25 09:59:03 +02:00
..

Debug scripts

Throwaway diagnostics for investigating beamline problems. Not part of the plugin: nothing here is imported by csaxs_bec, and none of it needs BEC or a venv beyond the libraries each script names.

Kept on the debug/scan-artefacts branch rather than main so that a half-finished diagnostic never reaches a production checkout. Promote anything that turns out to be generally useful; delete the rest once the question it answered is settled.

scan_artefact_check.py

Desk check for the July 2026 commissioning scan artefacts reported by Andreas Apseros and Kazu Hirosawa. Read-only — opens BEC master files and writes nothing.

python3 scan_artefact_check.py --root /sls/x12sa/data/p23080/raw/data \
        --scan 473 --scan 450 --scan 411 --scan 254

Answers two questions without beam:

  • end-of-line intensity — is the last point of every line systematically weaker, and is the first point affected too (which would mean a different mechanism)?
  • dropped line motion — did the fast axis actually travel on every line? A line whose span collapsed is motion that did not happen while the scan still reported success.

Include a known-clean scan (254) so a null result distinguishes "this scan was fine" from "the analysis is wrong".

Run --list first if anything looks off; it dumps the file structure.

The motion check reads the fast-axis readback. If that axis is an open-loop stepper with no encoder, the readback is the commanded position and lost steps are invisible: a collapsed span still proves failure, but a healthy span proves nothing.