Skip to content

Retype distortion models to SpectralPositionalVectorArray#156

Merged
roytsmart merged 1 commit into
mainfrom
feature/distortion-spectral-positional
May 31, 2026
Merged

Retype distortion models to SpectralPositionalVectorArray#156
roytsmart merged 1 commit into
mainfrom
feature/distortion-spectral-positional

Conversation

@roytsmart
Copy link
Copy Markdown
Collaborator

Summary

Changes the optika.distortion model I/O from optika.vectors.SceneVectorArray to na.SpectralPositionalVectorArray, so scene and sensor coordinates share a single named-arrays vector type.

  • AbstractDistortionModel.distort/undistort now take and return na.SpectralPositionalVectorArray (abstract return type na.AbstractSpectralPositionalVectorArray); coordinates_sensor stays Cartesian2dVectorArray.
  • PolynomialDistortionModel.fit feeds coordinates_scene directly into PolynomialFitFunctionArray (the scene vector already exposes wavelength/position.x/position.y as polynomial components), and undistort returns a SpectralPositionalVectorArray.

Motivation

ctis (which sits above optika, like esis) implements the same scene→sensor forward model in ctis.instruments.IdealInstrument and already uses na.SpectralPositionalVectorArray for both scene and sensor coordinates. Standardizing optika's distortion model on the same named-arrays type lets ctis and optika.systems.AbstractInterpolatedSystem reuse these models without repackaging coordinates between SceneVectorArray and SpectralPositionalVectorArray.

Testing

  • pytest optika/distortion/_distortion_test.py — 26 passed (distort/undistort/round-trip, fit, and plot_residual across degree ∈ {1, 2}).
  • 100% coverage on the module; black --check and ruff check clean.

🤖 Generated with Claude Code

Make `AbstractDistortionModel.distort`/`undistort` accept and return
`na.SpectralPositionalVectorArray` instead of `optika.vectors.SceneVectorArray`,
so the scene and sensor coordinates share one named-arrays vector type.

`PolynomialDistortionModel` now feeds `coordinates_scene` directly into the
fit (the scene vector already exposes `wavelength`/`position` as polynomial
components), and `undistort` returns a `SpectralPositionalVectorArray`. This
also lets downstream consumers (e.g. `AbstractInterpolatedSystem`, and
`ctis` instruments) call the model without repackaging coordinates.

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.29%. Comparing base (2a2fe34) to head (35087f4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
- Coverage   99.29%   99.29%   -0.01%     
==========================================
  Files         111      111              
  Lines        5537     5533       -4     
==========================================
- Hits         5498     5494       -4     
  Misses         39       39              
Flag Coverage Δ
unittests 99.29% <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 roytsmart merged commit 88989a1 into main May 31, 2026
12 checks passed
@roytsmart roytsmart deleted the feature/distortion-spectral-positional branch May 31, 2026 17:59
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