Added support for using the object surface as the field stop of a SequentialSystem#169
Open
jacobdparker wants to merge 1 commit into
Open
Added support for using the object surface as the field stop of a SequentialSystem#169jacobdparker wants to merge 1 commit into
SequentialSystem#169jacobdparker wants to merge 1 commit into
Conversation
…uentialSystem Marking the object surface (with an angular, dimensionless aperture) as the field stop is the natural configuration for dispersive systems, where the sensor outline is not reachable at a single wavelength, but the stop root-finding problem was broken in three ways for this case: - The position-variable branch of `_calc_rayfunction_stops_only` called `sag()` with a 2-component vector, raising a TypeError before the solve even started. - The solved outputs were never broadcast over both stop axes, so the reductions in `field_min`/`field_max`/`pupil_min`/`pupil_max` raised an axis error. - The initial guess started every ray at the origin of the first stop with direction +z, which produces NaN residuals on the first iteration for surfaces far from that axis (e.g. the off-axis feed mirror of a Rowland-circle spectrograph) or on steep grazing-incidence flanks, and Newton's method cannot recover from NaN. The seed now aims each ray at its own target point on the last stop surface when no surface with optical power lies between the two stops (nearly exact), and otherwise at the center of the first powered surface. Adds a grazing-incidence spectrograph regression test whose source is the field stop, asserting that the recovered field equals the source's angular radius. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 11, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix/solver-robustness #169 +/- ##
=========================================================
+ Coverage 99.29% 99.36% +0.07%
=========================================================
Files 116 116
Lines 5978 6024 +46
=========================================================
+ Hits 5936 5986 +50
+ Misses 42 38 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Second PR in the stop-solver stack — stacked on #168 (the diff shown here is relative to that branch).
Problem
Marking the object surface (with an angular, dimensionless aperture) as the field stop is the natural configuration for dispersive systems — at a single wavelength of a dispersed spectrum, most of the sensor outline is unreachable, so targeting the sensor wire is ill-posed. But this configuration was broken in three independent ways:
_calc_rayfunction_stops_onlycalledsag()with a 2-component vector →TypeErrorbefore the solve started.field_min/max/pupil_min/maxreductions.Changes
zfuncbuilds a proper 3-D vector before callingsag()._calc_rayfunction_stopsbroadcasts position and direction against each other before the stop-axis reductions._anchor_surfacehelper: the seed now aims each ray at its own target point on the last stop surface when no powered surface lies between the stops (nearly exact — the grazing solve converges in ~5 iterations), and otherwise at the center of the first powered surface.Tests
Adds
TestSequentialSystemGrazingSpectrograph: a grazing-incidence paraboloid + transmission-grating spectrograph whose source is the field stop, asserting the recovered field equals the source's angular radius (0.25°) to 1e-6 deg. Also verified against the FURSTSpectrographmodel from Kankelborg-Group/furst-optics#25, which recoversfield_max= ±0.26656° (the sunpy solar angular radius).🤖 Generated with Claude Code