From 31327bf387e826ec7ac0044cf8d361ff222e7e1e Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Wed, 8 Sep 2021 17:46:25 -0400 Subject: [PATCH] Mosviz: Slit overlay to use Data WCS --- .../configs/mosviz/plugins/slit_overlay/slit_overlay.py | 8 +++----- setup.cfg | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py b/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py index 4cdeb98cb0..7ab2f77588 100644 --- a/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py +++ b/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py @@ -9,7 +9,6 @@ from regions import RectangleSkyRegion from astropy.coordinates import Angle, SkyCoord from astropy import units as u -from astropy.wcs import WCS import bqplot @@ -78,11 +77,11 @@ def place_slit_overlay(self, *args, **kwargs): self.remove_slit_overlay() # Get data from relevant viewers - image_data = self.app.get_viewer("image-viewer").data() + image_data = self.app.get_viewer("image-viewer").state.reference_data spec2d_data = self.app.get_viewer("spectrum-2d-viewer").data() # 'S_REGION' contains slit information. Bypass in case no images exist. - if len(image_data) > 0: + if image_data is not None: # Only use S_REGION for Nirspec data, turn the plugin off # if other data is loaded if (len(spec2d_data) > 0 and 'S_REGION' in spec2d_data[0].meta @@ -91,8 +90,7 @@ def place_slit_overlay(self, *args, **kwargs): sky_region = jwst_header_to_skyregion(header) # Use wcs of image viewer to scale slit dimensions correctly - wcs_image = WCS(image_data[0].meta) - pixel_region = sky_region.to_pixel(wcs_image) + pixel_region = sky_region.to_pixel(image_data.coords) # Create polygon region from the pixel region and set vertices pix_rec = pixel_region.to_polygon() diff --git a/setup.cfg b/setup.cfg index 59c3e91865..4e6a883628 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,7 +53,7 @@ docs = sphinx-astropy all = scikit-image - regions + regions>=0.5 photutils [options.package_data]