Skip to content

Express the stop rays in the object's local frame before flipping their direction - #198

Open
jacobdparker wants to merge 2 commits into
mainfrom
fix/stop-ray-object-frame
Open

Express the stop rays in the object's local frame before flipping their direction#198
jacobdparker wants to merge 2 commits into
mainfrom
fix/stop-ray-object-frame

Conversation

@jacobdparker

Copy link
Copy Markdown
Contributor

Problem

_calc_rayfunction_stops computes obj.transformation.inverse(rays) but only uses the localized rays for the direction-flip test — the flip itself is applied to result.outputs, which stays in global coordinates. Downstream, _calc_rayfunction_input interprets the field and pupil coordinates of the input grid in the object-local frame.

Any system whose object surface carries a rotation therefore breaks two ways:

  • the field bounds come back mirrored relative to the frame the input grid is interpreted in, so rays are aimed at the reflection of the field stop rather than the field stop itself; and
  • the stop-ray directions end up pointing along $-z$ in the local frame, wrapping the pupil-angle box at ±180°.

For a decentered field stop this vignettes every traced ray. Translation-only object transformations are unaffected, which is why existing tests never caught it. (Found via a MUSE spectrograph-only model whose object surface — the slit plane — is rotated 180° about $y$ to face the grating: all 35 slits vignetted completely.)

Changes

  • After localizing the rays with obj.transformation.inverse, apply the direction flip to the localized rays and store them back to result.outputs, so the stop rays are expressed in the same frame the input grid is interpreted in.

Tests

Adds TestSequentialSystemRotatedObject: a finite-conjugate relay whose object surface is rotated 180° about $y$ with a decentered circular aperture as the field stop, running the full AbstractTestAbstractSequentialSystem battery plus two focused assertions (field bounds match the decentered aperture in the object-local frame; a healthy fraction of rays reaches the sensor). Both focused tests fail on main and pass with the fix; the full _sequential_test.py file (509 tests) passes.

🤖 Generated with Claude Code

jacobdparker and others added 2 commits August 17, 2026 16:10
Preserved from the fix/linear-weights-area-unit working tree when that
branch was merged upstream as PR #194: the direction flip must be
applied to the rays already expressed in the local coordinates of the
object surface, since that is the frame in which _calc_rayfunction_input
interprets the field and pupil coordinates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A finite-conjugate relay whose object surface is rotated 180 degrees
about y, with a decentered circular aperture as the field stop. Without
the object-local frame fix, the field bounds come back mirrored
(field_min/field_max centered on -3 mm instead of +3 mm) and every
traced ray vignettes at the field stop.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jacobdparker
jacobdparker requested a review from roytsmart August 18, 2026 15:43
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.61%. Comparing base (64e05e6) to head (3f3e446).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
+ Coverage   99.57%   99.61%   +0.03%     
==========================================
  Files         118      118              
  Lines        6829     6947     +118     
==========================================
+ Hits         6800     6920     +120     
+ Misses         29       27       -2     
Flag Coverage Δ
unittests 99.61% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant