Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mwregan2 committed Jan 29, 2024
1 parent 8f30516 commit be254e7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stcal/jump/twopoint_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def find_crs(
row = cr_row[j]
col = cr_col[j]
if e_jump_4d[intg, group - 1, row, col] >= cthres[row, col]:
for kk in range(group, min(group + cgroup + 1, ngroups)):
for kk in range(group + 1, min(group + cgroup + 1, ngroups)):
if (gdq[intg, kk, row, col] & sat_flag) == 0 and (
gdq[intg, kk, row, col] & dnu_flag
) == 0:
Expand Down
46 changes: 46 additions & 0 deletions tests/test_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,52 @@ def test_multiprocessing():
assert gdq[0, 4, 6, 1] == DQFLAGS['DO_NOT_USE'] #This value would have been 5 without the fix.


def test_multiprocessing_big():
nints = 1
nrows = 2048
ncols = 7
ngroups = 13
readnoise = 10
frames_per_group = 1

data = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.float32)
readnoise_2d = np.ones((nrows, ncols), dtype=np.float32) * readnoise
gain_2d = np.ones((nrows, ncols), dtype=np.float32) * 4
gdq = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.uint32)
pdq = np.zeros(shape=(nrows, ncols), dtype=np.uint32)
err = np.zeros(shape=(nrows, ncols), dtype=np.float32)
num_cores = "1"
data[0, 4:, 204, 5] = 2000
gdq[0, 4:, 204, 6] = DQFLAGS['DO_NOT_USE']
gdq, pdq, total_primary_crs, number_extended_events, stddev = detect_jumps(
frames_per_group, data, gdq, pdq, err, gain_2d, readnoise_2d, rejection_thresh=5, three_grp_thresh=6,
four_grp_thresh=7, max_cores=num_cores, max_jump_to_flag_neighbors=10000, min_jump_to_flag_neighbors=100,
flag_4_neighbors=True, dqflags=DQFLAGS)
print(data[0, 4, :, :])
print(gdq[0, 4, :, :])
assert gdq[0, 4, 204, 5] == DQFLAGS['JUMP_DET']
assert gdq[0, 4, 205, 5] == DQFLAGS['JUMP_DET']
assert gdq[0, 4, 204, 6] == DQFLAGS['DO_NOT_USE']

# This section of code will fail without the fixes for PR #239 that prevent
# the double flagging pixels with jump which already have do_not_use or saturation set.
num_cores = "10"
data = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.float32)
gdq = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.uint32)
pdq = np.zeros(shape=(nrows, ncols), dtype=np.uint32)
readnoise_2d = np.ones((nrows, ncols), dtype=np.float32) * readnoise
gain_2d = np.ones((nrows, ncols), dtype=np.float32) * 3
err = np.zeros(shape=(nrows, ncols), dtype=np.float32)
data[0, 4:, 204, 5] = 2000
gdq[0, 4:, 204, 6] = DQFLAGS['DO_NOT_USE']
gdq, pdq, total_primary_crs, number_extended_events, stddev = detect_jumps(
frames_per_group, data, gdq, pdq, err, gain_2d, readnoise_2d, rejection_thresh=5, three_grp_thresh=6,
four_grp_thresh=7, max_cores=num_cores, max_jump_to_flag_neighbors=10000, min_jump_to_flag_neighbors=100,
flag_4_neighbors=True, dqflags=DQFLAGS)
assert gdq[0, 4, 204, 5] == DQFLAGS['JUMP_DET']
assert gdq[0, 4, 205, 5] == DQFLAGS['JUMP_DET']
assert gdq[0, 4, 204, 6] == DQFLAGS['DO_NOT_USE'] #This value would have been 5 without the fix.



def test_find_simple_ellipse():
Expand Down

0 comments on commit be254e7

Please sign in to comment.