Feat/fil comb #306

Merged
menzel merged 4 commits from feat/fil-comb into main 2026-08-30 12:58:16 +02:00
4 Commits
Author SHA1 Message Date
menzelandClaude Opus 5 d120740dbb feat(filters): accept fil_comb(1411) as well as fil_comb(1, 4, 1, 1)
CI for csaxs_bec / test (pull_request) Successful in 1m41s
Read the Docs Deploy Trigger / trigger-rtd-webhook (push) Successful in 2s
CI for csaxs_bec / test (push) Successful in 1m52s
The four-digit code is already the currency of this module: it is what
_all_combinations builds, what fil_trans prints as the selected
combination, and what _fil_trans_report prints for what is currently in
the beam. Requiring commas on the way back in meant reading a code off
the screen and retyping it as four separate arguments.

fil_comb now takes 1411, "1411", (1, 4, 1, 1) or [1, 4, 1, 1], so a
reported combination can be pasted straight back.

A code of the wrong length is rejected with the length it needs rather
than falling through to "expects 4 positions, got 1", which was the
unhelpful error a code would have produced before. bool is excluded from
the integer branch so fil_comb(True) does not quietly become "True".
Digits outside 1..6 are left to the existing per-unit range check, which
names the offending unit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kLGTqTyXzTT4swt3CfTkV
2026-08-30 12:47:26 +02:00
menzelandClaude Opus 5 0874ca3b38 fix(filters): use the measured thicknesses and keep calibration foils out of fil_trans
Two ways the filter table disagreed with filter.mac rev 1.19.

The Si thicknesses were nominal where spec used values measured at
18.58 keV: 400/200/3200/100/1600/800 against 345.6/234.6/3303/137.5/
1661.5/833.8. Si100 vs Si137.5 is 37% out, and at 17 keV the pair
Si200+Si1600 gives T=0.060 where the measured Si234.6+Si1661.5 gives
0.052 -- a 16% error, larger than any distinction the search was trying
to make between neighbouring combinations.

The Zr and Cu calibration foils were selectable. filter.mac flagged them
disabled so that selection by transmission could not pick them, and at
17 keV fil_trans(0.05) duly returned 5246 -- a combination built on the
Zr foil, 1 keV below its K edge, where its transmission moves with any
small change in energy.

They are excluded through a new _EXCLUDE_FROM_SEARCH rather than by
clearing their 'enabled' flag, because those two things are not the same
and the flag is load-bearing elsewhere: _fil_trans_report substitutes
T=1.0 for a disabled position, so clearing the flag would have made the
report silently ignore a foil parked in the beam -- precisely the state
an edge scan puts it in. The foils stay enabled, stay addressable via
fil_comb as they were in spec, and are skipped only by the automatic
search.

At 17 keV fil_trans(0.05) now returns 2146 (Si345.6 + Ti200 + Ti20,
T=0.0494) and fil_trans(0.01) returns 2234 (T=0.0099), both matching an
independent calculation over the same CXRO tables.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kLGTqTyXzTT4swt3CfTkV
2026-08-30 12:46:12 +02:00
menzelandClaude Opus 5 9cf7a9307c refactor(filters): share the attenuation interlock between fil_trans and fil_comb
The DMM-through / CCM-active check now lives in _attenuation_allowed and
fil_trans calls it, so there is one copy rather than two drifting ones.
A guard that is duplicated is a guard that gets fixed in one place only.

Behaviour is unchanged: the same three PVs are read with the same
fallbacks, the same warning is printed, the same default-NO prompt is
raised through OMNYTools.yesno, the same "Safe fallback" of refusing
when no prompt is available applies, and fil_trans(1) still bypasses the
check entirely.

Split from the previous commit so that this half can be reverted on its
own if it misbehaves at the beamline, without taking fil_comb with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kLGTqTyXzTT4swt3CfTkV
2026-08-30 12:42:51 +02:00
menzelandClaude Opus 5 1646e3cb4a feat(filters): add fil_comb for explicit filter combinations
fil_trans selects by transmission, which is the wrong tool when a
particular foil is wanted: it optimises against the thickness table and
which combination wins is not something to rely on. The alternative was
four hand-copied stage coordinates, where the out positions differ per
unit (25.0 / 25.5 / 25.8 / 25.0) and getting one wrong leaves the stage
off any tabulated slot -- _fil_trans_report matches within 0.1, so the
combination then reports as unidentified.

fil_comb takes one slot number per unit, 1..6 with 1 = out, as the SPEC
fil_comb did, and looks the coordinates up. It reuses
_position_transmission, _print_combination and _execute_combination
unchanged, so it reports and moves exactly as fil_trans does, including
the dry run and the default-yes prompt.

Every slot is validated before the safety prompt is reached, so a typo
raises rather than putting a question about an unexecutable combination
in front of someone. Disabled slots -- Fe5 and the redundant opens --
raise too: _all_combinations skips them, so fil_comb must refuse them
rather than move somewhere fil_trans would never choose.

_attenuation_allowed is added here but not yet wired into fil_trans;
that is the next commit, so this one cannot change existing behaviour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kLGTqTyXzTT4swt3CfTkV
2026-08-30 12:42:12 +02:00