-
Notifications
You must be signed in to change notification settings - Fork 171
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
JP-824: Add option to save combined background image #5954
JP-824: Add option to save combined background image #5954
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5954 +/- ##
==========================================
+ Coverage 77.44% 77.49% +0.04%
==========================================
Files 404 404
Lines 35373 35552 +179
==========================================
+ Hits 27395 27551 +156
- Misses 7978 8001 +23
*This pull request uses carry forward flags. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Code looks good. Should update the background step docs to mention this, and of course the requisite change log entry.
I think we might have at least 1 regtest that applies the |
Yeah, the regression test is jwst/jwst/regtest/test_miri_lrs_slit_spec2.py Lines 28 to 34 in 434c540
Also, looking at the test, it seems we are skipping resample in that test for the following reason: We should turn resampling back on, and test the |
#4373 Ah, from the great regtest marathon, when all @hbushouse and @jdavies-st did for Christmas was write tests! Those were the days. ;-) |
@hbushouse @jdavies-st It took me a bit to find some code I could test this with, having forgotten to check the regtest data first. Using the data from the test mentioned above, I'm getting an error when attempting the save_model call; the traceback goes through many lines of of astropy fits io but ends in a numpy core line with "NotImplementedError: MaskedArray.tofile() not implemented yet." Has this been seen before? Is some model massaging required? It seems as though the culprit is the err array in the ImageModel. I can't believe this is the first time an err is being saved... |
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.
Need changelog!
@stscieisenhamer , do you have a suggestion on the comment I made above regarding issues printing an ImageModel with an included MaskedArray to file? |
Sorry, missed that comment. The issue is not that an err array is being saved, but this is a masked err array. Others a bit more knowledgeable of the code base may know different, however I do not believe any of the |
So the obvious next question is where/how one of the arrays in the background model is ending up as a masked array. Have you been able to figure that out? Perhaps by whatever routine is being used to create the combined/sigma-clipped array? |
Finding that wasn't too difficult - the err array is explicitly initialized as a masked array. I've been futzing around with the output though, to understand exactly how I should be "collapsing" it - the mask is in place to utilize the results of a sigma_clip on the background data. The combined err does an uncertainty calculation, but it calls the masked array without using .data or .mask, and I'm not sure exactly what is being fed into the line (Line here). If I were to force-apply the mask to the data, is the goal of the sigma_clip to remove those entries from the error calculation? |
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.
Looks like this latest update should fix the model saving problem. Can remove the 1 commented line.
Still needs a change log entry and step docs update.
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.
Looks good. All the boxes checked!
Closes #3746
Resolves JP-824
Description
This PR adds the option to save the combined background image model, in a method pulled directly from the optional flat_field output. Currently will not work as written, oops. Do we really need to close that bkg_model?
Checklist