-
Notifications
You must be signed in to change notification settings - Fork 74
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
Cubeviz image viewer coordinates display #1315
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1315 +/- ##
==========================================
- Coverage 83.56% 83.42% -0.15%
==========================================
Files 91 91
Lines 7576 7620 +44
==========================================
+ Hits 6331 6357 +26
- Misses 1245 1263 +18
Continue to review full report at Codecov.
|
Any chance this can be generalized (without too much effort) and moved to a Mixin that both cubeviz and imviz viewers inherit from (especially if adding the same to specviz is in our future)? It seems like a lot of the code is the same. |
Re: Refactoring -- I'd rather wait to see what needs to happen for #1299 first. |
Ok, do you want to move ahead with reviews on this as-is (ignoring refactoring) then and deal with that as a separate effort? Or should we put this PR on hold until 1299 is resolved? |
I'd prefer we move ahead as-is. Thanks! |
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'd prefer we move ahead as-is.
Ok, then let's refactor if/when we add to any other viz or when 1299 is resolved. I don't love the hit to coverage, but the interactive nature is difficult to test without more UI testing infrastructure. At least this is something that will be very obvious if it completely breaks (although very non-obvious if it just displays the wrong information). Is it possible to fake the data
sent to on_mouse_or_key_event
to at least make sure the value and a single known pixel is parsed correctly?
# Extract first dataset from visible layers and use this for coordinates - the choice | ||
# of dataset shouldn't matter if the datasets are linked correctly | ||
image = visible_layers[0].layer |
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.
how is visible_layers
ordered? If there are multiple layers and they're linked correctly, the coordinates shouldn't care what layer, but the value will... is this guaranteed to be the "top" layer if multiple layers are plotted without changing transparency? Is there any room to squeeze in the layer name for cases where visible_layers
includes more than one?
This behavior/situation might be something that is worth adding test coverage, if possible.
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.
The inner workings of visible layers, I'd have to defer to @astrofrog or @maartenbreddels. I wish there is an easier way for me to reliably grab this info too but then Glue lets you overlay this and that, which complicates things. This particular info panel would ignore the semi-transparent overlay use cases.
Re: tests -- the info panel is kinda tested non-interactively in https://github.com/spacetelescope/jdaviz/blob/main/jdaviz/configs/imviz/tests/test_linking.py (the label_mouseover
stuff). Not that the tests are exhaustive because they obviously missed #1299 but again adding a test for that would be out of scope here. Still, I guess I can add similar test(s) to Cubeviz...
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.
from trial and error, it seems that this does always show the "top" layer, which is the most sensible (simple) behavior. If there is any room, I do think a label would be useful, but will approve this and that can always be added later if you don't have time to include it in scope here (as I think the same thing could apply to the existing display in imviz).
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.
Re: label -- In Imviz, I incorporated that into Compass plugin (because the label just seems to go with Compass naturally). Originally when I was new and naive, I attempted glue-viz/glue-jupyter#244 but failed. I don't think there is any more space for label in the coordinates display, as it is already pretty crowded.
This does bring up a good point... What if someone deselects the cube and have a 2D moment map displayed in the cube viewer instead? Is that a use case we even support?
for Spectrum1D in Cubeviz. TST: Add Cubeviz coords info tests. DOC: Update change log.
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.
@kecnry , I added tests but might also have opened a small rabbit hole. Please re-review. Thanks!
app.add_data(spectrum1d_cube, 'test[FLUX]') | ||
app.add_data_to_viewer('flux-viewer', 'test[FLUX]') | ||
dc = cubeviz_helper.app.data_collection | ||
cubeviz_helper.load_data(spectrum1d_cube, data_label='test') |
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.
Since I am updating this test anyway, I took the liberty to make it more realistic in loading like a user would.
@@ -30,11 +28,20 @@ def test_moment_calculation(cubeviz_helper, spectrum1d_cube, tmpdir): | |||
assert mm.results_label_overwrite is True | |||
|
|||
result = dc[1].get_object(cls=CCDData) | |||
assert result.shape == (2, 4) # Cube shape is (2, 2, 4) | |||
assert result.shape == (4, 2) # Cube shape is (2, 2, 4) |
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.
But in changing from using app.add_data
to cubeviz_helper.load_data
, the moment map shape changed! @rosteen , since you refactored how Cubeviz swaps dimensions around, does this make sense to you?
@@ -75,9 +75,9 @@ def parse_data(app, file_obj, data_type=None, data_label=None): | |||
# into something glue can understand. | |||
elif isinstance(file_obj, Spectrum1D): | |||
if file_obj.flux.ndim == 3: | |||
_parse_spectrum1d_3d(app, file_obj) | |||
_parse_spectrum1d_3d(app, file_obj, data_label=data_label) |
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.
It is highly annoying to me that data_label
is ignored when you pass Spectrum1D
into Cubeviz, so I fixed it here. Unless there is a good reason not to do this? I cannot think of any good reason.
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.
Thank you for doing this! It's actually bothered me before but I guess not enough to add it 😅
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.
Looks good!
Description
This pull request is to add Imviz-like coordinates display for Cubeviz image viewers.
This is all UI so I am not sure how to add tests. There is currently no unit test for this equivalent capability in Imviz. Reviewers should interactively load a few different datasets that we are supposed to support and see what happens...
Here is a screenshot with data from Cubeviz example notebook (the mouse was at the center of flux viewer for this one):
Fixes #1090
Imviz's display was originally done by @astrofrog (e.g., #557).
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.CHANGES.rst
?