-
Notifications
You must be signed in to change notification settings - Fork 76
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
lcviz cube support #2678
Merged
Merged
lcviz cube support #2678
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a1eb402
lcviz-case for cube mouseover
kecnry 7857649
stretch histogram - use layer attribute instead of assuming first
kecnry 1aa435b
handle data menu visibility for TPF cubes vs light curves
kecnry f121f04
remove tpf until finalized in lcviz
kecnry f1d643a
rename tpf > image
kecnry 1989b85
refactor coords info so downstream can override
kecnry c6d0f2d
clarify ix_shape/iy_shape in comments
kecnry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,24 @@ def update_display(self, viewer, x, y): | |
(ImvizImageView, CubevizImageView, MosvizImageView, MosvizProfile2DView)): | ||
self._image_viewer_update(viewer, x, y) | ||
|
||
def _image_shape_inds(self, image): | ||
if image.ndim == 3: | ||
# cubeviz case | ||
return (0, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would prefer you keep the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clarified with inline comments |
||
elif image.ndim == 2: | ||
return (1, 0) | ||
else: # pragma: no cover | ||
raise ValueError(f'does not support ndim={image.ndim}') | ||
|
||
def _get_cube_value(self, image, arr, x, y, viewer): | ||
if image.ndim == 3: | ||
# cubeviz case: | ||
return arr[int(round(x)), int(round(y)), viewer.state.slices[-1]] | ||
elif image.ndim == 2: | ||
return arr[int(round(y)), int(round(x))] | ||
else: # pragma: no cover | ||
raise ValueError(f'does not support ndim={image.ndim}') | ||
|
||
def _image_viewer_update(self, viewer, x, y): | ||
# Display the current cursor coordinates (both pixel and world) as | ||
# well as data values. For now we use the first dataset in the | ||
|
@@ -406,15 +424,7 @@ def _image_viewer_update(self, viewer, x, y): | |
|
||
# Extract data values at this position. | ||
# Check if shape is [x, y, z] or [y, x] and show value accordingly. | ||
if image.ndim == 3: | ||
# needed for cubeviz | ||
ix_shape = 0 | ||
iy_shape = 1 | ||
elif image.ndim == 2: | ||
ix_shape = 1 | ||
iy_shape = 0 | ||
else: # pragma: no cover | ||
raise ValueError(f'does not support ndim={image.ndim}') | ||
ix_shape, iy_shape = self._image_shape_inds(image) | ||
|
||
if (-0.5 < x < image.shape[ix_shape] - 0.5 and -0.5 < y < image.shape[iy_shape] - 0.5 | ||
and hasattr(active_layer, 'attribute')): | ||
|
@@ -425,10 +435,7 @@ def _image_viewer_update(self, viewer, x, y): | |
elif isinstance(viewer, CubevizImageView): | ||
arr = image.get_component(attribute).data | ||
unit = image.get_component(attribute).units | ||
if image.ndim == 3: | ||
value = arr[int(round(x)), int(round(y)), viewer.state.slices[-1]] | ||
else: # 2 | ||
value = arr[int(round(y)), int(round(x))] | ||
value = self._get_cube_value(image, arr, x, y, viewer) | ||
self.row1b_title = 'Value' | ||
self.row1b_text = f'{value:+10.5e} {unit}' | ||
self._dict['value'] = float(value) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really equivalent to
main_component[0]
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but I think its what we actually want. Shouldn't this always be the plotted data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno. Further down, there is a block that calls
data.get_component
under some condition. Will that still be consistent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That logic probably also could use rewriting to be more specific as well (currently only applies to 2d spectral viewers, afaik), but should not affect this at all (that is for the x-y limit determination, this is for the actual "color" axis of the image which is what should be plotted on the histogram). Feel free to find a case that breaks if you have any concerns!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not expert in Plot Options, so this is fine. I won't do this to, say, aperture photometry though, but that is irrelevant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layer.state.attribute
is the requested column to be plotted,data.main_components[0]
is just the first "main" component (which probably is the default column to be plotted, but is not general enough). For the histogram, we definitely want to plot the same data in the histogram as is shown in the image viewer itself, so I think the previous assumption is not general enough.