Skip to content

Commit e7f6511

Browse files
authored
fix unit test for jump (#6552)
1 parent 9177d9c commit e7f6511

File tree

2 files changed

+49
-43
lines changed

2 files changed

+49
-43
lines changed

CHANGES.rst

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ jump
201201

202202
- Updated jump detection step to use common code moved to stcal [#6089]
203203

204+
- In stcal (pr #72), several changes were made to fix existing bugs in the
205+
twopoint difference routine for jump detection. Some of these issues
206+
resulted in jumps erroneously being flagged for pixels with only two
207+
usable groups (i.e one usable difference). This PR on the JWST side
208+
fixes one of the unit tests to account for this. [#6552]
209+
204210
lib
205211
---
206212

jwst/jump/tests/test_detect_jumps.py

+43-43
Original file line numberDiff line numberDiff line change
@@ -248,49 +248,49 @@ def test_multiple_neighbor_jumps_firstlastbad(setup_inputs):
248248
assert_array_equal(out_model.groupdq[0, :, 4, 4], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1])
249249

250250

251-
# def test_nirspec_saturated_pix(setup_inputs):
252-
# """
253-
# This test is based on an actual NIRSpec exposure that has some pixels
254-
# flagged as saturated in one or more groups, which the jump step is
255-
# supposed to ignore, but an old version of the code was setting JUMP flags
256-
# for some of the saturated groups. This is to verify that the saturated
257-
# groups are no longer flagged with jumps.
258-
# """
259-
# grouptime = 3.0
260-
# ingain = 1.0
261-
# inreadnoise = 10.7
262-
# ngroups = 7
263-
# nrows = 6
264-
# ncols = 6
265-
266-
# model, rnoise, gain = setup_inputs(ngroups=ngroups, nints=1, nrows=nrows,
267-
# ncols=ncols, gain=ingain,
268-
# readnoise=inreadnoise, deltatime=grouptime)
269-
270-
# # Setup the needed input pixel and DQ values
271-
# model.data[0, :, 1, 1] = [639854.75, 4872.451, -17861.791, 14022.15, 22320.176,
272-
# 1116.3828, 1936.9746]
273-
# model.groupdq[0, :, 1, 1] = [0, 0, 0, 0, 0, 2, 2]
274-
# model.data[0, :, 2, 2] = [8.25666812e+05, -1.10471914e+05, 1.95755371e+02, 1.83118457e+03,
275-
# 1.72250879e+03, 1.81733496e+03, 1.65188281e+03]
276-
# # 2 non-sat groups means only 1 non-sat diff, so no jumps should be flagged
277-
# model.groupdq[0, :, 2, 2] = [0, 0, 2, 2, 2, 2, 2]
278-
# model.data[0, :, 3, 3] = [1228767., 46392.234, -3245.6553, 7762.413,
279-
# 37190.76, 266611.62, 5072.4434]
280-
# model.groupdq[0, :, 3, 3] = [0, 0, 0, 0, 0, 0, 2]
281-
282-
# # run jump detection
283-
# out_model = run_detect_jumps(model, gain, rnoise, rejection_thresh=200.0, three_grp_thresh=200,
284-
# four_grp_thresh=200,
285-
# max_cores=None, max_jump_to_flag_neighbors=200,
286-
# min_jump_to_flag_neighbors=10, flag_4_neighbors=False)
287-
288-
# # Check the results. There should not be any pixels with DQ values of 6, which
289-
# # is saturated (2) plus jump (4). All the DQ's should be either just 2 or just 4.
290-
# assert_array_equal(out_model.groupdq[0, :, 1, 1], [0, 4, 4, 4, 0, 2, 2])
291-
# # no groups are flagged when theres only 1 non-sat. grp
292-
# assert_array_equal(out_model.groupdq[0, :, 2, 2], [0, 0, 2, 2, 2, 2, 2])
293-
# assert_array_equal(out_model.groupdq[0, :, 3, 3], [0, 4, 4, 0, 0, 4, 2])
251+
def test_nirspec_saturated_pix(setup_inputs):
252+
"""
253+
This test is based on an actual NIRSpec exposure that has some pixels
254+
flagged as saturated in one or more groups, which the jump step is
255+
supposed to ignore, but an old version of the code was setting JUMP flags
256+
for some of the saturated groups. This is to verify that the saturated
257+
groups are no longer flagged with jumps.
258+
"""
259+
grouptime = 3.0
260+
ingain = 1.0
261+
inreadnoise = 10.7
262+
ngroups = 7
263+
nrows = 6
264+
ncols = 6
265+
266+
model, rnoise, gain = setup_inputs(ngroups=ngroups, nints=1, nrows=nrows,
267+
ncols=ncols, gain=ingain,
268+
readnoise=inreadnoise, deltatime=grouptime)
269+
270+
# Setup the needed input pixel and DQ values
271+
model.data[0, :, 1, 1] = [639854.75, 4872.451, -17861.791, 14022.15, 22320.176,
272+
1116.3828, 1936.9746]
273+
model.groupdq[0, :, 1, 1] = [0, 0, 0, 0, 0, 2, 2]
274+
model.data[0, :, 2, 2] = [8.25666812e+05, -1.10471914e+05, 1.95755371e+02, 1.83118457e+03,
275+
1.72250879e+03, 1.81733496e+03, 1.65188281e+03]
276+
# 2 non-sat groups means only 1 non-sat diff, so no jumps should be flagged
277+
model.groupdq[0, :, 2, 2] = [0, 0, 2, 2, 2, 2, 2]
278+
model.data[0, :, 3, 3] = [1228767., 46392.234, -3245.6553, 7762.413,
279+
37190.76, 266611.62, 5072.4434]
280+
model.groupdq[0, :, 3, 3] = [0, 0, 0, 0, 0, 0, 2]
281+
282+
# run jump detection
283+
out_model = run_detect_jumps(model, gain, rnoise, rejection_thresh=200.0, three_grp_thresh=200,
284+
four_grp_thresh=200,
285+
max_cores=None, max_jump_to_flag_neighbors=200,
286+
min_jump_to_flag_neighbors=10, flag_4_neighbors=True)
287+
288+
# Check the results. There should not be any pixels with DQ values of 6, which
289+
# is saturated (2) plus jump (4). All the DQ's should be either just 2 or just 4.
290+
assert_array_equal(out_model.groupdq[0, :, 1, 1], [0, 4, 4, 4, 0, 2, 2])
291+
# assert that no groups are flagged when theres only 1 non-sat. grp
292+
assert_array_equal(out_model.groupdq[0, :, 2, 2], [0, 0, 2, 2, 2, 2, 2])
293+
assert_array_equal(out_model.groupdq[0, :, 3, 3], [0, 4, 4, 0, 0, 4, 2])
294294

295295

296296
@pytest.mark.skip(reason='multiprocessing temporarily disabled')

0 commit comments

Comments
 (0)