Skip to content

Commit

Permalink
Merge pull request #850 from pllim/mosviz-i2d-one-image
Browse files Browse the repository at this point in the history
Mosviz: Slit overlay to use Data WCS
  • Loading branch information
rosteen authored Sep 14, 2021
2 parents a9236cf + 31327bf commit c306f98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ docs =
sphinx-astropy
all =
scikit-image
regions
regions>=0.5
photutils

[options.package_data]
Expand Down

0 comments on commit c306f98

Please sign in to comment.