Evaluate the xi-lambda image with direct bilinear interpolation - #993
Draft
astronomyk wants to merge 1 commit into
Draft
Evaluate the xi-lambda image with direct bilinear interpolation#993astronomyk wants to merge 1 commit into
astronomyk wants to merge 1 commit into
Conversation
map_spectra_to_focal_plane evaluates the XiLamImage at every pixel of the detector sub-image through RectBivariateSpline(kx=ky=1) with grid=False. FITPACK's scattered-point evaluation is orders of magnitude slower than a direct bilinear lookup on the regular (xi, lam) grid: for a METIS long-slit trace this one call took ~3 s per FieldOfView. XiLamImage.interp is now a method that performs the bilinear interpolation directly, with identical semantics (including clamping of out-of-range coordinates); the call site is unchanged. Adds equivalence tests against RectBivariateSpline for scattered and grid evaluation, including points beyond the grid edges. 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 #993 +/- ##
==========================================
+ Coverage 76.47% 76.49% +0.02%
==========================================
Files 69 69
Lines 9027 9037 +10
==========================================
+ Hits 6903 6913 +10
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
map_spectra_to_focal_planeevaluates the rectified (xi, lambda) spectrum at every pixel of the detector sub-image throughRectBivariateSpline(kx=ky=1)withgrid=False. FITPACK's scattered-point evaluation path is very slow for large coordinate arrays: for a METIS long-slit trace this single call took ~3 s per FieldOfView.XiLamImage.interpis now a method performing the bilinear interpolation directly on the regular (xi, lambda) grid — identical semantics forkx=ky=1, including the clamping of out-of-range coordinates, for bothgrid=Falseandgrid=True. The call site is unchanged, and the spline attribute no longer needs to be built eagerly in the constructor.Measured on the rectified spectrum of a real METIS LSS observation: 3.77 s -> 1.46 s for 1.4M evaluation points (the isolated microbenchmark difference is considerably larger for bigger sub-images).
Testing
TestXiLamImage::test_interp_matches_rect_bivariate_spline— equivalence againstRectBivariateSplinefor scattered and grid evaluation, including points beyond the grid edges.Note: includes the same 3-line
MockCubeFov(data=...)test-helper extension as #989; the two merge cleanly in either order.