diff --git a/CHANGES.rst b/CHANGES.rst index dee1aec2bc..5b995d3074 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -80,6 +80,8 @@ Imviz - Improved behavior when orientations are created or selected without having data loaded in the viewer. [#2789] +- Fixed a bug in the Orientation plugin where a WCS orientation could sometimes be flipped. [#2802] + Mosviz ^^^^^^ diff --git a/jdaviz/configs/imviz/tests/test_linking.py b/jdaviz/configs/imviz/tests/test_linking.py index 21e69bf24a..6734360c95 100644 --- a/jdaviz/configs/imviz/tests/test_linking.py +++ b/jdaviz/configs/imviz/tests/test_linking.py @@ -196,16 +196,21 @@ def test_wcslink_rotated(self): self.imviz.app.data_collection['fits_wcs[DATA]']) gwcs_zoom_limits = self.viewer._get_zoom_limits( self.imviz.app.data_collection['gwcs[DATA]']) + + # x_min, y_min + # x_min, y_max + # x_max, y_max + # x_max, y_min assert_allclose(fits_wcs_zoom_limits, - [[-1.590838, -0.423662], - [-1.826862, 9.896219], - [8.590838, 9.423662], - [8.826862, -0.896219]], rtol=1e-5) + [[-2.406711, -1.588057], + [-2.697746, 11.137127], + [10.148055, 10.554429], + [10.439091, -2.170755]], rtol=1e-5) assert_allclose(gwcs_zoom_limits, - [[3.186753, 11.337468], - [11.895862, 5.072343], - [6.158421, -3.145985], - [-2.550688, 3.119141]], rtol=1e-5) + [[2.636299, 12.732915], + [13.375281, 5.007547], + [6.300587, -5.126264], + [-4.438394, 2.599103]], rtol=1e-5) # Also check the coordinates display: Last loaded is on top. # Cycle order: GWCS, FITS WCS diff --git a/jdaviz/core/freezable_state.py b/jdaviz/core/freezable_state.py index 3fb1d0a1c0..a2b258923e 100644 --- a/jdaviz/core/freezable_state.py +++ b/jdaviz/core/freezable_state.py @@ -167,13 +167,18 @@ def _get_reset_limits(self, return_as_world=False): y_min = min(y_min, world_bottom_left.dec.value) y_max = max(y_max, world_top_right.dec.value) else: - pixel_bottom_left = self.reference_data.coords.world_to_pixel(world_bottom_left) - pixel_top_right = self.reference_data.coords.world_to_pixel(world_top_right) - - x_min = min(x_min, pixel_bottom_left[0] - 0.5) - x_max = max(x_max, pixel_top_right[0] + 0.5) - y_min = min(y_min, pixel_bottom_left[1] - 0.5) - y_max = max(y_max, pixel_top_right[1] + 0.5) + x_bl, y_bl = self.reference_data.coords.world_to_pixel(world_bottom_left) + x_tr, y_tr = self.reference_data.coords.world_to_pixel(world_top_right) + + x_pix_min = min(x_bl, x_tr) + x_pix_max = max(x_bl, x_tr) + y_pix_min = min(y_bl, y_tr) + y_pix_max = max(y_bl, y_tr) + + x_min = min(x_min, x_pix_min - 0.5) + x_max = max(x_max, x_pix_max + 0.5) + y_min = min(y_min, y_pix_min - 0.5) + y_max = max(y_max, y_pix_max + 0.5) wcs_success = True if not wcs_success: