Skip to content

Add optika.vignetting.PolynomialVignettingModel#155

Merged
roytsmart merged 3 commits into
mainfrom
feature/polynomial-vignetting
May 31, 2026
Merged

Add optika.vignetting.PolynomialVignettingModel#155
roytsmart merged 3 commits into
mainfrom
feature/polynomial-vignetting

Conversation

@roytsmart
Copy link
Copy Markdown
Collaborator

Summary

Adds the optika.vignetting subpackage for mapping scene coordinates (wavelength + field position) to the fraction of light transmitted by the optical system. Mirrors the structure of optika.distortion (#154).

  • AbstractVignettingModel — defines the __call__(coordinates) -> scalar interface (the transmitted fraction) plus an inverse(coordinates) helper returning 1 / transmission (the vignetting-correction factor). inverse is defined on the abstract base since it only depends on the forward call.
  • AbstractInterpolatedVignettingModel — adds the calibration-point interface (coordinates_scene, transmission, axis_wavelength, axis_field).
  • PolynomialVignettingModel — fits a mean-centered polynomial to the measured transmission (center = scene.mean(axis_scene)), exposed via the public fit cached property, and provides plot_residual() to visualize the absolute fit residual vs. field angle with a subplot per wavelength (auto-sized figure, figsize/cmap/vmin/vmax arguments).

Registers the subpackage in optika/__init__.py.

Testing

  • pytest optika/vignetting/_vignetting_test.py — 22 passed (call, inverse, fit, properties, and plot_residual across degree ∈ {1, 2}).
  • 100% coverage on the new module; black --check and ruff check clean.

🤖 Generated with Claude Code

Introduce the `optika.vignetting` subpackage, which maps scene
coordinates (wavelength + field position) to the fraction of light
transmitted by the optical system:

- `AbstractVignettingModel` defines the `__call__` interface and an
  `inverse` (1 / transmission) helper.
- `AbstractInterpolatedVignettingModel` adds the calibration-point
  interface (`coordinates_scene`, `transmission`, axes).
- `PolynomialVignettingModel` fits a mean-centered polynomial to the
  measured transmission, exposed via the public `fit` property, and
  provides `plot_residual()` to visualize the fit residual vs. field
  angle with a subplot per wavelength.

Register the subpackage in `optika/__init__.py` and add tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.31%. Comparing base (2a2fe34) to head (d285ab7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
+ Coverage   99.29%   99.31%   +0.01%     
==========================================
  Files         111      114       +3     
  Lines        5537     5675     +138     
==========================================
+ Hits         5498     5636     +138     
  Misses         39       39              
Flag Coverage Δ
unittests 99.31% <100.00%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

roytsmart and others added 2 commits May 30, 2026 18:32
Plot the calibration transmission as a function of field angle (one
subplot per wavelength), mirroring `plot_residual`. Factor the shared
plotting machinery into a private `_plot` helper used by both methods,
and demonstrate `plot()` in the class example.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Make `AbstractVignettingModel.__call__`/`inverse` accept
`na.SpectralPositionalVectorArray` instead of `optika.vectors.SceneVectorArray`,
matching the distortion models so scene coordinates share one named-arrays
vector type across both. Updates the example, plots, and tests accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@roytsmart roytsmart merged commit 4b67d7f into main May 31, 2026
12 checks passed
@roytsmart roytsmart deleted the feature/polynomial-vignetting branch May 31, 2026 18:23
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