Skip to content

Commit

Permalink
Use UnitSelectPluginComponent for radius unit
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed Sep 12, 2024
1 parent 783262a commit 5742480
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _init_voplugin_M51(self, imviz_helper):
vo_plugin.viewer_selected = "Manual"
vo_plugin.source = "M51"
vo_plugin.radius_val = 1
vo_plugin.radius_unit = "deg"
vo_plugin.radius_unit.selected = "deg"
vo_plugin.waveband_selected = "optical"

return vo_plugin
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_target_lookup_warnings(self, imviz_helper):
vo_plugin.viewer_selected = "Manual"
vo_plugin.source = "ThisIsAFakeTargetThatWontResolveToAnything"
vo_plugin.radius_val = 1
vo_plugin.radius_unit = "deg"
vo_plugin.radius_unit.selected = "deg"

# If we have coverage filtering on, we should get an error
vo_plugin.resource_filter_coverage = True
Expand Down
13 changes: 10 additions & 3 deletions jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
AddResultsMixin,
TableMixin,
ViewerSelect,
UnitSelectPluginComponent,
)

__all__ = ["VoPlugin"]
Expand All @@ -49,7 +50,8 @@ class VoPlugin(PluginTemplateMixin, AddResultsMixin, TableMixin):
coordframes = List([]).tag(sync=True)
coordframe_selected = Unicode("icrs").tag(sync=True)
radius_val = Float(1).tag(sync=True)
radius_unit = Unicode("deg").tag(sync=True)
radius_unit_items = List().tag(sync=True)
radius_unit_selected = Unicode("deg").tag(sync=True)

results_loading = Bool(False).tag(sync=True)
data_loading = Bool(False).tag(sync=True)
Expand All @@ -60,6 +62,11 @@ def __init__(self, *args, **kwargs):
self, "viewer_items", "viewer_selected", manual_options=["Manual"]
)

self.radius_unit = UnitSelectPluginComponent(
self, items="radius_unit_items", selected="radius_unit_selected"
)
self.radius_unit.choices = ["deg", "rad", "arcmin", "arcsec"]

# Waveband properties to filter available registry resources
self.wavebands = [
w.lower() for w in vocabularies.get_vocabulary("messenger")["terms"]
Expand Down Expand Up @@ -187,7 +194,7 @@ def vue_query_registry_resources(self, _=None):
)
registry_args.append(
registry.Spatial(
(coord, (self.radius_val * u.Unit(self.radius_unit))),
(coord, (self.radius_val * u.Unit(self.radius_unit.selected))),
intersect="overlaps",
)
)
Expand Down Expand Up @@ -256,7 +263,7 @@ def vue_query_resource(self, _=None):
sia_results = sia_service.search(
coord,
size=(
(self.radius_val * u.Unit(self.radius_unit))
(self.radius_val * u.Unit(self.radius_unit.selected))
if self.radius_val > 0.0
else None
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
</div>
<div :style="{ width: '40%' }">
<v-select
v-model="radius_unit"
v-model="radius_unit_selected"
attach
:items="['deg', 'rad', 'arcmin', 'arcsec']"
:items="radius_unit_items.map(i => i.label)"
label="Unit">
</v-select>
</div>
Expand Down

0 comments on commit 5742480

Please sign in to comment.