Skip to content

Commit e1cb770

Browse files
Update ndcube/ndcube.py
Co-authored-by: DanRyanIrish <ryand5@tcd.ie>
1 parent 3b16c2e commit e1cb770

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ndcube/ndcube.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ def _generate_world_coords(self, pixel_corners, wcs, needed_axes=None, *, units)
448448
# This bypasses the entire rest of the function below which works out the full set of coordinates
449449
# This only works for WCS that have the same number of world and pixel dimensions
450450
if not pixel_corners and needed_axes is not None and not isinstance(wcs, ExtraCoords) and np.sum(wcs.axis_correlation_matrix[needed_axes]) == 1 and len(self.data.shape) == wcs.world_n_dim:
451-
indices = [np.arange(self.data.shape[::-1][needed_axes[0]]) if wanted else [0] for wanted in wcs.axis_correlation_matrix[needed_axes][0]]
451+
lims = (-0.5, self.data.shape[::-1][needed_axes[0]] + 1) if pixel_corners else (0, self.data.shape[::-1][needed_axes[0]])
452+
indices = [np.arange(lims[0], lims[1]) if wanted else [0] for wanted in wcs.axis_correlation_matrix[needed_axes][0]]
452453
world_coords = wcs.pixel_to_world_values(*indices)
453454
if units:
454455
world_coords = world_coords << u.Unit(wcs.world_axis_units[needed_axes[0]])

0 commit comments

Comments
 (0)