Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-2944: Limit major axis expansion for MIRI shower flagging #123

Merged
merged 14 commits into from
Oct 14, 2022
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dark_current

jump
~~~~
-- Changes to limit the expansion of MIRI shower ellipses to be the same
hbushouse marked this conversation as resolved.
Show resolved Hide resolved
number of pixels for both the major and minor axis. JP-2944 [#123]

- Changes to flag both NIR snowballs and MIRI showers
for JP-#2645. [#118]
Expand Down
16 changes: 12 additions & 4 deletions src/stcal/jump/jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,19 @@ def extend_ellipses(plane, ellipses, sat_flag, jump_flag, expansion=1.1):
for ellipse in ellipses:
ceny = ellipse[0][0]
cenx = ellipse[0][1]
majaxis = ellipse[1][0] * expansion
minaxis = ellipse[1][1] * expansion
# Expand the ellipse by the expansion factor. The number of pixels added to both axes is
# the number of pixels added to the minor axis. This prevents very large flagged ellipses
# with high axis ratio ellipses. The major and minor axis are not always the same index.
# Therefore, we have to test to find which is actually the minor axis.
if ellipse[1][1] < ellipse[1][0]:
axis1 = ellipse[1][0] + (expansion - 1.0) * ellipse[1][1]
axis2 = ellipse[1][1] * expansion
else:
axis1 = ellipse[1][0] * expansion
axis2 = ellipse[1][1] + (expansion - 1.0) * ellipse[1][0]
alpha = ellipse[2]
image = cv.ellipse(image, (round(ceny), round(cenx)), (round(majaxis / 2),
round(minaxis / 2)), alpha, 0, 360, (0, 0, 4), -1)
image = cv.ellipse(image, (round(ceny), round(cenx)), (round(axis1 / 2),
round(axis2 / 2)), alpha, 0, 360, (0, 0, 4), -1)
jump_ellipse = image[:, :, 2]
saty, satx = np.where(sat_pix == 2)
jump_ellipse[saty, satx] = 0
Expand Down