Fix transposed axes in make_image_interpolations - #984
Merged
Conversation
RectBivariateSpline was constructed with x = arange(NAXIS1) and y = arange(NAXIS2) against data of shape (NAXIS2, NAXIS1), which raises ValueError for any non-square image. It went unnoticed because current detector images are square and the caller in SpectralTrace.rectify compensates by passing (j, i) swapped. Build the spline with axes matching the data layout instead; the (j, i) call convention used by rectify and existing tests is now correct by construction and documented. Results on square images are unchanged. Adds a non-square regression test.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #984 +/- ##
=======================================
Coverage 76.50% 76.50%
=======================================
Files 69 69
Lines 9062 9062
=======================================
Hits 6933 6933
Misses 2129 2129 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
make_image_interpolations
astronomyk
marked this pull request as ready for review
August 24, 2026 12:43
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.
Yet again, just a bit of clean up of a latent bug that has not yet bitten.
TL;DR - aligns the
RectBivariateSplineshape to the axis convention of.rectifyNAXIS1, NAXIS2 --> NAXIS2, NAXIS1inspectral_trace_list_utils.pyFrom the below mentioned testing notebook:
old construction raises: x dimension of z must have same number of elements as xWhat
make_image_interpolationsconstructed its splines asRectBivariateSpline(arange(NAXIS1), arange(NAXIS2), hdu.data)— axes transposed relative to the data shape(NAXIS2, NAXIS1). For any non-square image this raisesIt has gone unnoticed because the detector images we currently rectify are square (2048x2048), and because the caller in
SpectralTrace.rectifycompensates by evaluating with swapped arguments,interps[ihdu](jarr, iarr).The spline is now built with axes matching the data layout, so the
(j, i)call convention used byrectify(and by the existing accuracy test) is correct by construction; the convention is documented in the docstring. Results on square images are bit-identical.Testing
TestImageInterpolations::test_works_with_non_square_image(80x50 image), mirroring the existing accuracy test.