8000 Fix _apply_sky in skymatch for single group input by mcara · Pull Request #5440 · spacetelescope/jwst · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix _apply_sky in skymatch for single group input #5440

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

Merged
merged 2 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ saturation
NO_SAT_CHECK in the saturation reference file, instead of skipping any
test of those pixels. [#5394]

skymatch
--------

- Fix a bug in ``skymatch`` that would result in a crash when ``skymethod``
contains ``'global'`` and the *single image group*'s sky cannot be computed
(e.g., because all pixels are flagged as "bad"). [#5440]

0.17.1 (2020-09-15)
===================

Expand Down
1 change: 0 additions & 1 deletion jwst/skymatch/skyimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def sky(self):
def sky(self, sky):
self._sky = sky


@property
def is_sky_valid(self):
"""
Expand Down
16 changes: 7 additions & 9 deletions jwst/skymatch/skymatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ def match(images, skymethod='global+match', match_down=True, subtract=False):
log.info(" ")
if minsky is None:
log.warning(" Unable to compute \"global\" sky value")
sky_deltas = len(sky_deltas) * [None]
else:
sky_deltas = len(sky_deltas) * [minsky]
sky_deltas = len(sky_deltas) * [minsky]
log.info(" \"Global\" sky value correction: {} "
"[not converted]".format(minsky))

Expand All @@ -383,23 +381,23 @@ def match(images, skymethod='global+match', match_down=True, subtract=False):

def _apply_sky(images, sky_deltas, do_global, do_skysub, show_old):
for img, sky in zip(images, sky_deltas):
img_type = 'Image' if isinstance(img, SkyImage) else 'Group'
is_group = not isinstance(img, SkyImage)

if do_global:
if sky is None:
valid = img.is_sky_valid
valid = img[0].is_sky_valid if is_group else img.is_sky_valid
sky = 0.0
else:
valid = True

else:
valid = sky is None
if valid:
valid = sky is not None
if not valid:
log.warning(" * {:s} ID={}: Unable to compute sky value"
.format(img_type, img.id))
.format('Group' if is_group else 'Image', img.id))
sky = 0.0

if img_type == 'Group':
if is_group:
# apply sky change:
old_img_sky = [im.sky for im in img]
if do_skysub:
Expand Down
0