Skip to content

Commit

Permalink
Clear source field if autocoord viewer has no data
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed Jul 26, 2024
1 parent aebd564 commit 437d395
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,32 @@ class TestVOImvizLocal(BaseImviz_WCS_WCS):
def test_autocenter_coords(self):
"""
Loads two data products and checks the plugin correctly adjusts the automatically-derived
coordinates of the center of the viewer when the viewer dropdown is changed
coordinates of the center of the viewer when the viewer dropdown is changed.
Also verify changing autocoord to a blank viewer with no data properly empties the source
field.
"""
# Create a second viewer and put each data in its own viewer
# Create a second viewer and remove second dataset from first viewer to avoid ambiguity
self.imviz.create_image_viewer()
self.imviz.app.remove_data_from_viewer("imviz-0", "has_wcs_2[SCI,1]")
self.imviz.app.add_data_to_viewer("imviz-1", "has_wcs_2[SCI,1]")

# Check default viewer is "Manual"
vo_plugin = self.imviz.plugins[vo_plugin_label]._obj
assert vo_plugin.viewer_selected == "Manual"
assert vo_plugin.source == ''

# Switch to first viewer and verify coordinates have switched
vo_plugin.viewer_selected = "imviz-0"
ra_str, dec_str = vo_plugin.source.split()
assert_allclose(float(ra_str), self._data_center_coords['has_wcs_1[SCI,1]']['ra'])
assert_allclose(float(dec_str), self._data_center_coords['has_wcs_1[SCI,1]']['dec'])

# Switch to second viewer and verify coordinates
# Switch to second viewer without data and verify autocoord gracefully clears source field
vo_plugin.viewer_selected = "imviz-1"
assert vo_plugin.source == ''

# Now load second data into second viewer and verify coordinates
self.imviz.app.add_data_to_viewer("imviz-1", "has_wcs_2[SCI,1]")
ra_str, dec_str = vo_plugin.source.split()
assert_allclose(float(ra_str), self._data_center_coords['has_wcs_2[SCI,1]']['ra'])
assert_allclose(float(dec_str), self._data_center_coords['has_wcs_2[SCI,1]']['dec'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def _center_on_data(self, _=None):
viewer.state.reference_data is None
or viewer.state.reference_data.coords is None
):
self.source = ''
return

# Obtain center point of the current image and convert into sky coordinates
Expand Down

0 comments on commit 437d395

Please sign in to comment.