Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vector directions when overlaid on image #2276

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions glue/viewers/scatter/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down