Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cubeviz image viewer to display coords for 2D data #1326

Merged
merged 1 commit into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))]
pllim marked this conversation as resolved.
Show resolved Hide resolved

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