Skip to content

Commit

Permalink
adds a check for saturation bias in group 2 for nframes > 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
penaguerrero committed May 21, 2024
1 parent 6739c1c commit 562b19c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/stcal/saturation/saturation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


def flag_saturated_pixels(
data, gdq, pdq, sat_thresh, sat_dq, atod_limit, dqflags, n_pix_grow_sat=1, zframe=None, read_pattern=None
):
data, gdq, pdq, sat_thresh, sat_dq, atod_limit, dqflags, nframes,
n_pix_grow_sat=1, zframe=None, read_pattern=None):
"""
Short Summary
-------------
Expand Down Expand Up @@ -43,6 +43,9 @@ def flag_saturated_pixels(
A dictionary with at least the following keywords:
DO_NOT_USE, SATURATED, AD_FLOOR, NO_SAT_CHECK
nframes : int
Number of frames per group.
n_pix_grow_sat : int
Number of pixels that each flagged saturated pixel should be 'grown',
to account for charge spilling. Default is 1.
Expand Down Expand Up @@ -96,6 +99,19 @@ def flag_saturated_pixels(
# and all following planes.
np.bitwise_or(gdq[ints, group:, :, :], flagarray, gdq[ints, group:, :, :])

if group == 2 and nframes > 1:
# Look for pixels for which SATURATION is set in group 3. If the count
# value in group 1 is less than 1/10 of the value that would be required
# to trigger SATURATION (i.e., it isn't obviously a very bright source),
# then also set the SATURATION flag for this pixel in group 2.
saturation_in_goup3 = np.where(gdq[:, 2, ...] == saturated, True, False)
if np.any(saturation_in_goup3):
sat_nints, _, _ = np.shape(saturation_in_goup3)
for ni in range(sat_nints):
satgp3mask = saturation_in_goup3[ni]
gdq[ni, 1][satgp3mask] = np.where(data[ni, 0][satgp3mask] < sat_thresh/10.,
saturated, gdq[ni, 1][satgp3mask])

# for A/D floor, the flag is only set of the current plane
np.bitwise_or(gdq[ints, group, :, :], flaglowarray, gdq[ints, group, :, :])

Expand Down

0 comments on commit 562b19c

Please sign in to comment.