Skip to content

Commit

Permalink
Add support for radius units
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed Sep 11, 2024
1 parent ea2562e commit 783262a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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:
Expand Down
26 changes: 18 additions & 8 deletions jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,24 @@

<j-plugin-section-header>Common Options</j-plugin-section-header>

<v-row>
<v-text-field
v-model.number="radius_deg"
type="number"
label="Radius"
hint="Angular radius, in degrees, around source coordinates, within which to query for data (Default 1 degree)"
persistent-hint>
</v-text-field>
<v-row justify="space-between">
<div :style="{ width: '55%' }">
<v-text-field
v-model.number="radius_val"
type="number"
label="Radius"
hint="Angular radius around source coordinates, within which to query for data (Default 1 degree)"
persistent-hint>
</v-text-field>
</div>
<div :style="{ width: '40%' }">
<v-select
v-model="radius_unit"
attach
:items="['deg', 'rad', 'arcmin', 'arcsec']"
label="Unit">
</v-select>
</div>
</v-row>


Expand Down

0 comments on commit 783262a

Please sign in to comment.