From 9572b497a991d42600c01daf3dfa9a801382709d Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:54:39 -0400 Subject: [PATCH] Disallow pixel markers when linked by WCS and fix relevant test. --- jdaviz/configs/imviz/tests/test_linking.py | 7 ++++--- jdaviz/core/astrowidgets_api.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_linking.py b/jdaviz/configs/imviz/tests/test_linking.py index 3d1ac1c097..946ecb2ace 100644 --- a/jdaviz/configs/imviz/tests/test_linking.py +++ b/jdaviz/configs/imviz/tests/test_linking.py @@ -1,6 +1,7 @@ import pytest -from astropy.table import Table import astropy.units as u +from astropy.coordinates import SkyCoord +from astropy.table import Table from astropy.wcs import WCS from glue.core.link_helpers import LinkSame from glue.plugins.wcs_autolinking.wcs_autolinking import AffineLink, OffsetLink @@ -119,8 +120,8 @@ def test_wcslink_affine_with_extras(self): PolygonPixelRegion(vertices=PixCoord(x=[2, 3, 3], y=[2, 2, 3]))]) # Add markers. - tbl = Table({'x': (0, 0), 'y': (0, 1)}) - self.viewer.add_markers(tbl, marker_name='xy_markers') + tbl = Table({'coord': [SkyCoord(337.5203, -20.8333, unit="deg")]}) + self.viewer.add_markers(tbl, use_skycoord=True, marker_name='xy_markers') assert 'xy_markers' in self.imviz.app.data_collection.labels # linking shouldn't be possible now because astrowidgets creates a data entry diff --git a/jdaviz/core/astrowidgets_api.py b/jdaviz/core/astrowidgets_api.py index da6639a3af..4b0d35c457 100644 --- a/jdaviz/core/astrowidgets_api.py +++ b/jdaviz/core/astrowidgets_api.py @@ -473,6 +473,8 @@ def add_markers(self, table, x_colname='x', y_colname='y', jglue.data_collection[marker_name] = t_glue jglue.add_link(t_glue, 'ra', image, ra_str) jglue.add_link(t_glue, 'dec', image, dec_str) + elif self.jdaviz_app.config == "imviz" and self.jdaviz_app._link_type == "wcs": + raise TypeError("Cannot add markers in pixel space when linked by WCS.") else: t_glue = Data(marker_name, **table[x_colname, y_colname]) with jglue.data_collection.delay_link_manager_update():