Skip to content

Commit

Permalink
adjusting for jumps in electrons not DNs
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Aug 10, 2022
1 parent b787de4 commit 316ca6f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
23 changes: 13 additions & 10 deletions src/stcal/jump/jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def detect_jumps(frames_per_group, data, gdq, pdq, err,
data *= gain_2d
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

# Apply the 2-point difference method as a first pass
log.info('Executing two-point difference method')
Expand Down Expand Up @@ -168,9 +171,9 @@ def detect_jumps(frames_per_group, data, gdq, pdq, err,
three_grp_thresh, four_grp_thresh, frames_per_group,
flag_4_neighbors, max_jump_to_flag_neighbors,
min_jump_to_flag_neighbors, dqflags,
after_jump_flag_dn1=after_jump_flag_dn1,
after_jump_flag_e1=after_jump_flag_e1,
after_jump_flag_n1=after_jump_flag_n1,
after_jump_flag_dn2=after_jump_flag_dn2,
after_jump_flag_e2=after_jump_flag_e2,
after_jump_flag_n2=after_jump_flag_n2)

elapsed = time.time() - start
Expand All @@ -196,10 +199,10 @@ def detect_jumps(frames_per_group, data, gdq, pdq, err,
rejection_thresh, three_grp_thresh, four_grp_thresh,
frames_per_group, flag_4_neighbors,
max_jump_to_flag_neighbors,
min_jump_to_flag_neighbors,
after_jump_flag_dn1, after_jump_flag_n1,
after_jump_flag_dn2, after_jump_flag_n2,
dqflags, copy_arrs))
min_jump_to_flag_neighbors, dqflags,
after_jump_flag_e1, after_jump_flag_n1,
after_jump_flag_e2, after_jump_flag_n2,
copy_arrs))

# last slice get the rest
slices.insert(n_slices - 1, (data[:, :, (n_slices - 1) * yinc:n_rows, :],
Expand All @@ -208,10 +211,10 @@ def detect_jumps(frames_per_group, data, gdq, pdq, err,
rejection_thresh, three_grp_thresh,
four_grp_thresh, frames_per_group,
flag_4_neighbors, max_jump_to_flag_neighbors,
min_jump_to_flag_neighbors,
after_jump_flag_dn1, after_jump_flag_n1,
after_jump_flag_dn2, after_jump_flag_n2,
dqflags, copy_arrs))
min_jump_to_flag_neighbors, dqflags,
after_jump_flag_e1, after_jump_flag_n1,
after_jump_flag_e2, after_jump_flag_n2,
copy_arrs))
log.info("Creating %d processes for jump detection " % n_slices)
pool = multiprocessing.Pool(processes=n_slices)
# Starts each slice in its own process. Starmap allows more than one
Expand Down
20 changes: 11 additions & 9 deletions src/stcal/jump/twopoint_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def find_crs(dataa, group_dq, read_noise, rejection_thresh,
two_diff_rej_thresh, three_diff_rej_thresh, nframes,
flag_4_neighbors, max_jump_to_flag_neighbors,
min_jump_to_flag_neighbors, dqflags,
after_jump_flag_dn1=0.0,
after_jump_flag_e1=0.0,
after_jump_flag_n1=0,
after_jump_flag_dn2=0.0,
after_jump_flag_e2=0.0,
after_jump_flag_n2=0,
copy_arrs=True):

Expand Down Expand Up @@ -63,16 +63,16 @@ def find_crs(dataa, group_dq, read_noise, rejection_thresh,
A dictionary with at least the following keywords:
DO_NOT_USE, SATURATED, JUMP_DET, NO_GAIN_VALUE, GOOD
after_jump_flag_dn1 : float
1st flag after jumps with the specified DN jump
after_jump_flag_e1 : float
1st flag after jumps with the specified electron jump
to remove the transient seen from the slope calculation
after_jump_flag_n1 : int
1st flag n groups after companion threshold
to remove the transient seen from the slope calculation
after_jump_flag_dn2 : float
2nd flag after jumps with the specified DN jump
after_jump_flag_e2 : float
2nd flag after jumps with the specified electron jump
to remove the transient seen from the slope calculation
after_jump_flag_n2 : int
Expand Down Expand Up @@ -283,7 +283,7 @@ def find_crs(dataa, group_dq, read_noise, rejection_thresh,
np.bitwise_or(gdq[integ, group, row, col + 1], jump_flag)

# flag n groups after all jumps to account for the transient seen
flag_dn_threshold = [after_jump_flag_dn1, after_jump_flag_dn2]
flag_dn_threshold = [after_jump_flag_e1, after_jump_flag_e2]
flag_groups = [after_jump_flag_n1, after_jump_flag_n2]
# ensure the smallest threshold is 1st
# if flag_dn_threshold[0] > flag_dn_threshold[1]:
Expand Down Expand Up @@ -311,13 +311,15 @@ def find_crs(dataa, group_dq, read_noise, rejection_thresh,

for cthres, cgroup in zip(flag_dn_threshold, flag_groups):
if cgroup > 0:
log.info(f"Flagging {cgroup} groups after detected jumps with DN >= {cthres}.")
log.info(f"Flagging {cgroup} groups after detected jumps with e >= {np.mean(cthres)}.")

for j in range(len(cr_group)):
group = cr_group[j]
row = cr_row[j]
col = cr_col[j]
if dn_jump[group - 1, row, col] >= cthres:
if dn_jump[group - 1, row, col] >= cthres[row, col]:
# print("stcal ", group, group + cgroup + 1,
# dn_jump[group - 1, row, col], cthres[row, col])
for kk in range(group, min(group + cgroup + 1, ngroups)):
if (gdq[integ, kk, row, col] & sat_flag) == 0:
if (gdq[integ, kk, row, col] & dnu_flag) == 0:
Expand Down

0 comments on commit 316ca6f

Please sign in to comment.