From f011e93184d2a28da9abf5af8896ff0aeaf5e3c9 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Thu, 25 Jan 2024 11:01:41 -0500 Subject: [PATCH 01/19] Update jump.py --- src/stcal/jump/jump.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 6139d103..ac58b886 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -427,6 +427,13 @@ def detect_jumps( # save the neighbors to be flagged that will be in the next slice previous_row_above_gdq = row_above_gdq.copy() k += 1 + # remove redundant bits in pixels that have jump flagged but were + # already flagged as do_not_use or saturated. + gdq[gdq == np.bitwise_or(dqflags['DO_NOT_USE'], dqflags['JUMP_DET'])] = \ + dqflags['DO_NOT_USE'] + gdq[gdq == np.bitwise_or(dqflags['SATURATED'], dqflags['JUMP_DET'])] = \ + dqflags['SATURATED'] + # This is the flag that controls the flagging of snowballs. if expand_large_events: total_snowballs = flag_large_events( From 623934a70eb651e8ce36c3af176629efc036c5ec Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Thu, 25 Jan 2024 11:03:32 -0500 Subject: [PATCH 02/19] Update jump.py --- src/stcal/jump/jump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index ac58b886..59c25936 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -314,7 +314,7 @@ def detect_jumps( log.info("Total showers= %i", num_showers) number_extended_events = num_showers else: - yinc = int(n_rows / n_slices) + yinc = int(n_rows // n_slices) slices = [] # Slice up data, gdq, readnoise_2d into slices # Each element of slices is a tuple of From c0ff94a090534b847137f3b36f43397b58cc7a11 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Thu, 25 Jan 2024 14:17:00 -0500 Subject: [PATCH 03/19] Update CHANGES.rst --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index b22ce3e2..7976861e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -86,6 +86,9 @@ jump - Added more allowable selections for the number of cores to use for multiprocessing [#183]. +- Fixed the numer of rows per slice in multiprocessing that lead to + different results when running the step with multiprocess [#239] + ramp_fitting ~~~~~~~~~~~~ From c5c0248dde98cd2d0005fe6f4c706b78d5ea7b53 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Thu, 25 Jan 2024 14:53:35 -0500 Subject: [PATCH 04/19] Update CHANGES.rst --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7976861e..48d9eda8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -86,8 +86,8 @@ jump - Added more allowable selections for the number of cores to use for multiprocessing [#183]. -- Fixed the numer of rows per slice in multiprocessing that lead to - different results when running the step with multiprocess [#239] +- Fixed the computation of the number of rows per slice for multiprocessing, + which caused different results when running the step with multiprocess [#239] ramp_fitting ~~~~~~~~~~~~ From 8f30516d93302bdd04226ff21de018e0fa657e03 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Fri, 26 Jan 2024 14:53:55 -0500 Subject: [PATCH 05/19] Add unit test for the double flagging of pixels --- src/stcal/jump/jump.py | 8 +++---- tests/test_jump.py | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 59c25936..eea6ce43 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -427,11 +427,11 @@ def detect_jumps( # save the neighbors to be flagged that will be in the next slice previous_row_above_gdq = row_above_gdq.copy() k += 1 - # remove redundant bits in pixels that have jump flagged but were - # already flagged as do_not_use or saturated. - gdq[gdq == np.bitwise_or(dqflags['DO_NOT_USE'], dqflags['JUMP_DET'])] = \ + # remove redundant bits in pixels that have jump flagged but were + # already flagged as do_not_use or saturated. + gdq[gdq == np.bitwise_or(dqflags['DO_NOT_USE'], dqflags['JUMP_DET'])] = \ dqflags['DO_NOT_USE'] - gdq[gdq == np.bitwise_or(dqflags['SATURATED'], dqflags['JUMP_DET'])] = \ + gdq[gdq == np.bitwise_or(dqflags['SATURATED'], dqflags['JUMP_DET'])] = \ dqflags['SATURATED'] # This is the flag that controls the flagging of snowballs. diff --git a/tests/test_jump.py b/tests/test_jump.py index 0ddbefb1..ccd450c8 100644 --- a/tests/test_jump.py +++ b/tests/test_jump.py @@ -8,6 +8,7 @@ find_faint_extended, flag_large_events, point_inside_ellipse, + detect_jumps, ) DQFLAGS = {"JUMP_DET": 4, "SATURATED": 2, "DO_NOT_USE": 1, "GOOD": 0, "NO_GAIN_VALUE": 8} @@ -30,6 +31,53 @@ def _cube(ngroups, readnoise=10): return _cube +def test_multiprocessing(): + nints = 1 + nrows = 13 + ncols = 2 + 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:, 5, 1] = 2000 + gdq[0, 4:, 6, 1] = 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, 5, 1] == DQFLAGS['JUMP_DET'] + assert gdq[0, 4, 6, 1] == 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 = "5" + 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:, 5, 1] = 2000 + gdq[0, 4:, 6, 1] = 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, 5, 1] == DQFLAGS['JUMP_DET'] + assert gdq[0, 4, 6, 1] == DQFLAGS['DO_NOT_USE'] #This value would have been 5 without the fix. + + + + def test_find_simple_ellipse(): plane = np.zeros(shape=(5, 5), dtype=np.uint8) plane[2, 2] = DQFLAGS["JUMP_DET"] From be254e7dfe5f63f00dde0f96cc8d59e34936e632 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Mon, 29 Jan 2024 16:33:41 -0500 Subject: [PATCH 06/19] fixes --- src/stcal/jump/twopoint_difference.py | 2 +- tests/test_jump.py | 46 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index 62d44b1a..970be369 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -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: diff --git a/tests/test_jump.py b/tests/test_jump.py index ccd450c8..a85eef51 100644 --- a/tests/test_jump.py +++ b/tests/test_jump.py @@ -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(): From 35d808624030c56e17b82a1bc14588f08b321ff4 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Mon, 29 Jan 2024 17:20:51 -0500 Subject: [PATCH 07/19] Update jump.py --- src/stcal/jump/jump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index eea6ce43..eca264a4 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -333,7 +333,7 @@ def detect_jumps( i, ( data[:, :, i * yinc : (i + 1) * yinc, :], - gdq[:, :, i * yinc : (i + 1) * yinc, :], + gdq[:, :, i * yinc : (i + 1) * yinc, :].copy(), readnoise_2d[i * yinc : (i + 1) * yinc, :], rejection_thresh, three_grp_thresh, @@ -359,7 +359,7 @@ def detect_jumps( n_slices - 1, ( data[:, :, (n_slices - 1) * yinc : n_rows, :], - gdq[:, :, (n_slices - 1) * yinc : n_rows, :], + gdq[:, :, (n_slices - 1) * yinc : n_rows, :].copy(), readnoise_2d[(n_slices - 1) * yinc : n_rows, :], rejection_thresh, three_grp_thresh, From d4d36402820f6374542ca781e338dcf484a1066e Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Mon, 29 Jan 2024 17:23:10 -0500 Subject: [PATCH 08/19] Update jump.py --- src/stcal/jump/jump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index eca264a4..923c766b 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -359,7 +359,7 @@ def detect_jumps( n_slices - 1, ( data[:, :, (n_slices - 1) * yinc : n_rows, :], - gdq[:, :, (n_slices - 1) * yinc : n_rows, :].copy(), + gdq[:, :, (n_slices - 1) * yinc : n_rows, :].copy() , readnoise_2d[(n_slices - 1) * yinc : n_rows, :], rejection_thresh, three_grp_thresh, From 8f9c6eded668183d576b64f766925314211467c1 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Mon, 29 Jan 2024 17:24:32 -0500 Subject: [PATCH 09/19] Update jump.py --- src/stcal/jump/jump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 923c766b..ce07cb59 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -323,11 +323,11 @@ def detect_jumps( # must copy arrays here, find_crs will make copies but if slices # are being passed in for multiprocessing then the original gdq will be - # modified unless copied beforehand + # modified unless copied beforehand. gdq = gdq.copy() data = data.copy() copy_arrs = False # we don't need to copy arrays again in find_crs - + print("this is a test") for i in range(n_slices - 1): slices.insert( i, From c2bcca944f5df623176bb3f212eb8e3d26b987a5 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 09:52:04 -0500 Subject: [PATCH 10/19] Update twopoint_difference.py --- src/stcal/jump/twopoint_difference.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index 970be369..b07c5f2d 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -412,10 +412,7 @@ def find_crs( col = cr_col[j] if e_jump_4d[intg, group - 1, row, col] >= cthres[row, col]: 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: - gdq[intg, kk, row, col] = np.bitwise_or(gdq[integ, kk, row, col], jump_flag) + gdq[intg, kk, row, col] = np.bitwise_or(gdq[integ, kk, row, col], jump_flag) if "stddev" in locals(): return gdq, row_below_gdq, row_above_gdq, num_primary_crs, stddev From f0e856ae73b4990a2371016f392b2338bbe87d09 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 10:14:12 -0500 Subject: [PATCH 11/19] Update jump.py --- src/stcal/jump/jump.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index ce07cb59..274ccac6 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -380,7 +380,9 @@ def detect_jumps( ), ) log.info("Creating %d processes for jump detection ", n_slices) - pool = multiprocessing.Pool(processes=n_slices) +# pool = multiprocessing.Pool(processes=n_slices) +######### JUST FOR DEBUGGING ######################### + pool = multiprocessing.Pool(processes=1) # Starts each slice in its own process. Starmap allows more than one # parameter to be passed. real_result = pool.starmap(twopt.find_crs, slices) From 907e25ad45b2cb15d0059764848820fbe9c557da Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 10:19:21 -0500 Subject: [PATCH 12/19] Update twopoint_difference.py --- src/stcal/jump/twopoint_difference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index b07c5f2d..b394832f 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -401,7 +401,7 @@ def find_crs( # the transient seen after ramp jumps flag_e_threshold = [after_jump_flag_e1, after_jump_flag_e2] flag_groups = [after_jump_flag_n1, after_jump_flag_n2] - + print("starting flagging after jump") for cthres, cgroup in zip(flag_e_threshold, flag_groups): if cgroup > 0: cr_intg, cr_group, cr_row, cr_col = np.where(np.bitwise_and(gdq, jump_flag)) From 9c7d6147ae74c2c1f7804a60f208d978f7012740 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 10:32:48 -0500 Subject: [PATCH 13/19] Update twopoint_difference.py --- src/stcal/jump/twopoint_difference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index b394832f..af950a10 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -412,7 +412,7 @@ def find_crs( col = cr_col[j] if e_jump_4d[intg, group - 1, row, col] >= cthres[row, col]: for kk in range(group + 1, min(group + cgroup + 1, ngroups)): - gdq[intg, kk, row, col] = np.bitwise_or(gdq[integ, kk, row, col], jump_flag) + gdq[intg, kk, row, col] = np.bitwise_or(gdq[intg, kk, row, col], jump_flag) if "stddev" in locals(): return gdq, row_below_gdq, row_above_gdq, num_primary_crs, stddev From 2c8d36003d62228f3c7072f4af71c440e09097d6 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 10:33:50 -0500 Subject: [PATCH 14/19] Update jump.py --- src/stcal/jump/jump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 274ccac6..016017b4 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -380,9 +380,9 @@ def detect_jumps( ), ) log.info("Creating %d processes for jump detection ", n_slices) -# pool = multiprocessing.Pool(processes=n_slices) + pool = multiprocessing.Pool(processes=n_slices) ######### JUST FOR DEBUGGING ######################### - pool = multiprocessing.Pool(processes=1) +# pool = multiprocessing.Pool(processes=1) # Starts each slice in its own process. Starmap allows more than one # parameter to be passed. real_result = pool.starmap(twopt.find_crs, slices) From efd4abcae2face69d00a8860cf8e45579bf48243 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 12:05:07 -0500 Subject: [PATCH 15/19] fixes --- src/stcal/jump/jump.py | 4 ++-- src/stcal/jump/twopoint_difference.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 016017b4..1c3dfdc6 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -235,8 +235,8 @@ def detect_jumps( err *= gain_2d readnoise_2d *= gain_2d # also apply to the after_jump thresholds - after_jump_flag_e1 = after_jump_flag_dn1 * gain_2d - after_jump_flag_e2 = after_jump_flag_dn2 * gain_2d + after_jump_flag_e1 = after_jump_flag_dn1 * np.nanmedian(gain_2d) + after_jump_flag_e2 = after_jump_flag_dn2 * np.nanmedian(gain_2d) # Apply the 2-point difference method as a first pass log.info("Executing two-point difference method") diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index af950a10..39a54fc0 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -403,7 +403,7 @@ def find_crs( flag_groups = [after_jump_flag_n1, after_jump_flag_n2] print("starting flagging after jump") for cthres, cgroup in zip(flag_e_threshold, flag_groups): - if cgroup > 0: + if cgroup > 0 and cthres > 0: cr_intg, cr_group, cr_row, cr_col = np.where(np.bitwise_and(gdq, jump_flag)) for j in range(len(cr_group)): intg = cr_intg[j] From 38d617e88ac781b961813cd392a3347a47a51cfc Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 12:16:36 -0500 Subject: [PATCH 16/19] Update twopoint_difference.py --- src/stcal/jump/twopoint_difference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index 39a54fc0..5e118a1f 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -410,7 +410,7 @@ def find_crs( group = cr_group[j] row = cr_row[j] col = cr_col[j] - if e_jump_4d[intg, group - 1, row, col] >= cthres[row, col]: + if e_jump_4d[intg, group - 1, row, col] >= cthres: for kk in range(group + 1, min(group + cgroup + 1, ngroups)): gdq[intg, kk, row, col] = np.bitwise_or(gdq[intg, kk, row, col], jump_flag) if "stddev" in locals(): From e5c15e2b6305d3634d01e5c46bcd040373e5c110 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 12:35:16 -0500 Subject: [PATCH 17/19] Update jump.py --- src/stcal/jump/jump.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 1c3dfdc6..d49e3b56 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -277,6 +277,12 @@ def detect_jumps( minimum_sigclip_groups=minimum_sigclip_groups, only_use_ints=only_use_ints, ) + # remove redundant bits in pixels that have jump flagged but were + # already flagged as do_not_use or saturated. + gdq[gdq == np.bitwise_or(dqflags['DO_NOT_USE'], dqflags['JUMP_DET'])] = \ + dqflags['DO_NOT_USE'] + gdq[gdq == np.bitwise_or(dqflags['SATURATED'], dqflags['JUMP_DET'])] = \ + dqflags['SATURATED'] # This is the flag that controls the flagging of snowballs. if expand_large_events: total_snowballs = flag_large_events( From 9701831129de722175bf3cba899ab1e53dae8599 Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 13:13:45 -0500 Subject: [PATCH 18/19] delete jumps --- src/stcal/jump/jump.py | 1 - src/stcal/jump/twopoint_difference.py | 1 - 2 files changed, 2 deletions(-) diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index d49e3b56..d6aeb3ad 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -333,7 +333,6 @@ def detect_jumps( gdq = gdq.copy() data = data.copy() copy_arrs = False # we don't need to copy arrays again in find_crs - print("this is a test") for i in range(n_slices - 1): slices.insert( i, diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index 5e118a1f..b9111870 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -401,7 +401,6 @@ def find_crs( # the transient seen after ramp jumps flag_e_threshold = [after_jump_flag_e1, after_jump_flag_e2] flag_groups = [after_jump_flag_n1, after_jump_flag_n2] - print("starting flagging after jump") for cthres, cgroup in zip(flag_e_threshold, flag_groups): if cgroup > 0 and cthres > 0: cr_intg, cr_group, cr_row, cr_col = np.where(np.bitwise_and(gdq, jump_flag)) From a061bdd2f95405f92394236f9c2d08a1eba3373b Mon Sep 17 00:00:00 2001 From: Mike Regan Date: Tue, 30 Jan 2024 14:05:15 -0500 Subject: [PATCH 19/19] Update test_twopoint_difference.py --- tests/test_twopoint_difference.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_twopoint_difference.py b/tests/test_twopoint_difference.py index c6443bc7..f066b4b1 100644 --- a/tests/test_twopoint_difference.py +++ b/tests/test_twopoint_difference.py @@ -855,7 +855,7 @@ def test_10grps_1cr_afterjump(setup_cube): data[0, 8, 100, 100] = 1190 data[0, 9, 100, 100] = 1209 - after_jump_flag_e1 = np.full(data.shape[2:4], 1.0) * 0.0 + after_jump_flag_e1 = 1.0 out_gdq, row_below_gdq, rows_above_gdq, total_crs, stddev = find_crs( data, gdq, @@ -891,7 +891,7 @@ def test_10grps_1cr_afterjump_2group(setup_cube): data[0, 8, 100, 100] = 1190 data[0, 9, 100, 100] = 1209 - after_jump_flag_e1 = np.full(data.shape[2:4], 1.0) * 0.0 + after_jump_flag_e1 = 1.0 out_gdq, row_below_gdq, rows_above_gdq, total_crs, stddev = find_crs( data, gdq, @@ -932,7 +932,7 @@ def test_10grps_1cr_afterjump_toosmall(setup_cube): data[0, 8, 100, 100] = 1190 data[0, 9, 100, 100] = 1209 - after_jump_flag_e1 = np.full(data.shape[2:4], 1.0) * 10000.0 + after_jump_flag_e1 = 10000.0 out_gdq, row_below_gdq, rows_above_gdq, total_crs, stddev = find_crs( data, gdq, @@ -968,8 +968,8 @@ def test_10grps_1cr_afterjump_twothresholds(setup_cube): data[0, 8, 100, 100] = 1190 data[0, 9, 100, 100] = 1209 - after_jump_flag_e1 = np.full(data.shape[2:4], 1.0) * 500.0 - after_jump_flag_e2 = np.full(data.shape[2:4], 1.0) * 10.0 + after_jump_flag_e1 = 500.0 + after_jump_flag_e2 = 10.0 out_gdq, row_below_gdq, rows_above_gdq, total_crs, stddev = find_crs( data, gdq,