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

BUG: Fix inaccurate coordinates info on dithered data linked by WCS #992

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Dec 8, 2021

Description

This pull request is to fix inaccurate coordinates info on dithered data linked by WCS.

Also add in backend to show which data is currently visible. Adding this info to GUI is a separate ticket and directly tied to Imviz wireframe work.

Suggested workflow for review:

  1. Fire up Imviz example notebook.
  2. Load the ACS images.
  3. Zoom in so you get a nice view of some pixels.
  4. Mouse over a pixel of interest.
  5. Press b to blink. Currently, they are linked by pixels, so X/Y should stay the same but WCS and value will change.
  6. Run the cell at the bottom to link them by WCS.
  7. Mouse over a pixel of interest.
  8. Press b to blink. Now, they are linked by WCS, so X/Y and value will change, but WCS still stay the same.

If you also run with the JWST data, please note that there is upstream bug reported at spacetelescope/gwcs#392.

Also feel free to load your favorite data to test this out. Everything is linked by pixels by default (on load), so you always need to run the extra cell to link them by WCS.

Fixes #945

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

and update tests and notebook.

Also add in backend to show which data is currently visible.
@pllim pllim added the bug Something isn't working label Dec 8, 2021
@pllim pllim added this to the 2.1 milestone Dec 8, 2021
@github-actions github-actions bot added documentation Explanation of code and concepts imviz labels Dec 8, 2021
@pllim pllim force-pushed the the-coords-who-cried-wolf branch from 5dc43f1 to f68eea6 Compare December 9, 2021 00:03
@pllim pllim marked this pull request as ready for review December 9, 2021 00:07
@codecov
Copy link

codecov bot commented Dec 9, 2021

Codecov Report

Merging #992 (4c2f5cc) into main (aa2efc4) will increase coverage by 1.02%.
The diff coverage is 96.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #992      +/-   ##
==========================================
+ Coverage   70.53%   71.55%   +1.02%     
==========================================
  Files          74       74              
  Lines        5437     5464      +27     
==========================================
+ Hits         3835     3910      +75     
+ Misses       1602     1554      -48     
Impacted Files Coverage Δ
jdaviz/configs/imviz/plugins/viewers.py 79.27% <96.15%> (+37.41%) ⬆️
jdaviz/app.py 88.11% <100.00%> (+0.04%) ⬆️
...z/configs/imviz/plugins/coords_info/coords_info.py 97.50% <0.00%> (+52.50%) ⬆️

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 aa2efc4...4c2f5cc. Read the comment docs.

Comment on lines +97 to +113
{
"cell_type": "markdown",
"id": "81249347-a61b-478e-bcfc-586f0457ff4e",
"metadata": {},
"source": [
"This next cell is only enable for debugging. It captures outputs printed to the underlying application `Output` widget."
]
},
{
"cell_type": "raw",
"id": "d23931dc",
"metadata": {},
"source": [
"# This is for debugging only.\n",
"imviz.app._application_handler.output"
]
},
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to keep this in the public example notebook?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe until we can find a way to display which data is currently visible. Every time we have Imviz "hack hour" or something, people ask about that feature. At least for now, we can ask them to enable this cell and see the print out.

link_type = 'pixels'
else: # If not pixels, must be WCS
link_type = 'wcs'
break # Might have duplicate, just grab first match
Copy link
Member

Choose a reason for hiding this comment

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

In what scenario would this happen (and would the "duplicate" ever be something different than the first match)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this scenario:

>>> import numpy as np
>>> from jdaviz import Imviz
>>> a = np.ones((10, 10))
>>> imviz = Imviz()
>>> imviz.load_data(a, data_label='1')
>>> imviz.load_data(a, data_label='2')
>>> imviz.load_data(a, data_label='3')
>>> for elink in imviz.app.data_collection.external_links:
...     print(elink.__class__.__name__, elink.data1.label, elink.data2.label)
LinkSame 1 2
LinkSame 1 2
LinkSame 1 3
LinkSame 1 3

Figuring out why is a rabbit hole for another day.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far in my limited testing, the duplicate is always the same.

There is also another oddity I encountered -- When I load pure numpy arrays, it takes one extra blink for the app to report the correct visible layer data label. Again, "future work."

Copy link
Member

Choose a reason for hiding this comment

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

ok, as long as we would never expect the scenario where the first case gives LinkSame -> pixels but another (ignored because of the break) case would give wcs, then I think this is probably fine.

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 followed your proposed testing procedure and it looks good!

@rosteen rosteen merged commit 1319fc3 into spacetelescope:main Dec 9, 2021
@pllim pllim deleted the the-coords-who-cried-wolf branch December 9, 2021 22:12
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working documentation Explanation of code and concepts imviz Ready for final review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coordinates info display inaccurate on dithered data with WCS
3 participants