-
Notifications
You must be signed in to change notification settings - Fork 32
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-3669: Updating the C Extension to do CHARGELOSS Read Noise Recalculations #275
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #275 +/- ##
==========================================
+ Coverage 84.38% 84.63% +0.25%
==========================================
Files 41 41
Lines 7557 7628 +71
==========================================
+ Hits 6377 6456 +79
+ Misses 1180 1172 -8 ☔ View full report in Codecov by Sentry. |
e3789d6
to
f78aff6
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.
I'm not great at C, but this looks plausible to me. Just a couple comments on the Python parts and some typos.
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.
Linked to spacetelescope/jwst#8697
Looks good to me! I've successfully tested that:
-
Runtime improves as expected in test case jw02079004003_03101_00001_nis. In the old version it takes about 2.5 minutes to run the relevant piece of the RN recalculation, while with this PR it takes about 2.5 seconds.
-
RN variances stay as expected in test case jw01510001001_02108_00001_nis using both the OLS and OLS_C algorithms.
-
Checked that the SCI and variance arrays did not change for other instruments that don't use charge migration.
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.
All my comments were addressed, thanks!
I think this should be good to go, once the changelog format is fixed and conflicts are resolved. It might be a good idea to run the regression tests one last time before merging.
The corresponding JWST PR can be merged as soon as this one is in.
a7006ab
to
d4a5f36
Compare
This needs an update to move the changelog entry to a towncrier fragment, then we'll get this merged ASAP in preparation for an stcal build. |
Tests are showing a number of failures. It looks like the gls_fit tests have out of date dqflags, and the downstream tests show the same failures wrt. level 2 pipelines across PRs. We can get this PR in, but we should clean up these failures. There isn't much value gained by having tests if we ignore them due to repeated failures. |
I added the CHARGELOSS flag keyword to the GLS flags for testing. They now pass. |
531ebae
to
b121fa2
Compare
The romancal test failures: @schlafly are there plans to support this in in romancal or alternatively can ols be dropped? |
Is there an option to turn on/off this behavior? For Roman we don't currently have this flag but we could add it; it does seem to me that we will have charge migration issues. On the other hand, this code isn't about flagging or addressing the charge migration per se. My understanding is that the "old" behavior gives a more accurate estimation of the read noise contribution to the variance of these pixels, but that we've decided that we don't want that more accurate estimation because it leads to high flux pixels being weighted downward in resample for IVM weighting. I might have approached this via something like: |
@@ -131,6 +144,7 @@ def set_dqflags(self, dqflags): | |||
self.flags_saturated = dqflags["SATURATED"] | |||
self.flags_no_gain_val = dqflags["NO_GAIN_VALUE"] | |||
self.flags_unreliable_slope = dqflags["UNRELIABLE_SLOPE"] | |||
self.flags_chargeloss = dqflags["CHARGELOSS"] |
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.
Is CHARGELOSS
only supported by OLS_C
and not OLS
? If so, I think (and I tested this locally) passing in algorithm
to this method and only setting flags_chargeloss
if algorithm == OLS_C
should fix the romancal tests.
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 CHARGELOSS
flag is used when selecting either OLS_C
or OLS
. Currently, the use of the CHARGELOSS
flag is handled in the JWST
step code. Unfortunately, there is a bug in the segmentation computation (that occurs very rarely on an edge case) and with a computation hit.
When running ramp fitting, there is a message that the code returned from the STCAL
code, but there can be a noticeable lag between that and the completion of the ramp fitting step. To fix the bug and to improve computational performance, I moved the read noise variance re-calculation from the JWST
step code into the C-extension. This required some accounting changes in ramp_fit_class.py
and ramp_fit.py
to get the proper information to the C-extension.
…ation for the read noise variance in ramp fitting. The test_niriss_image.py 'rate' tests are failing for less than one percent of the CHARGELOSS affected pixels.
… the creation of the RampData array during ramp fitting.
…noise variance due to the CHARGELOSS flag.
…conditioned on the use of the 'OLS_C' ramp fitting algorithm.
a16b8ca
to
e893cf1
Compare
I got confirmation from RTB that they do not intend to use OLS_C or OLS for Roman. |
Happy to merge this ASAP, but it looks like one of the new unit tests is failing:
|
I"ll check it out. |
It's fixed. |
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.
LGTM - merging this momentarily.
Resolves JP-3669
Closes #8601
This PR addresses the read noise variance recalculation based on the CHARGELOSS flag. This recalculation was in the JWST ramp fit step code, but that came with a performance hit and was unnecessarily complicated. The recalculation has been implemented in the C extension code, simplifying the ramp fitting, as well as improving performance.
There is a corresponding JWST PR that removes the CHARGELOSS recalculation from the step code, as well as removes the corresponding test. spacetelescope/jwst#8678
The regression tests pass, except for one test. The test failure has been confirmed to be incorrect. The regression test truth file for this test needs to be updated:
https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1623/
Checklist
CHANGES.rst
(either inBug Fixes
orChanges to API
)