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 aperture weight mask with loaded mask cube #3358

Merged
merged 13 commits into from
Dec 16, 2024

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Dec 13, 2024

Updates the value in the test from #3319 to be, I think, correct this time, and adds a simpler test that exposes the problem that I had with that test. I'm out of time to add a changelog, I'll do it tomorrow.

@rosteen rosteen added bug Something isn't working cubeviz plugin Label for plugins common to multiple configurations 💤backport-v4.0.x on-merge: backport to v4.0.x labels Dec 13, 2024
@rosteen rosteen added this to the 4.0.1 milestone Dec 13, 2024
@rosteen
Copy link
Collaborator Author

rosteen commented Dec 13, 2024

Confirmed that these two tests fail on both main and 4.0.x.

spectral_axis=[1, 2]*u.AA,
mask=[[[1, 0], [0, 0]], [[0, 0], [0, 0]]])
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we completely control the data generation here, is it possible to make it such a way that it won't emit warning on load in the first place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I don't think it's needed here actually. But I'm currently tracking down the bigger issues of this breaking like half the tests somehow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooops... didn't even notice the CI. 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whew, figured that out, I'll push a commit shortly fixing tests and addressing your comments.

@@ -224,7 +242,7 @@ def test_manga_cube(cubeviz_helper):
se.function = "Mean"
se.extract()
extracted_max = cubeviz_helper.get_data("Spectrum (mean)").max()
assert_allclose(extracted_max.value, 2.836957E-18)
assert_allclose(extracted_max.value, 5.566169e-18)
Copy link
Contributor

Choose a reason for hiding this comment

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

That is quite a jump. Does this mean MANGA result has been wrong all this time? 😱

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think that mean extract has been wrong (well, wrong if you don't want to average the masked values into your spectrum...) at least since the spectral extraction was changed.

se.function = "Mean"
se.extract()
extracted = cubeviz_helper.get_data("Spectrum (mean)")
assert_allclose(extracted.flux.value, [6, 1])
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for my future self so I don't have to do math again:

  1. (9 + 3 + 6) / 3 = 6
  2. (1 + 1 + 1) / 3 = 1

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.

Thanks!

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.76%. Comparing base (05e9afb) to head (e57ef83).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3358      +/-   ##
==========================================
- Coverage   88.78%   88.76%   -0.02%     
==========================================
  Files         125      125              
  Lines       19161    19227      +66     
==========================================
+ Hits        17012    17067      +55     
- Misses       2149     2160      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

Adding some ideas here:

rosteen#8

@rosteen
Copy link
Collaborator Author

rosteen commented Dec 16, 2024

Adding some ideas here:

rosteen#8

Merged!

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes.

@rosteen rosteen merged commit 92390e2 into spacetelescope:main Dec 16, 2024
18 of 19 checks passed
Copy link

lumberbot-app bot commented Dec 16, 2024

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v4.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 92390e225991d3445de366dce8d2b0a67b8839a1
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #3358: Fix aperture weight mask with loaded mask cube'
  1. Push to a named branch:
git push YOURFORK v4.0.x:auto-backport-of-pr-3358-on-v4.0.x
  1. Create a PR against branch v4.0.x, I would have named this PR:

"Backport PR #3358 on branch v4.0.x (Fix aperture weight mask with loaded mask cube)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

rosteen added a commit to rosteen/jdaviz that referenced this pull request Dec 16, 2024
… mask cube

Fix aperture weight mask with loaded mask cube (spacetelescope#3358)

* Track loaded mask cube in cubeviz

* Don't save DQ array as loaded_mask for JWST

* Add extraction test on file with mask

* Codestyle

* Add consideration of loaded mask to aperture weight mask

* Remove duplicate test, codestyle

* Changelog

* Update jdaviz/configs/cubeviz/plugins/tests/test_parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Cast this as bool here

* Fix tests, address review comments

* adding regression tests to manga mask

* Update jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

Co-authored-by: Brett M. Morris <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
(cherry picked from commit 92390e2)
rosteen added a commit to rosteen/jdaviz that referenced this pull request Dec 16, 2024
… mask cube

Fix aperture weight mask with loaded mask cube (spacetelescope#3358)

* Track loaded mask cube in cubeviz

* Don't save DQ array as loaded_mask for JWST

* Add extraction test on file with mask

* Codestyle

* Add consideration of loaded mask to aperture weight mask

* Remove duplicate test, codestyle

* Changelog

* Update jdaviz/configs/cubeviz/plugins/tests/test_parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Cast this as bool here

* Fix tests, address review comments

* adding regression tests to manga mask

* Update jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

Co-authored-by: Brett M. Morris <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
(cherry picked from commit 92390e2)
rosteen added a commit to rosteen/jdaviz that referenced this pull request Dec 16, 2024
… mask cube

Fix aperture weight mask with loaded mask cube (spacetelescope#3358)

* Track loaded mask cube in cubeviz

* Don't save DQ array as loaded_mask for JWST

* Add extraction test on file with mask

* Codestyle

* Add consideration of loaded mask to aperture weight mask

* Remove duplicate test, codestyle

* Changelog

* Update jdaviz/configs/cubeviz/plugins/tests/test_parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Cast this as bool here

* Fix tests, address review comments

* adding regression tests to manga mask

* Update jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

Co-authored-by: Brett M. Morris <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
(cherry picked from commit 92390e2)
rosteen added a commit that referenced this pull request Dec 16, 2024
…ded mask cube) (#3360)

* Backport PR #3358: Fix aperture weight mask with loaded mask cube

Fix aperture weight mask with loaded mask cube (#3358)

* Track loaded mask cube in cubeviz

* Don't save DQ array as loaded_mask for JWST

* Add extraction test on file with mask

* Codestyle

* Add consideration of loaded mask to aperture weight mask

* Remove duplicate test, codestyle

* Changelog

* Update jdaviz/configs/cubeviz/plugins/tests/test_parsers.py

Co-authored-by: P. L. Lim <[email protected]>

* Cast this as bool here

* Fix tests, address review comments

* adding regression tests to manga mask

* Update jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py

Co-authored-by: Brett M. Morris <[email protected]>

---------

Co-authored-by: P. L. Lim <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
Co-authored-by: Brett M. Morris <[email protected]>
(cherry picked from commit 92390e2)

* Update jdaviz/configs/cubeviz/plugins/tests/test_parsers.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cubeviz plugin Label for plugins common to multiple configurations Still Needs Manual Backport 💤backport-v4.0.x on-merge: backport to v4.0.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants