Vectorise the wavelength resampling in XiLamImage - #989
Draft
astronomyk wants to merge 1 commit into
Draft
Conversation
The per-eta loop built a full 2D RectBivariateSpline over each cube plane and evaluated it exactly at the xi knot positions, i.e. the spline degenerated to independent 1D linear interpolation along the wavelength axis. Replace it with a direct searchsorted-based linear interpolation over all xi rows at once. Out-of-range wavelengths are clamped to the boundary values, exactly as the degree-1 spline did. For a METIS LSS field of view this removes ~1.7 s of spline construction per FieldOfView; for METIS LMS the loop runs 28 times per observation. Adds an equivalence test against the previous spline-based computation on random cube data (including the clamped edge region). The full basic_instrument spectroscopy/ifu suite passes unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #989 +/- ##
=======================================
Coverage 76.46% 76.46%
=======================================
Files 69 69
Lines 9025 9026 +1
=======================================
+ Hits 6901 6902 +1
Misses 2124 2124 ☔ 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.
What
For every spatial row across the slit width (eta), the
XiLamImageconstructor built a full 2-DRectBivariateSplineover the cube plane — and then evaluated it exactly at the xi grid points, so the spline degenerated to plain 1-D linear interpolation along the wavelength axis.The loop now interpolates directly, vectorised over all xi rows at once (
searchsorted-based gather). Out-of-range wavelengths are clamped to the boundary values — exactly what a degree-1RectBivariateSplinedoes (verified: FITPACK clamps, it does not extrapolate).Measured on the cube of a real METIS LSS observation: 6.06 s -> 1.54 s per FieldOfView with max |difference| = 0.0; for METIS LMS the same construction runs 28 times per observation.
Testing
TestXiLamImage::test_image_matches_rect_bivariate_spline_reference— equivalence against the previous spline-per-row computation on random cube data, including the clamped edge region.