-
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
Expose spectrum-viewer bounds in UI #2604
Expose spectrum-viewer bounds in UI #2604
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2604 +/- ##
==========================================
+ Coverage 91.52% 91.53% +0.01%
==========================================
Files 161 161
Lines 19995 20056 +61
==========================================
+ Hits 18300 18359 +59
- Misses 1695 1697 +2 ☔ View full report in Codecov by Sentry. |
lcviz doesn't have profile viewers, but it definitely would be nice for this to be able to work there. The only thing that I think needs to be disabled for now is image viewers (because we need to respect aspect ratio, which probably means setting the center and zoom level, or deciding to recompute limits that encompass the user-provided bounds, etc). |
I just tried this in Cubeviz and it works really well!! Thank you!! |
2b717e0
to
0560f05
Compare
@camipacifici Would you try this again, please? Due to some updates it now live updates the viewer bounds as you edit the fields, I want to check that that behavior is ok for this. |
I like it! Responds well. It's ok for me. |
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.
This looks good so far, just adding some comments now and i'll continue to test and review:
- a 'reset' button might be nice to have in the plugin. i know the home button will do the same thing but i think it would be nice to also have it here.
- display less decimal points?
- are there any consequences to having an empty entry for a boundary? you can delete one of the bounds entirely and if you click off it it doesn't snap back to its previous value or zero. this doesn't seem to matter but im not sure if the viewer limits are being used elsewhere and this could cause issues
@@ -753,14 +753,19 @@ def _update_viewer_bound_steps(self, msg={}): | |||
|
|||
viewer = self.viewer.selected_obj[0] if self.viewer_multiselect else self.viewer.selected_obj # noqa | |||
if not isinstance(viewer.state, ImageViewerState): | |||
# We round these values to show, e.g., 7.15 instead of 7.1499999 |
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.
this also limits the ability to zoom in to small wavelength ranges... I'm not sure that is worth 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.
maybe decimals
can be based on the current range instead?
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.
Changing this to depend on the difference between min and max rather than just max makes sense to me.
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 also prevents decreasing v_max
to be less than v_min
, which is nice.
Note that using |
bound_step = (viewer.state.x_max) / 100. | ||
decimals = -int(np.log10(bound_step))+1 | ||
bound_step = (viewer.state.x_max - viewer.state.x_min) / 100. | ||
decimals = -int(np.log10(bound_step)) + 1 |
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.
otherwise this can result in an OverflowError if bound_step == 0
(not sure what makes sense for the fallback, and will need to apply this to the case for y as well).
decimals = -int(np.log10(bound_step)) + 1 | |
decimals = -int(np.log10(bound_step)) + 1 if bound_step > 0 else 6 |
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 about just wrapping bound_step
in abs()
instead? I think we want that anyway now that I think about it - or are you thinking about a reverse axis case where the up arrow should decrease the value?
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.
We still need to handle the bound_step==0
case in which log10(0)
will resolve to -inf
and raise an error when casting to an integer.
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.
Honestly we should probably prevent min=max in general somewhere else, but for now I added this check.
# This button is currently only exposed if only the spectrum viewer is selected | ||
viewer = self.app.get_viewer('spectrum-viewer') |
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.
can we use the selected viewer reference directly instead of hardcoding for spectrum-viewer?
@@ -39,6 +39,64 @@ | |||
:hint="viewer_multiselect ? 'Select viewers to set options simultaneously' : 'Select the viewer to set options.'" | |||
/> | |||
|
|||
<v-row v-if="viewer_selected === 'spectrum-viewer' || (viewer_selected[0] === 'spectrum-viewer' && viewer_selected.length === 1)"> |
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.
this logic prevents this from being used in lcviz (and will conflict with any future support for renaming viewers). I think we should be able to rely on the info in the sync traitlets to determine whether this is applicable or not.
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 had worked on generalizing this and then reverted to just the initial scope of spectrum-viewer - I remember it was partially working for LCViz but something was messed up, don't remember exactly why I abandoned it. I can try that again now that some other things are resolved.
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.
does the logic have to be in python with an extra traitlet or can we just use the existing logic in the PlotOptionsSyncState
by doing v-if="viewer_x_min_sync.in_subscribed_states"
?
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 don't really know the details of what subscribed states is doing, so: maybe? 😆
I'll give it a try.
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.
Yeah, that doesn't stop the viewer bounds menu from showing up if you multiselect a spectrum viewer and an image viewer. So I think the way I have it now is necessary.
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 I think that's ok and consistent with how everything else works in plot options. Do the viewer numbers appear in mutliselect (if not, that might avoid any confusion).
@kecnry this now works in LCViz (as far as I tested anyway) and I also fixed a bug I noticed with the decimal rounding for large (>10) min/max separations. |
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.
this looks good and works well for me!
the only minor suggestion i have is that floats like (1., 2.) aren't accepted and i think it is reasonable that they should be
Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
Forgot vue file
805aaa5
to
b31e268
Compare
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.
Let's get this in and we can iterate on any multiviewer support as part of #2649 on top of this. Thanks!
This allows the user to update the bounds of the spectrum viewer from the Plot Options plugin. I erred on the conservative side for now, and only have this active in single-select with
spectrum-viewer
chosen, or in multi-select if onlyspectrum-viewer
is chosen.Still needs tests, and it probably actually needs to handle the case of multiple non-image viewers already - I was thinking that everything in Jdaviz only has a single
spectrum-viewer
, but @kecnry does lcviz have multiple profile viewers already that we would want to update with this?