Skip to content

Commit

Permalink
Update ndcube/ndcube.py
Browse files Browse the repository at this point in the history
Co-authored-by: DanRyanIrish <[email protected]>
  • Loading branch information
nabobalis and DanRyanIrish authored Nov 22, 2024
1 parent 3b16c2e commit e1cb770
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ def _generate_world_coords(self, pixel_corners, wcs, needed_axes=None, *, units)
# This bypasses the entire rest of the function below which works out the full set of coordinates
# This only works for WCS that have the same number of world and pixel dimensions
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:
indices = [np.arange(self.data.shape[::-1][needed_axes[0]]) if wanted else [0] for wanted in wcs.axis_correlation_matrix[needed_axes][0]]
lims = (-0.5, self.data.shape[::-1][needed_axes[0]] + 1) if pixel_corners else (0, self.data.shape[::-1][needed_axes[0]])
indices = [np.arange(lims[0], lims[1]) if wanted else [0] for wanted in wcs.axis_correlation_matrix[needed_axes][0]]
world_coords = wcs.pixel_to_world_values(*indices)
if units:
world_coords = world_coords << u.Unit(wcs.world_axis_units[needed_axes[0]])
Expand Down

0 comments on commit e1cb770

Please sign in to comment.