-
Notifications
You must be signed in to change notification settings - Fork 170
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-3235: Implement NSClean step for NIRSpec 1/f noise #8000
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #8000 +/- ##
==========================================
- Coverage 75.94% 75.41% -0.53%
==========================================
Files 460 464 +4
Lines 37629 37941 +312
==========================================
+ Hits 28577 28615 +38
- Misses 9052 9326 +274
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@melanieclarke I think this is now ready for a final review. I've tested the latest updates on subarray images, both simple 2D versions and 3D BOTS, and it appears to work. |
@melanieclarke Whoops, just noticed that I need to go back and update the step docs to remove the warnings/notes about not being able to work on subarrays. I'll take care of that. But other than that, the actual code is final (I hope!). |
Thanks @hbushouse! I should have some time to review later this week. |
@hbushouse - sorry for the delay, I'm testing a number of things now and will pass on input when I have it. For starters - things look good so far for subarray support and opting out of masking the spectral regions. Thanks for the updates! The user mask support needs a little clean up (above), but making those changes locally made the rest of it work fine with a modified version of a mask saved by an earlier run. Also, attempting to clean an ALLSLITS subarray (e.g. jw01128004001_0310g_00003_nrs1_rate.fits) consistently uses up all the memory on my machine, then kills the kernel. This is true for the original NSClean algorithm too, and I don't know why. Can we either try to fix it or else skip cleaning for this mode for now? I have not yet tested BOTS -- I'll let you know how it goes. |
Huh, interesting. Is there anything particularly weird about that dataset? (e.g. lots of masked pixels or something). Have you tried any other ALLSLITS examples? Can't imagine why that particular subarray shape/size would cause unique problems.
I tried it on one and it runs without failing, but my particular example had so many flagged/masked pixels it's hard to tell whether it successfully fit and removed the background noise. |
It happens for every ALLSLITS data set I've tried. Maybe something about the data array shape with the subarray implementation? I tested on a BOTS file with 1512 integrations. It worked successfully, but masking the spectral trace area leaves very little unilluminated data, so the correction is poor. It works better with just sigma-clipping, but then it takes some experimentation to get the right n_sigma. It took about 1.5-2 hours per cleaning run on my computer, depending on my settings, so cleaning BOTS data with this algorithm will take some dedication on the user's part. |
The ALLSLITS memory issue is because of the subarray width in the x-direction (in detector space). Subarrays are currently handled by inverting the FFT matrix for the full array all at once, where the full-frame mode proceeds line by line. The extra size for ALLSLITS makes the matrix too big to fit in memory when handled by the subarray case. I looked briefly into whether it would be possible to support ALLSLITS with the full-frame mode or to convert the subarray mode to work one line at a time, but there was no obvious way to make either option work. It needs more study, and maybe some input from Bernie on the frequency filtering methods that differ between the two modes. For this first implementation, I suggest we disable NSClean for ALLSLITS subarrays and file a ticket to implement it later and/or merge the subarray and full-frame handling. |
@melanieclarke This is ready for final review and/or testing. The only recent change was to add an abort if someone feeds in an ALLSLITS subarray, with an appropriate warning in the docs saying that it doesn't work for ALLSLITS. Given that that's all that's changed, if you were satisfied with your last round of tests on the modes that are supported, then I think we're good to go. Note that I've still got the skip parameter in the step module hardwired to skip, so that this will not get executed in normal processing even after it's merged. |
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.
I checked the user mask implementation, the ALLSLITS handling, and the default to skip the step, and I think everything looks good now. Thanks again!
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.
I did not correct Python types everywhere. Change boolean
--> bool
, string
--> str
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.
This clean
method needs some cleaning
@nden Are we happy now? |
Resolves JP-3235
Closes #7724
This PR implements the "NSClean" algorithm for removing 1/f noise from NIRSpec IFU and MOS images. This initial commit is a crude first draft that just implements basic step structure and functionality. More work to come, especially specifics for handling MOS vs. IFU.
Checklist for maintainers
CHANGES.rst
within the relevant release sectionHow to run regression tests on a PR