Resample all LMS cube planes in one step - #995
Draft
astronomyk wants to merge 1 commit into
Draft
Conversation
The FieldOfView branch of MetisLMSSpectralTraceList.apply_to built a fresh RectBivariateSpline over the FoV plane for every wavelength plane of the cube and evaluated it at the slice coordinates. Those sample coordinates depend only on the slice geometry and are identical for every plane, so with thousands of planes and 28 slices this meant up to ~200k spline constructions per observation; in a profiled LMS run the loop accounted for the bulk of observe(). New module function interpolate_cube_planes computes the bilinear indices and weights once and gathers all planes in a single vectorised expression. Out-of-plane coordinates are clamped to the edges, exactly as RectBivariateSpline does. Adds an equivalence test against the per-plane spline evaluation, including coordinates beyond the plane edges.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #995 +/- ##
==========================================
+ Coverage 76.47% 76.51% +0.04%
==========================================
Files 69 69
Lines 9027 9032 +5
==========================================
+ Hits 6903 6911 +8
+ Misses 2124 2121 -3 ☔ 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
The FieldOfView branch of
MetisLMSSpectralTraceList.apply_tobuilt a freshRectBivariateSpline(kx=1, ky=1)over the field-of-view plane for every wavelength plane of the cube and evaluated it at the slice's(yfov, xfov)coordinates. Those sample coordinates depend only on the slice geometry — they are identical for every plane — so with ~2,500–7,000 planes (depending on!SIM.spectral.spectral_bin_width) and 28 slices this meant up to ~200,000 spline constructions per observation. In a profiled LMS run this loop accounted for the bulk ofobserve().The new module function
interpolate_cube_planes(fovcube, yfov, xfov)computes the bilinear indices and weights once per slice and gathers all planes in a single vectorised expression. Coordinates outside the plane are clamped to the edges, exactly asRectBivariateSplinedoes.End-to-end check (full
lmsmode, point source, identical inputs, separate processes):observe()wall time 386.5 s -> 108.6 s, with the detector image identical to the last digit (sum 1617362510.5459003, max 193.6031494140625 on both). The like-for-like loop comparison on one slice of the real cube is 10x (2.89 s -> 0.29 s, x28 slices per observation).Testing
TestInterpolateCubePlanes::test_matches_spline_per_plane_reference— exact equivalence against the per-plane spline evaluation on random data, including sample coordinates beyond the plane edges (clamping behaviour).