diff --git a/src/cal_tools/agipdutils.py b/src/cal_tools/agipdutils.py index c5063106f5c2fe354c0a23450ab5da07a5c23ec3..7fd779456838e9e5fc12851349c2596b1c6e9354 100644 --- a/src/cal_tools/agipdutils.py +++ b/src/cal_tools/agipdutils.py @@ -131,13 +131,12 @@ def get_shadowed_stripe(data, threshold, fraction): rows_to_use = npx_sh / npx_all > fraction # TODO: is this necessary? - # The previous code excludes the first and last rows that would otherwise - # be considered shadowed, with no explanation of why. + # The previous code excludes the first and last rows of each shadowed + # stripe, before accounting for the double-width pixels. # For now, I'll preserve the behaviour. -TK - row_idxs = np.nonzero(rows_to_use)[0] - if len(row_idxs) > 0: - rows_to_use[row_idxs[0]] = False - rows_to_use[row_idxs[-1]] = False + shadow_bounds = contiguous_regions(rows_to_use) + rows_to_use[shadow_bounds[:, 0]] = False + rows_to_use[shadow_bounds[:, 1] - 1] = False # Ignore rows with double-width pixels rows_to_use[64:512:64] = False