From 58f659557c29c0e45c78b87c1e88b6e87285b026 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Thu, 28 Apr 2022 14:48:58 +0100 Subject: [PATCH] Exclude first & last pixel of each shadowed stripe --- src/cal_tools/agipdutils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cal_tools/agipdutils.py b/src/cal_tools/agipdutils.py index c5063106f..7fd779456 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 -- GitLab