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

Add stretch bounds tool to plot option histogram viewer #2513

Merged
merged 10 commits into from
Oct 20, 2023

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Oct 16, 2023

Opening as draft since I'll need a test and changelog entry.

@rosteen rosteen added feature Feature request plugin Label for plugins common to multiple configurations labels Oct 16, 2023
@rosteen rosteen added this to the 3.8 milestone Oct 16, 2023
@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Files Coverage Δ
...nfigs/default/plugins/plot_options/plot_options.py 86.64% <100.00%> (+0.28%) ⬆️
jdaviz/core/template_mixin.py 91.25% <100.00%> (+0.01%) ⬆️
jdaviz/core/tools.py 86.42% <89.65%> (+0.34%) ⬆️

... and 6 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

jdaviz/core/tools.py Outdated Show resolved Hide resolved
Remove debugging prints

Add test
Comment on lines 407 to 411
# Add the stretch bounds tool to the default Plot viewer.
self.stretch_histogram.tools_nested.append(["jdaviz:stretch_bounds"])
self.stretch_histogram.toolbar = NestedJupyterToolbar(self.stretch_histogram.viewer,
self.stretch_histogram.tools_nested,
[])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might eventually want to generalize this as a method (or have the init take options for the tools), but this is probably ok for now if this is the only case we're modifying?

jdaviz/core/tools.py Outdated Show resolved Hide resolved
@rosteen
Copy link
Collaborator Author

rosteen commented Oct 16, 2023

FYI Jenn said she probably won't be able to get to making an icon for this until next week.

@rosteen
Copy link
Collaborator Author

rosteen commented Oct 19, 2023

I changed this to update the closest bound to where the user clicks, and to enable clicking+dragging. Way more performant than I was worried it would be, video below:

Screen.Recording.2023-10-19.at.11.54.31.AM.mov

@pllim
Copy link
Contributor

pllim commented Oct 19, 2023

Curious... what happens when someone puts one line on top of another, how do you decide which line they are clicking on?

@rosteen
Copy link
Collaborator Author

rosteen commented Oct 19, 2023

Curious... what happens when someone puts one line on top of another, how do you decide which line they are clicking on?

It seems to Just Work (tm) actually, I don't think it will let you drag the VMax below the VMin, it switches between them as you drag past.

jdaviz/core/tools.py Outdated Show resolved Hide resolved
jdaviz/core/tests/test_tools.py Outdated Show resolved Hide resolved
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really works very nicely once we get the throttling tuned right for large images. Do we want to change the color between inactive/active in this PR or consider that follow-up?

@rosteen rosteen marked this pull request as ready for review October 19, 2023 17:48
@rosteen
Copy link
Collaborator Author

rosteen commented Oct 19, 2023

This really works very nicely once we get the throttling tuned right for large images. Do we want to change the color between inactive/active in this PR or consider that follow-up?

I'll see if I can do the color quickly this afternoon.

@rosteen
Copy link
Collaborator Author

rosteen commented Oct 19, 2023

@kecnry Colors change now, not sure if this is the best way to do it but these lines weren't a subclass of any of our marks, so I just did it this way 🤷 .

@kecnry
Copy link
Member

kecnry commented Oct 19, 2023

This also changes the color of the stretch function itself, which isn't ideal. We probably want that to always be blue now since that will only be "active"/"clickable" with another tool and only for splines (in the future). We might eventually want to generalize the slice mark to also get the "out-of-bounds" logic, but for now just a custom class or even just a private attribute to check (line.is_vmin_vmax=True and then `hasattr(line, 'is_vmin_vmax' or something like that) so that we can filter on just these two should do the trick.

@rosteen
Copy link
Collaborator Author

rosteen commented Oct 19, 2023

This also changes the color of the stretch function itself

I was thinking that, although you aren't directly changing that line, it does update when you change vmin and vmax, that it might make sense to have it change color as well. Basically "things that will be affected by using this tool change color." I'm open to changing it though.

Update jdaviz/configs/default/plugins/plot_options/plot_options.py

Co-authored-by: Kyle Conroy <[email protected]>

Codestyle
@rosteen
Copy link
Collaborator Author

rosteen commented Oct 19, 2023

Alright, I updated so that the stretch curve color doesn't get updated.

Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no where to suggest it, so I just pushed a commit that changes the curve to the same "inactive" blue (always). Once that supports dragging as well, we can do the same color toggling as here.

This works great and is a super elegant solution! Curious to see if we need to fine-tune the throttling when using on super large images, but we can iterate on that easily going forward.

Copy link
Contributor

@cshanahan1 cshanahan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only small issue I ran into was that there is some funky behavior when you click a min/max line and drag it around, when it surpasses the previous maximum and becomes the new maximum. The second line will move even when not being dragged:

Screen.Recording.2023-10-20.at.12.55.26.PM.mov

EDIT: We had a discussion offline about changing the logic of this from 'inactive bar becomes active' to 'active bar becomes new min/max' which would improve the jumpiness when dragging the bar around, but that doesn't need to block this PR.

@cshanahan1
Copy link
Contributor

cshanahan1 commented Oct 20, 2023

When you click the home button the bars disappear. Also you can see in this video, do vmin and vmax start overlapping and you have to 'shake' the second bound loose to have access to both bars?:

Screen.Recording.2023-10-20.at.1.05.24.PM.mov

@kecnry
Copy link
Member

kecnry commented Oct 20, 2023

When you click the home button the bars disappear.

Home button is a known bug, see #2506

Copy link
Contributor

@cshanahan1 cshanahan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but to summarize some offline discussion pertaining to my review:

  1. My comment about the jumpiness of the bars can be fixed in a follow up but doesn't need to block this PR. It would entail changing the logic when vmin>vmax from the active bar switching, to the definition of the active bar switching (vmin becomes vmax, rather than the selection changing)
  2. The home button problem is an existing issue
  3. The overlapping bars issue i mentioned is related to Non-repeatable vmin vmax[BUG] #2526

@kecnry kecnry merged commit d9cacaf into spacetelescope:main Oct 20, 2023
15 checks passed
@kecnry kecnry mentioned this pull request Oct 27, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request plugin Label for plugins common to multiple configurations Ready for final review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants