From 9bbdf0945e11259bc063542aa13a156d6b513afe Mon Sep 17 00:00:00 2001 From: Jon Carifio Date: Fri, 11 Feb 2022 17:27:42 -0500 Subject: [PATCH] If a scatter layer artist is overlaid onto an image, check the relative axis orientations and adjust accordingly. --- glue/viewers/scatter/layer_artist.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/glue/viewers/scatter/layer_artist.py b/glue/viewers/scatter/layer_artist.py index 12585a3b6..6aff2cc6f 100644 --- a/glue/viewers/scatter/layer_artist.py +++ b/glue/viewers/scatter/layer_artist.py @@ -277,6 +277,18 @@ def _update_data(self): vx = ensure_numerical(self.layer[self.state.vx_att].ravel()) vy = ensure_numerical(self.layer[self.state.vy_att].ravel()) + # If this is being overlaid on an image viewer with a WCS, + # we need to check the relative orientations of the pixel/world axes + if getattr(self.axes, 'wcs', None) is not None: + cdelt = self.axes.wcs.wcs.get_cdelt() + ndim = self._viewer_state.reference_data.ndim + x_index = ndim - self._viewer_state.x_att.axis - 1 + y_index = ndim - self._viewer_state.y_att.axis - 1 + if cdelt[x_index] < 0: + vx = np.negative(vx) + if cdelt[y_index] < 0: + vy = np.negative(vy) + if self.state.vector_mode == 'Polar': ang = vx length = vy