From 783262a1aa7ba0a0cb3733f858dcb59c9be4142c Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Wed, 11 Sep 2024 16:51:36 -0400 Subject: [PATCH] Add support for radius units --- .../tests/test_vo_imviz.py | 6 +++-- .../plugins/virtual_observatory/vo_plugin.py | 14 +++++++--- .../plugins/virtual_observatory/vo_plugin.vue | 26 +++++++++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/jdaviz/configs/default/plugins/virtual_observatory/tests/test_vo_imviz.py b/jdaviz/configs/default/plugins/virtual_observatory/tests/test_vo_imviz.py index c981c7814f..e0fa8f7f82 100644 --- a/jdaviz/configs/default/plugins/virtual_observatory/tests/test_vo_imviz.py +++ b/jdaviz/configs/default/plugins/virtual_observatory/tests/test_vo_imviz.py @@ -216,7 +216,8 @@ def _init_voplugin_M51(self, imviz_helper): # Sets common args for Remote Testing vo_plugin.viewer_selected = "Manual" vo_plugin.source = "M51" - vo_plugin.radius = 1 + vo_plugin.radius_val = 1 + vo_plugin.radius_unit = "deg" vo_plugin.waveband_selected = "optical" return vo_plugin @@ -287,7 +288,8 @@ def test_target_lookup_warnings(self, imviz_helper): # Manually set the source to a fake target vo_plugin.viewer_selected = "Manual" vo_plugin.source = "ThisIsAFakeTargetThatWontResolveToAnything" - vo_plugin.radius = 1 + vo_plugin.radius_val = 1 + vo_plugin.radius_unit = "deg" # If we have coverage filtering on, we should get an error vo_plugin.resource_filter_coverage = True diff --git a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py index d2602b3107..0fe121649b 100644 --- a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py +++ b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py @@ -48,7 +48,8 @@ class VoPlugin(PluginTemplateMixin, AddResultsMixin, TableMixin): source = Unicode("").tag(sync=True) coordframes = List([]).tag(sync=True) coordframe_selected = Unicode("icrs").tag(sync=True) - radius_deg = Float(1).tag(sync=True) + radius_val = Float(1).tag(sync=True) + radius_unit = Unicode("deg").tag(sync=True) results_loading = Bool(False).tag(sync=True) data_loading = Bool(False).tag(sync=True) @@ -185,7 +186,10 @@ def vue_query_registry_resources(self, _=None): f"Unable to resolve source coordinates: {self.source}" ) registry_args.append( - registry.Spatial(coord, self.radius_deg, intersect="overlaps") + registry.Spatial( + (coord, (self.radius_val * u.Unit(self.radius_unit))), + intersect="overlaps", + ) ) self._full_registry_results = registry.search(*registry_args) self.resources = list(self._full_registry_results.getcolumn("short_name")) @@ -251,7 +255,11 @@ def vue_query_resource(self, _=None): # Once coordinate lookup is complete, search service using these coords. sia_results = sia_service.search( coord, - size=((self.radius_deg * u.deg) if self.radius_deg > 0.0 else None), + size=( + (self.radius_val * u.Unit(self.radius_unit)) + if self.radius_val > 0.0 + else None + ), format="image/fits", ) if len(sia_results) == 0: diff --git a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue index a020094241..adafdd558a 100644 --- a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue +++ b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue @@ -41,14 +41,24 @@ Common Options - - - + +
+ + +
+
+ + +