Repository navigation
Read a scan's pattern center back from its strain - #34
Merged
Merged
Conversation
A pattern fitted at a center d too far shows the strain J d, with J the symmetric, trace-free part of the center maps' derivative (worked out from the geometry). strain_per_center gives J; centers_from_strain reads each point's center from its strain and fits a robust plane through them over the beam positions, leaving out local real strain. Optionally the drift is given from the geometry and only the offset fitted. Claude-Session: https://claude.ai/code/session_01DzXsKCmqfzn1vmniNccgXh
CSSFrancis
force-pushed
the
feat/center-from-strain
branch
from
November 13, 2026 16:43
ae16127 to
0dc74ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #33 (its Live strain docs section is extended here).
A pattern fitted at a center
dtoo far shows the strainJ d.Jis the symmetric, trace-free part of the derivative ofcenter_maps, worked out from the geometry with no pattern fitted; on the twin it matched finite differences of real fits to within 1%.LiveIndexer.strain_per_center()/calibration.strain_per_center:J,(3, 3, 3).calibration.centers_from_strain(strain, positions, fitted_at, response, *, use=None, drift=None, robust=True)→CenterPlane(center, drift, points, weights): each point's center from its strain, and a plane through them over the beam positions. Robust by default (Tukey's biweight from a least-median start, so a strained corner can't tilt it);userestricts it to a known unstrained region;driftfixes the drift from the geometry and fits only the offset.Twin (duplex steel + indent, 480 µm, 16×16, indexed 0.010/−0.008/0.006 off): center at the middle within 3e-4, worst over the field 7e-4; re-indexed there the strain is within 6e-4 rms of each point at its true center (74e-4 at the wrong center). Subtracting a plane from the strain instead also took out the indent.
Tests:
test_a_center_error_shows_as_the_strain_strain_per_center_predicts,test_a_scans_center_plane_is_read_back_from_its_strain. Ranruff check,ruff format --check,tests/index/test_live.pyandtest_pattern_center.py(fused CUDA tests skipped: no CuPy in this env).https://claude.ai/code/session_01DzXsKCmqfzn1vmniNccgXh