Skip to content

Commit

Permalink
Merge pull request #1326 from javerbukh/coords-hotfix
Browse files Browse the repository at this point in the history
Allow cubeviz image viewer to display coords for 2D data
  • Loading branch information
pllim authored May 18, 2022
2 parents 3516b14 + ce25f7f commit 9213765
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions jdaviz/configs/cubeviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ def on_mouse_or_key_event(self, data):
self.label_mouseover.reset_coords_display()

# Extract data values at this position.
# Assume shape is [x, y, z] and not [y, x] like Imviz.
if (x > -0.5 and y > -0.5
and x < image.shape[0] - 0.5 and y < image.shape[1] - 0.5
# Check if shape is [x, y, z] or [x, y] and show value accordingly.
if (-0.5 < x < image.shape[0] - 0.5 and -0.5 < y < image.shape[1] - 0.5
and hasattr(visible_layers[0], 'attribute')):
attribute = visible_layers[0].attribute
value = image.get_data(attribute)[int(round(x)), int(round(y)),
self.state.slices[-1]]
if len(image.shape) == 3:
value = image.get_data(attribute)[int(round(x)), int(round(y)),
self.state.slices[-1]]
elif len(image.shape) == 2:
value = image.get_data(attribute)[int(round(x)), int(round(y))]

unit = image.get_component(attribute).units
self.label_mouseover.value = f'{value:+10.5e} {unit}'
else:
Expand Down

0 comments on commit 9213765

Please sign in to comment.