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

JP-3463: Dark current noise floor #236

Closed
wants to merge 35 commits into from

Conversation

mwregan2
Copy link
Collaborator

@mwregan2 mwregan2 commented Dec 28, 2023

Resolves JP-3463

Closes [spacetelescope/jwst#8071]

This PR addresses the issue described in JP-3463 that the Poisson Noise from the dark current in the pixels is not included in the rate uncertainty. This change adds the dark rate to the estimated source rate to determine the total Poisson noise.

Checklist

  • added entry in CHANGES.rst (either in Bug Fixes or Changes to API)
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)

Copy link

codecov bot commented Dec 28, 2023

Codecov Report

Attention: 28 lines in your changes are missing coverage. Please review.

Comparison is base (dfa9a50) 85.94% compared to head (23e3562) 85.80%.

Files Patch % Lines
tests/test_jump.py 25.00% 12 Missing ⚠️
tests/test_ramp_fitting_gls_fit.py 58.33% 10 Missing ⚠️
src/stcal/ramp_fitting/ols_fit.py 50.00% 4 Missing ⚠️
src/stcal/ramp_fitting/ramp_fit.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #236      +/-   ##
==========================================
- Coverage   85.94%   85.80%   -0.14%     
==========================================
  Files          35       35              
  Lines        6523     6621      +98     
==========================================
+ Hits         5606     5681      +75     
- Misses        917      940      +23     

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

Copy link
Collaborator

@kmacdonald-stsci kmacdonald-stsci left a comment

Choose a reason for hiding this comment

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

I recommend adding avg_dark_current to the RampData class, which would minimize the number of edits in ramp fitting and ramp fitting testing.

CHANGES.rst Outdated Show resolved Hide resolved
src/stcal/jump/jump.py Outdated Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Outdated Show resolved Hide resolved
src/stcal/ramp_fitting/ramp_fit.py Outdated Show resolved Hide resolved
tests/test_ramp_fitting.py Outdated Show resolved Hide resolved
@hbushouse
Copy link
Collaborator

@mwregan2 Still waiting for review comments/suggestions to be addressed.

@hbushouse hbushouse changed the title Dark current noise floor JP-3463: Dark current noise floor Jan 16, 2024
@hbushouse
Copy link
Collaborator

The errors in CI test "downstream" for jwst are all coming from the API change to "ramp_fit_data", because this PR adds more arguments to that function call, so the unit tests that are over in jwst/ramp_fitting/tests/test_ramp_fit.py don't match. That'll be fixed by a PR over in jwst. So I think the CI errors here are expected and OK. Should probably move all the unit tests out of jwst and into stcal, to avoid these kinds of issues.

CHANGES.rst Outdated Show resolved Hide resolved
src/stcal/jump/jump.py Outdated Show resolved Hide resolved
tests/test_ramp_fitting.py Outdated Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
@hbushouse
Copy link
Collaborator

@mwregan2 I'm still confused as to why there seem to be some changes to the jump code included here. Is that a mistake?

@hbushouse
Copy link
Collaborator

@kmacdonald-stsci Can you review again to see if you agree with the way avg_dark_current has now been implemented within the ramp_data class?

Copy link
Collaborator

@kmacdonald-stsci kmacdonald-stsci left a comment

Choose a reason for hiding this comment

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

The only places in ols_fit.py that avg_dark_current should appear is at lines 1157 and 1199. It still appears in docstrings and as some function parameters.

In nearly all the ramp fitting tests a variable avg_dark_current is unnecessarily added and not used.

if image_info is None or integ_info is None:
return None, None, None

return image_info, integ_info, opt_info

# Call ramp fitting for multi-processor (multiple data slices) case
image_info, integ_info, opt_info = ols_ramp_fit_multiprocessing(

else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This else is unnecessary.

src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
src/stcal/ramp_fitting/ols_fit.py Show resolved Hide resolved
rnoise_slice = readnoise_2d[start_row:start_row + rslices[k], :].copy()
gain_slice = gain_2d[start_row:start_row + rslices[k], :].copy()
slices.insert(
k, (ramp_slice, buffsize, save_opt, rnoise_slice, gain_slice, weighting, avg_dark_current))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The avg_dark_current is not needed as a part of this tuple. I am surprised this doesn't cause problems with the multiprocessing, since this tuple is a list of parameters to be used by ols_ramp_fit_single.

@@ -640,10 +640,10 @@ def test_one_group_fit():

ramp_data, gain2d, rnoise2d = setup_inputs(dims, gain, rnoise, group_time, frame_time)
ramp_data.data[0, 0, 50, 50] = 10.0

avg_dark_current = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unused, so can be removed.

@@ -665,10 +665,10 @@ def test_two_groups_unc():

ramp_data.data[0, 0, 50, 50] = 10.0
ramp_data.data[0, 1, 50, 50] = 10.0 + deltaDN

avg_dark_current = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unused, so can be removed.

@@ -705,10 +705,10 @@ def test_five_groups_unc():
ramp_data.data[0, 4, 50, 50] = 60.0

# check = np.median(np.diff(ramp_data.data[0,:,50,50])) / grouptime

avg_dark_current = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unused, so can be removed.

@@ -752,10 +752,10 @@ def test_oneCR_10_groups_combination():
ramp_data.data[0, 9, 50, 50] = 180.0

ramp_data.groupdq[0, 5, 50, 50] = JUMP_DET

avg_dark_current = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unused, so can be removed.

@@ -806,10 +806,10 @@ def test_oneCR_10_groups_combination_noisy2ndSegment():
ramp_data.data[0, 9, 50, 50] = 180.0

ramp_data.groupdq[0, 5, 50, 50] = JUMP_DET

avg_dark_current = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unused, so can be removed.

@hbushouse
Copy link
Collaborator

Superseded by #243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants