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')