Skip to content
New issue

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

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

Already on GitHub? # to your account

add data to viewers when created by plugins #974

Merged
merged 7 commits into from
Dec 9, 2021

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Nov 24, 2021

Description

This pull request provides immediate feedback from all plugins by showing (or replacing) data in the viewers. In cases where data would be replaced in an image viewer, these currently default to NOT replacing, but still provide the option to replace the image in any of the available viewers and text (should be reviewed by @Jenneh) to explain that the new data will be available in the data menu.

The following plugins are affected:

  • gaussian smooth (slightly different behaviors in specviz, cubeviz, and mosviz due to spectral vs spatial smoothing)
  • collapse (cubeviz)
  • model fitting (specviz, with additional capabilities for apply to cube in cubeviz)
  • moment maps (cubeviz)

This also implements a color cycler for the spectrum viewer - so that new data entries default to have a new color rather than always dark gray. This makes it easier to see the presence of new data in the viewer if its similar to existing data (especially in the case of gaussian smoothing with a small width, for example). (color cycler split into #988 and deferred)

The following screenrecordings show a general overview of most of the cases:

Screen.Recording.2021-12-03.at.10.03.56.AM.mov
Screen.Recording.2021-12-03.at.10.02.20.AM.mov

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.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a change log needed? If yes, is it added to CHANGES.rst?
  • Is a milestone set? Milestone is only currently required for PRs related to Imviz MVP.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 2.1 milestone Nov 24, 2021
@kecnry kecnry added the mosviz label Nov 24, 2021
@kecnry kecnry force-pushed the plugins-show-results branch 2 times, most recently from 1250388 to a9371dc Compare November 29, 2021 14:27
@codecov
Copy link

codecov bot commented Dec 2, 2021

Codecov Report

Merging #974 (68b61d7) into main (a3c4ebf) will increase coverage by 0.04%.
The diff coverage is 62.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #974      +/-   ##
==========================================
+ Coverage   70.46%   70.50%   +0.04%     
==========================================
  Files          73       74       +1     
  Lines        5393     5472      +79     
==========================================
+ Hits         3800     3858      +58     
- Misses       1593     1614      +21     
Impacted Files Coverage Δ
...igs/default/plugins/model_fitting/model_fitting.py 28.93% <44.44%> (+0.64%) ⬆️
jdaviz/app.py 87.90% <50.00%> (-0.16%) ⬇️
...configs/cubeviz/plugins/moment_maps/moment_maps.py 58.82% <60.00%> (+0.05%) ⬆️
...default/plugins/gaussian_smooth/gaussian_smooth.py 82.92% <65.00%> (-2.59%) ⬇️
...daviz/configs/default/plugins/collapse/collapse.py 79.81% <77.77%> (-0.39%) ⬇️
jdaviz/core/events.py 87.68% <0.00%> (-1.64%) ⬇️
jdaviz/configs/mosviz/helper.py 75.19% <0.00%> (-0.01%) ⬇️
jdaviz/configs/mosviz/plugins/__init__.py 100.00% <0.00%> (ø)
jdaviz/configs/mosviz/plugins/row_lock/row_lock.py 82.35% <0.00%> (ø)
jdaviz/configs/mosviz/plugins/viewers.py 80.82% <0.00%> (+0.13%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3c4ebf...68b61d7. Read the comment docs.

@kecnry kecnry marked this pull request as ready for review December 2, 2021 18:45
Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Seems to work as advertised, except I cannot figure out how Gaussian Smooth is supposed to behave in Mosviz. I did something and result didn't show, so I must have used it wrong, a second dev to test out Mosviz would be nice. I tested the rest in Lab and they worked fine.

Thanks!

# selected_viewer for selected_axis == 0
# NOTE: this is currently cubeviz-specific so will need to be updated
# to be config-specific if using within other viewer configurations.
viewer_to_id = {'Left': 'cubeviz-0', 'Center': 'cubeviz-1', 'Right': 'cubeviz-2'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems weird to have Cubeviz specific setting in a "default" section of plugins but seems to work with the other viz, so probably okay for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but couldn't think of a (simple) general way to reference the image viewers by position (suggestions welcomed). As far as I can tell, collapse is only used in cubeviz, so maybe we should just move the plugin there instead of in default?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why anyone wants to collapse anything besides a cube, so I agree it should be moved but maybe as a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly I think there are a few things in the package that would make better sense if they were located elsewhere. I agree that there should be a separate PR to do a little reorganizing.

@pllim

This comment has been minimized.

@kecnry kecnry force-pushed the plugins-show-results branch from abed1d2 to 11b7716 Compare December 3, 2021 19:57
@pllim

This comment has been minimized.

@pllim
Copy link
Contributor

pllim commented Dec 3, 2021

I fixed RTD on main. FYI.

* each plugin has a switch and/or select box which shows where data will appear and give options to change the default
* spectrum viewer implements a basic color cycler for new entries
* tests fail to update viewer since there is no viewer in the passed app, so instead we'll just set the boolean switch to false to allow the rest of the tests to run
Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

I was able to see the data get added to the viewers. However, it's causing some very strange behavior. In Specviz, running one of plugins with the auto-plot toggled on causes my subset to iterate to a new color, but only in the plot itself. If I use another plugin, the plot color toggles again but now all the GUI labels catch up to the previous color. Super weird, and I don't see anything like in on main when using the Model Fitting plugin, which currently auto-plots the results. See screenshots below. In Cubeviz using the smoothing plugin I see the smoothed cube show up in the specified viewer, but I can't change any of the layer options (e.g. switching to Square Root scaling).

Screen Shot 2021-12-03 at 4 21 10 PM

Screen Shot 2021-12-03 at 4 21 44 PM

# https://sashamaps.net/docs/resources/20-colors/
color_cycle = ["#595959", "#e6194B", "#3cb44b", "#4363d8", "#f58231",
"#911eb4", "#42d4f4", "#f032e6", "#bfef45"]
self.state.layers[-1].color = color_cycle[(len(self.state.layers) - 1) % len(color_cycle)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be interacting with subsets incorrectly, see screenshots on the main thread.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rosteen - good catch. I reworked this logic in 1c0986f to only use the color cycler for data layers (ignoring subset layers) and I think it now gives the expected behavior, but please confirm. I think some day merging the color cycler between subsets and data layers might be a good idea, but think that's probably out of scope for now.

@rosteen
Copy link
Collaborator

rosteen commented Dec 6, 2021

Video:

Screen.Recording.2021-12-06.at.12.22.18.PM.mov

* some day it might be nice to use a SHARED color cycler between the subsets and the data layers, but for now this avoids some odd behavior where subset layers were changing colors when adding new data layers
@kecnry kecnry force-pushed the plugins-show-results branch from 9619b9b to 1c0986f Compare December 6, 2021 20:02
@rosteen
Copy link
Collaborator

rosteen commented Dec 6, 2021

That fixed the subsets changing color, but I see multiple other problems with the color cycling. I'll write them up in a minute when I can summarize what's going on, but in the meantime at this point I would recommend removing the color cycling from this PR and making that a separate effort. It's not necessary for the automatic data addition as far as I know, just a nice to have.

@rosteen
Copy link
Collaborator

rosteen commented Dec 6, 2021

Ok, here's the color cycling problems I'm seeing:

  1. The automatic color cycling doesn't update the color selected under the layer tab until another dataset is added after the first. As you can see below, Model1 shows as green on the plot due to the color cycling, but the Layer tab shows it as gray. After I do another Gaussian Smooth, Model1 now shows as green correctly under Layers, but the new smoothed data now incorrectly shows as gray (should be blue).

Screen Shot 2021-12-06 at 3 23 58 PM

Screen Shot 2021-12-06 at 3 24 19 PM

  1. Unselecting and reselecting data in the DATA menu can cause colors to get reassigned. I think this is related to (1) with the plot probably referring to the color in the Layer menu, but I'm not sure. Below you can see that the second smoothed dataset, which was originally plotted in green, has changed to red after a couple check/uncheck operations in the Data menu.

Screen Shot 2021-12-06 at 3 30 07 PM

  1. This is minor in comparison, but I'd highly recommend making the first cycle color something other than red, since the first subset selection is automatically assigned red as well.

@kecnry kecnry mentioned this pull request Dec 6, 2021
11 tasks
@rosteen
Copy link
Collaborator

rosteen commented Dec 7, 2021

@kecnry I think this got missed, from upstream:

In Cubeviz using the smoothing plugin I see the smoothed cube show up in the specified viewer, but I can't change any of the layer options (e.g. switching to Square Root scaling).

Do you see the same/any idea what might be causing this? I have to de-select and re-select the data to get any layer changes to stick (they reset on reselection, but afterwards I can actually change them). It's possible this is another existing bug (bad app.add_data_to_viewer behavior when there's already data in the image viewer) that's just been exposed by this but I haven't confirmed either way.

@kecnry
Copy link
Member Author

kecnry commented Dec 7, 2021

@rosteen - I can also reproduce that in main (even without using a plugin), so have opened #990 and included a recording. Do you think that should block this PR since it now makes running into this bug much more common?

@rosteen
Copy link
Collaborator

rosteen commented Dec 7, 2021

Do you think that should block this PR since it now makes running into this bug much more common?

I vote that we ask for opinions on that at tagup tomorrow morning, I could go either way.

@pllim
Copy link
Contributor

pllim commented Dec 9, 2021

ask for opinions on that at tagup tomorrow morning

Were opinions given at yesterday's tag-up? What is the path forward?

@kecnry
Copy link
Member Author

kecnry commented Dec 9, 2021

ask for opinions on that at tagup tomorrow morning

Were opinions given at yesterday's tag-up? What is the path forward?

Yes, we decided to move forward with this PR as is and fix the bug later (although this PR likely raises its priority as it is more prevalent now).

@rosteen - just want to double check if all of your comments have now been addressed (or deferred 😉) and we can merge?

@rosteen rosteen merged commit 5511f12 into spacetelescope:main Dec 9, 2021
@kecnry kecnry deleted the plugins-show-results branch December 9, 2021 15:15
@kecnry kecnry mentioned this pull request Sep 26, 2022
9 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants