fix: Update find_xtal.py post-scan collection position logic (#10) #11

Merged
perl_d merged 3 commits from find-xtal-center-fallback into main 2026-07-31 10:49:59 +02:00
Owner

Closes #10.

What

raster_highest_score now falls back to the geometric grid centre when the
grid is too weak to contain a crystal, instead of collecting at the noisy argmax
cell. So a "nothing in the loop" result is centred and deliberate rather than
data collected on noise.

Guard: route to centre when the grid-wide maximum spots_low_res is below
min_low_res_spots (default 10.0, exposed as a tunable parameter).

spots_indexed is deliberately NOT part of the guard: indexing was dropped from
the crystal score on main (w_indexed=0.00), so a crystal that diffracts but
fails to index must still be targeted, not routed to centre. This resolves the
earlier open question about the OR rule -- the indexed clause is gone.

Returns a CenterOfMassModel at the centre (not None), so both DAQ call sites
work unchanged -- the simulated branch (no None check) and the real branch (its
existing None-fallback simply stays dead). No AareDAQ change required.

Single file touched: src/aarecommon/math/find_xtal.py.

Test

uv run python src/aarecommon/math/find_xtal.py prints find_xtal self-check passed
(crystal maps to best cell; all-noise maps to centre; strong-spots-but-unindexed
maps to the best cell, indexing does not veto).

Generated with Claude Code.

Closes #10. ## What raster_highest_score now falls back to the geometric **grid centre** when the grid is too weak to contain a crystal, instead of collecting at the noisy argmax cell. So a "nothing in the loop" result is centred and deliberate rather than data collected on noise. Guard: route to centre when the grid-wide maximum spots_low_res is below min_low_res_spots (default 10.0, exposed as a tunable parameter). spots_indexed is deliberately NOT part of the guard: indexing was dropped from the crystal score on main (w_indexed=0.00), so a crystal that diffracts but fails to index must still be targeted, not routed to centre. This resolves the earlier open question about the OR rule -- the indexed clause is gone. Returns a CenterOfMassModel at the centre (not None), so both DAQ call sites work unchanged -- the simulated branch (no None check) and the real branch (its existing None-fallback simply stays dead). No AareDAQ change required. Single file touched: src/aarecommon/math/find_xtal.py. ## Test uv run python src/aarecommon/math/find_xtal.py prints find_xtal self-check passed (crystal maps to best cell; all-noise maps to centre; strong-spots-but-unindexed maps to the best cell, indexing does not veto). Generated with Claude Code.
duan_j added 1 commit 2026-07-28 13:47:37 +02:00
WIP: return grid centre when no crystal in raster scan (#10)
CI / lint (push) Failing after 15s
CI / test (3.11) (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / lint (pull_request) Failing after 22s
CI / test (3.11) (pull_request) Skipped
CI / test (3.12) (pull_request) Skipped
CI / test (3.13) (pull_request) Skipped
e4e4a44868
raster_highest_score always returns the argmax cell, which lands on
noise when the loop has no crystal. Add a grid-wide weakness guard:
when max(spots_low_res) < min_low_res_spots OR max(spots_indexed) <
min_spots_indexed, return a CenterOfMassModel at the geometric grid
centre instead of collecting at a noisy cell. Thresholds are tunable
parameters (defaults 10.0 and 1).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
duan_j force-pushed find-xtal-center-fallback from cad77d4cf1 to e4e4a44868 2026-07-28 13:47:37 +02:00 Compare
duan_j added 1 commit 2026-07-28 13:52:59 +02:00
style: ruff format
CI / lint (push) Successful in 18s
CI / lint (pull_request) Successful in 17s
CI / test (3.11) (push) Successful in 24s
CI / test (3.12) (push) Successful in 26s
CI / test (3.11) (pull_request) Successful in 21s
CI / test (3.13) (push) Successful in 22s
CI / test (3.13) (pull_request) Successful in 23s
CI / test (3.12) (pull_request) Successful in 26s
0dcfe15b7c
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
duan_j added 1 commit 2026-07-28 13:59:40 +02:00
fix: drop spots_indexed from no-crystal guard
Build and Publish / release (push) Successful in 13s
CI / test (3.12) (push) Successful in 22s
CI / test (3.11) (push) Successful in 24s
CI / test (3.13) (push) Successful in 21s
CI / lint (push) Successful in 24s
CI / lint (pull_request) Successful in 16s
CI / test (3.12) (pull_request) Successful in 22s
CI / test (3.11) (pull_request) Successful in 24s
CI / test (3.13) (pull_request) Successful in 24s
2969af8764
Indexing was removed from the crystal score (w_indexed=0.00), so it must
not act as a hard veto either: a crystal that diffracts but fails to
index should still be targeted, not routed to grid centre. Guard now
checks max spots_low_res only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
duan_j marked the pull request as ready for review 2026-07-28 14:01:16 +02:00
duan_j changed title from Update find_xtal.py post-scan collection position logic (#10) to fix: Update find_xtal.py post-scan collection position logic (#10) 2026-07-28 14:01:24 +02:00
Author
Owner

This one is ready to merge too...should go to the grid center for data collection when there is nothing in the grid

This one is ready to merge too...should go to the grid center for data collection when there is nothing in the grid
perl_d merged commit 2969af8764 into main 2026-07-31 10:49:59 +02:00
Sign in to join this conversation.