-
Notifications
You must be signed in to change notification settings - Fork 74
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
Respect loaded mask cube properly in spectral extraction. #3319
Conversation
bab8070
to
6ee7daf
Compare
@@ -22,6 +22,7 @@ class Cubeviz(CubeConfigHelper, LineListMixin): | |||
|
|||
_loaded_flux_cube = None | |||
_loaded_uncert_cube = None | |||
_loaded_mask_cube = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe give @javerbukh co-author credit given #2718 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code itself looks good to me - just a few workflow related questions to consider:
Do we want (now or as a a follow-up ticket) to have a dropdown to select the mask cube? Should the default be to apply the mask or to not apply it?
What happens if the intersection between an aperture and the mask results in no pixels?
Should the mask be used in other plugins as well (aperture photometry, moment map, collapse, etc)?
I think that if it is used, it should be used everywhere (it can be a follow up issue). Can there maybe be an option at load_data to load AND use the mask? I would not set it to use by default, but maybe there could be a warning at loading like "there is a mask extension, if you want to load it do blah" |
Visualize the mask cube would be very useful! |
Code seems straightforward, testing this on top of #3307 and the non-finite warning above the Fit Model button goes away with this PR. In 3307, I was still seeing a model in the spectrum-viewer/table after model fitting, and there wasn't a traceback (but there was a warning was in the log). I'll hold off approving for now and re-review if/once the above comments are decided on and if they go into this PR or follow-ups. |
Hm, is the mask a subset of the DQ flags we're showing? Or is it the set of all the flagged pixels? I'm not completely sure what the difference is between the two things or whether we're losing anything by not showing the mask vs DQ. |
6ee7daf
to
b97ea9f
Compare
@kecnry I just tested, if you define an aperture that is totally covered by the mask, it extracts a flat spectrum at 0 flux. |
I think I figured out the test failure - the science validation cube has NaNs in the mask/DQ array where the data isn't masked rather than 0s (btw, I did confirm that what we're storing from reading the mask array is what we're showing as the DQ data entry). This is awful, but easy to handle. |
3ed5820
to
572e716
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3319 +/- ##
==========================================
- Coverage 88.80% 88.80% -0.01%
==========================================
Files 125 125
Lines 19137 19155 +18
==========================================
+ Hits 16995 17010 +15
- Misses 2142 2145 +3 ☔ View full report in Codecov by Sentry. |
I removed the lines storing the JWST DQ array as the original mask, and added a note in the docs as well as a Snackbar message indicating the original mask was applied during extraction, to address @camipacifici's concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any existing test data that we can send through spectral extraction to add coverage to these logic paths? Otherwise looks good to me until we can get the full support in to allow mask selection across all relevant plugins.
1ab3d1b
to
a53be86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recent code updates look good to me and behavior has been maintained since my last review!
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
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 If these instructions are inaccurate, feel free to suggest an improvement. |
…cope#3319) * Track loaded mask cube in cubeviz * First pass at handling mask cube in extraction * Fix type * Add changelog * Handle mask cubes that have NaNs instead of 0s * Act on copy of this mask array * Don't save DQ array as loaded_mask for JWST * Add snackbar warning and note in docs * codestyle * Add extraction test on file with mask * Codestyle (cherry picked from commit bf8cb26)
… in spectral extraction.) (#3348) --------- Co-authored-by: Brett M. Morris <morrisbrettm@gmail.com>
Fixes #3312.
Close #2718