Skip to content

Interpret grid_input as cell vertices and trace rays at cell centers#187

Open
roytsmart wants to merge 1 commit into
mainfrom
feature/grid-input-vertices
Open

Interpret grid_input as cell vertices and trace rays at cell centers#187
roytsmart wants to merge 1 commit into
mainfrom
feature/grid-input-vertices

Conversation

@roytsmart

Copy link
Copy Markdown
Collaborator

Summary

The components of grid_input (and of the grids given to distortion() and vignetting()) are now interpreted as cell vertices, and the rays of the system are traced at the corresponding cell centers, so the inputs of rayfunction_default and of the rayfunctions used by the fitting methods are defined on cell vertices while the outputs are defined on cell centers (a first-class named-arrays concept via FunctionArray.axes_vertex).

Why:

  • Makes the system grids consistent with the vertex convention already used by image() (whose pupil parameter was already documented as vertices).
  • Enables area-weighted methods, such as the upcoming effective area calculation, which need pupil cell areas from the vertices.
  • Rays are never traced exactly on aperture edges (cell centers are strictly interior), avoiding knife-edge vignetting comparisons.

Implementation:

  • _grid_input_physical / _grid_input_centers cached properties (denormalized vertices and their centers); _rayfunction_input traces the centers but attaches the vertex grid as inputs.
  • _rayfunction_and_axes resolves grids (components left as None inherit from grid_input), infers axes, denormalizes, centers, traces, and attaches the vertex inputs; distortion()/vignetting() compute their scene coordinates as rays.inputs.cell_centers(...) so calibration points align with the outputs.
  • raytrace()/rayfunction() keep their exact-sample-point semantics, since image() passes precomputed cell centers with stratified random offsets.
  • spot_diagram() draws its layout, wavelength colors, and field labels from the centered physical grid.

Migration note for downstream configurations

Grids built with na.*LinearSpace(..., centers=True) should drop centers=True and increment num by one, which reproduces the previously traced rays exactly (esis and cool-aid each have one or two such sites).

Tests

Full optika suite run locally: all passing (verified against the new named-arrays release together with #185). Verified directly that rayfunction_default.inputs holds the vertex grid, outputs are traced at centers, and axes_vertex reports all five grid axes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lm9SxSpyNg9hx8dNL9pUXc

The components of grid_input (and of the grids given to distortion()
and vignetting()) are now interpreted as cell vertices, and the rays of
the system are traced at the corresponding cell centers, so that the
inputs of rayfunction_default and of the rayfunctions used by the
fitting methods are defined on cell vertices while the outputs are
defined on cell centers. This makes the system grids consistent with
the vertex convention already used by image(), enables area-weighted
methods such as the upcoming effective area calculation, and avoids
tracing rays exactly on the edges of the apertures.

raytrace() and rayfunction() keep their exact-sample-point semantics,
since image() passes precomputed cell centers with stratified random
offsets.

Migration note for downstream configurations: grids built with
na.*LinearSpace(..., centers=True) should drop centers=True and
increment num by one, which reproduces the previously traced rays
exactly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lm9SxSpyNg9hx8dNL9pUXc
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.33%. Comparing base (001b708) to head (6f31a3d).

Files with missing lines Patch % Lines
optika/systems/_sequential.py 87.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
- Coverage   99.37%   99.33%   -0.05%     
==========================================
  Files         116      116              
  Lines        6282     6302      +20     
==========================================
+ Hits         6243     6260      +17     
- Misses         39       42       +3     
Flag Coverage Δ
unittests 99.33% <87.50%> (-0.05%) ⬇️

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