Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Nov 24, 2021
1 parent d043cc4 commit 870d92b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 20 deletions.
28 changes: 26 additions & 2 deletions jdaviz/configs/imviz/plugins/coords_info/coords_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@
class CoordsInfo(TemplateMixin):
template_file = __file__, "coords_info.vue"
pixel = Unicode("").tag(sync=True)
world = Unicode("").tag(sync=True)
world_deg = Unicode("").tag(sync=True)
value = Unicode("").tag(sync=True)
world_ra = Unicode("").tag(sync=True)
world_dec = Unicode("").tag(sync=True)
world_ra_deg = Unicode("").tag(sync=True)
world_dec_deg = Unicode("").tag(sync=True)

def reset_coords_display(self):
self.world_ra = ''
self.world_dec = ''
self.world_ra_deg = ''
self.world_dec_deg = ''

def set_coords(self, sky):
celestial_coordinates = sky.to_string('hmsdms', precision=4, pad=True).split()
celestial_coordinates_deg = sky.to_string('decimal', precision=10, pad=True).split()
world_ra = celestial_coordinates[0]
world_dec = celestial_coordinates[1]
world_ra_deg = celestial_coordinates_deg[0]
world_dec_deg = celestial_coordinates_deg[1]

if "nan" in (world_ra, world_dec, world_ra_deg, world_dec_deg):
self.reset_coords_display()
else:
self.world_ra = world_ra
self.world_dec = world_dec
self.world_ra_deg = world_ra_deg
self.world_dec_deg = world_dec_deg
26 changes: 21 additions & 5 deletions jdaviz/configs/imviz/plugins/coords_info/coords_info.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<template>
<div v-if="pixel" style="white-space: nowrap;">
<b v-if="pixel">Pixel </b>{{ pixel }}&nbsp;&nbsp;<b v-if="value">Value </b>{{ value }}<br>
<b v-if="world">World </b>{{ world }}<br>
<b v-if="world">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>{{ world_deg }}<br>
</div>
<div v-if="pixel" style="white-space: nowrap;">
<table>
<tr>
<td colspan="4">
<b v-if="pixel">Pixel </b>{{ pixel }}&nbsp;&nbsp;<b v-if="value">Value </b>{{ value }}
</td>
</tr>
<tr>
<td width="42"><b v-if="world_ra">World</b></td>
<td width="115">{{ world_ra }}</td>
<td width="120">{{ world_dec }}</td>
<td><div v-if="world_ra">(ICRS)</div></td>
</tr>
<tr>
<td width="42"></td>
<td width="115">{{ world_ra_deg }}</td>
<td width="120">{{ world_dec_deg }}</td>
<td><div v-if="world_ra">(deg)</div></td>
</tr>
</table>
</div>
</template>
18 changes: 5 additions & 13 deletions jdaviz/configs/imviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def on_mouse_or_key_event(self, data):

if x is None or y is None: # Out of bounds
self.label_mouseover.pixel = ""
self.label_mouseover.world = ""
self.label_mouseover.world_deg = ""
self.label_mouseover.reset_coords_display()
self.label_mouseover.value = ""
return

Expand All @@ -93,17 +92,11 @@ def on_mouse_or_key_event(self, data):
# with valid celestial WCS
try:
coo = image.coords.pixel_to_world(x, y).icrs
celestial_coordinates = coo.to_string('hmsdms', precision=4, pad=True)
celestial_coordinates_deg = coo.to_string('decimal', precision=12, pad=True)
self.label_mouseover.set_coords(coo)
except Exception:
self.label_mouseover.world = ''
self.label_mouseover.world_deg = ''
else:
self.label_mouseover.world = f'{celestial_coordinates:32s} (ICRS)'
self.label_mouseover.world_deg = f'{celestial_coordinates_deg} (deg)'
self.label_mouseover.reset_coords_display()
else:
self.label_mouseover.world = ''
self.label_mouseover.world_deg = ''
self.label_mouseover.reset_coords_display()

# Extract data values at this position.
# TODO: for now we just use the first visible layer but we should think
Expand All @@ -121,8 +114,7 @@ def on_mouse_or_key_event(self, data):
elif data['event'] == 'mouseleave' or data['event'] == 'mouseenter':

self.label_mouseover.pixel = ""
self.label_mouseover.world = ""
self.label_mouseover.world_deg = ""
self.label_mouseover.reset_coords_display()
self.label_mouseover.value = ""

elif data['event'] == 'keydown' and data['key'] == 'b':
Expand Down

0 comments on commit 870d92b

Please sign in to comment.