From 33a8b7e4b88d792da509cce2a77f7454ab0ede0f Mon Sep 17 00:00:00 2001 From: "Pey Lian Lim (Github)" <2090236+pllim@users.noreply.github.com> Date: Sun, 24 Jul 2022 12:46:23 -0400 Subject: [PATCH] WIP: Cunning plan not so cunning [ci skip] --- .../plugins/aper_phot_simple/aper_phot_simple.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py b/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py index fdc7711430..fb48110fc1 100644 --- a/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py +++ b/jdaviz/configs/imviz/plugins/aper_phot_simple/aper_phot_simple.py @@ -140,9 +140,18 @@ def _get_region_from_subset(self, subset): if subset_grp.label == subset: for sbst in subset_grp.subsets: if sbst.data.label == self.dataset_selected: - # TODO: https://github.com/glue-viz/glue-astronomy/issues/52 - return sbst.data.get_selection_definition( - subset_id=subset, format='astropy-regions') + reg = sbst.data.get_selection_definition( + subset_id=subset, format='astropy-regions') + # Works around https://github.com/glue-viz/glue-astronomy/issues/52 + # Assume it is always pixel region, not sky region. + # FIXME: I thought this was a cunning plan but now I remember this plugin + # is viewer agnostic because of Ori, so I need to think of a viewer + # agnostic way to do this; or just disallow this plugin when WCS linking is detected? + x, y, _ = viewer._get_real_xy(self.app.data_collection[self.dataset_selected], + reg.center.x, reg.center.y) + reg.center.x = x + reg.center.y = y + return reg else: raise ValueError(f'Subset "{subset}" not found')