Skip to content

Commit 44c6d03

Browse files
CadairDanRyanIrish
andcommitted
Fix ResampledLowLevelWCS pixel space conversions
Co-authored-by: Dan Ryan <ryand5@tcd.ie>
1 parent 9d2badc commit 44c6d03

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ndcube/wcs/wrappers/resampled_wcs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import numpy as np
23

34
from astropy.wcs.wcsapi.wrappers.base import BaseWCSWrapper
@@ -42,13 +43,13 @@ def _top_to_underlying_pixels(self, top_pixels):
4243
# Convert user-facing pixel indices to the pixel grid of underlying WCS.
4344
factor = self._pad_dims(self._factor, top_pixels.ndim)
4445
offset = self._pad_dims(self._offset, top_pixels.ndim)
45-
return (top_pixels + factor/2) * factor + offset
46+
return (top_pixels * factor) + 1 + offset
4647

4748
def _underlying_to_top_pixels(self, underlying_pixels):
4849
# Convert pixel indices of underlying pixel grid to user-facing grid.
4950
factor = self._pad_dims(self._factor, underlying_pixels.ndim)
5051
offset = self._pad_dims(self._offset, underlying_pixels.ndim)
51-
return (underlying_pixels - offset) / factor
52+
return (underlying_pixels - 1 - offset) / factor
5253

5354
def _pad_dims(self, arr, ndim):
5455
# Pad array with trailing degenerate dimensions.

0 commit comments

Comments
 (0)