Conversation
NDCube.rebin resampled lookup-table extra coords with offset 0, so they
were sampled at the first pixel of each bin (0, 2, 4) while the rebinned
WCS describes the bin centres (0.5, 2.5, 4.5). Pass a bin-centre offset
for lookup tables; WCS-backed extra coords keep the pixel-edge offset
that ResampledLowLevelWCS expects. test_rebin already expected the
bin-centre times, but np.allclose's default rtol on MJD values (about
half a day) hid the error, so tighten it.
ExtraCoords.resample also packed the new grids into an object array,
which numpy turns into a 2-D object array when all grids have the same
length, so rebinning a 1-D cube, or any cube whose axes all have the
same length after rebinning, raised "Cannot cast array data from
dtype('O')". Keep the grids in a list.
TimeTableCoordinate.interpolate interpolated absolute MJD floats,
quantising times to ~0.6 us, and dropped reference_time. Interpolate
second offsets from the first time and keep reference_time.
Split out of sunpy#967; none of this depends on N-D lookup tables.
QuantityTableCoordinate always holds a mesh of 1-D tables and interpolates each table along its own grid, but interpolate still required every grid to have the same shape. So NDCube.rebin raised "New array grids must all be same shape" for a Quantity lookup table spanning several axes whose lengths differ after rebinning. Drop the check.
This branch has not been deployed
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.
PR Description
NDCube.rebin had three problems with lookup-table extra coords:
They were resampled with offset=0, so each new pixel got the value at the first pixel of its bin, while the rebinned WCS gives the bin centre. rebin now passes (bin_shape - 1) / 2 for lookup tables. WCS-backed extra coords keep 0, because ResampledLowLevelWCS treats the offset as a shift of the pixel edge. Nothing public tells the two apart, so this checks the private _lookup_tables.
ExtraCoords.resample put the new grids in an object array. When they all have the same length (every 1-D cube, for example), numpy makes a 2-D object array and np.interp raises TypeError. They are now a list.
TimeTableCoordinate.interpolate interpolated absolute MJD floats (about 0.6 µs resolution for current dates) and dropped reference_time. It now interpolates seconds from the first time and keeps reference_time.
main:
this branch:
AI Assistance Disclosure
AI tools were used for:
K.