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

fix: buggy 1D/2D spectrum viewer x-axis links #852

Merged
merged 3 commits into from
Sep 15, 2021

Conversation

mariobuikhuizen
Copy link
Collaborator

Fixes #802

Description

This pull request is to address ...

Fixes #

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)?

@codecov
Copy link

codecov bot commented Sep 9, 2021

Codecov Report

Merging #852 (ca1e58c) into main (36605e8) will increase coverage by 0.23%.
The diff coverage is 75.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #852      +/-   ##
==========================================
+ Coverage   68.29%   68.53%   +0.23%     
==========================================
  Files          65       65              
  Lines        4741     4777      +36     
==========================================
+ Hits         3238     3274      +36     
  Misses       1503     1503              
Impacted Files Coverage Δ
jdaviz/configs/mosviz/helper.py 72.91% <73.86%> (+1.55%) ⬆️
jdaviz/configs/mosviz/plugins/viewers.py 73.78% <100.00%> (+0.51%) ⬆️
...configs/default/plugins/data_tools/file_chooser.py 69.14% <0.00%> (+3.42%) ⬆️

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 36605e8...ca1e58c. Read the comment docs.

@mariobuikhuizen
Copy link
Collaborator Author

Hmm.. I see now that my workaround for the flipped data does not work as expected.

@rosteen
Copy link
Collaborator

rosteen commented Sep 9, 2021

This is probably what you're talking about in regards to the flipped data, but for what it's worth I now see the the 1D spectrum with an ascending wavelength axis on row click, however the 2D spectrum is still in descending order. This means that if the user interacts with the 1D spectrum first, the 2D spectrum will flip to match it, but if the user interacts with the 2D spectrum first, the 1D spectrum will flip back to descending wavelength to match the 2D one. So this almost works, just needs a tweak to the initial loading of the 2D spectrum I think.

Other than that, this PR looks great. The pan/zoom warning behaves much better now.

@mariobuikhuizen
Copy link
Collaborator Author

Indeed. I think I can flip the 1d x-axis on row click.

@rosteen
Copy link
Collaborator

rosteen commented Sep 9, 2021

You mean 2D right? 😆

self.app.hub.broadcast(msg)

def _is_world_flipped(self):
spec1d = self.app.get_viewer('table-viewer')._selected_data["spectrum-viewer"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This causes KeyError.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's failing in the tests because the test is lazy and doesn't populate the 1D spectrum viewer for the 2D test, I think. Not sure if that's a realistic use case...I would assume we always have a 1D spectrum if we have a 2D in Mosviz.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the test or make this fail silently? Prefer the former...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I missed this conversation, I changed the code to guard for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

mosviz should support loading just one type of spectrum, as we can infer from the existence of methods such as load_1d_spectra.

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.

I don't grok the internals but here is a general review.

jdaviz/configs/mosviz/helper.py Outdated Show resolved Hide resolved
jdaviz/configs/mosviz/helper.py Show resolved Hide resolved
jdaviz/configs/mosviz/helper.py Outdated Show resolved Hide resolved
jdaviz/configs/mosviz/helper.py Outdated Show resolved Hide resolved
jdaviz/configs/mosviz/helper.py Outdated Show resolved Hide resolved
jdaviz/configs/mosviz/helper.py Outdated Show resolved Hide resolved
jdaviz/configs/mosviz/helper.py Outdated Show resolved Hide resolved
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.

Looks good to me, this is a huge improvement on the current performance. Thanks!

@pllim
Copy link
Contributor

pllim commented Sep 14, 2021

Does this need a rebase so this can be tested on top of #733 ?

@mariobuikhuizen
Copy link
Collaborator Author

I've rebased on #733, and some tests now produce errors.

@pllim
Copy link
Contributor

pllim commented Sep 14, 2021

Re: Errors -- We won't see it here until you push out the rebased branch... 😬

@mariobuikhuizen
Copy link
Collaborator Author

I was trying to see if I could quickly fix it 😃, but will push it now.

@pllim
Copy link
Contributor

pllim commented Sep 14, 2021

Hmm looks like everything is passing...

@@ -78,11 +77,11 @@ def place_slit_overlay(self, *args, **kwargs):
self.remove_slit_overlay()

# Get data from relevant viewers
image_data = self.app.get_viewer("image-viewer").data()
image_data = self.app.get_viewer("image-viewer").state.reference_data
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. This is from a different PR!

# Warn the user if they've panned far enough away from the data
# that the viewers will desync
# Note: Because of the flipped data workaround, idx_min can be > idx_max
if not (0 <= idx_min < len(world) and 0 <= idx_max < len(world)):
Copy link
Contributor

Choose a reason for hiding this comment

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

It bothers me a bit that len(world) is calculated twice in the same line, but I am being too nitpicky, perhaps...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't mind changing that.

@mariobuikhuizen
Copy link
Collaborator Author

Strange...

Also, I see some changes after the rebase that shouldn't be there. I see now that's because the merge target is main.

@mariobuikhuizen
Copy link
Collaborator Author

Will rebase on main, since 733 is merged

@pllim
Copy link
Contributor

pllim commented Sep 14, 2021

History and code look good now. Thanks!

@rosteen
Copy link
Collaborator

rosteen commented Sep 15, 2021

That sounded like an approval to me. Merging!

@rosteen rosteen merged commit 75e727a into spacetelescope:main Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Mosviz: 1D/2D spectrum viewer x-axis links are buggy
4 participants