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

DM-13408: fringe: fix test failure #46

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 15 additions & 12 deletions python/lsst/ip/isr/fringe.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,23 @@ def solve(self, science, fringes):

origNum = len(science)

def emptyResult(msg=""):
"""Generate an empty result for return to the user

There are no good pixels; doesn't matter what we return.
"""
self.log.warn("Unable to solve for fringes: no good pixels%s", msg)
out = [0]
if len(fringes) > 1:
out = out*len(fringes)
return numpy.array(out)

good = numpy.where(numpy.logical_and(numpy.isfinite(science), numpy.any(numpy.isfinite(fringes), 1)))
science = science[good]
fringes = fringes[good]
oldNum = len(science)
if oldNum == 0:
return emptyResult()

# Up-front rejection to get rid of extreme, potentially troublesome values
# (e.g., fringe apertures that fall on objects).
Expand All @@ -254,12 +267,7 @@ def solve(self, science, fringes):
fringes = fringes[good]
oldNum = len(science)
if oldNum == 0:
# No good pixels; doesn't matter what we return
self.log.warn("Unable to solve for fringes: no good pixels")
out = [0]
if len(fringes) > 1:
out = out*len(fringes)
return numpy.array(out)
return emptyResult(" after initial rejection")

for i in range(self.config.iterations):
solution = self._solve(science, fringes)
Expand All @@ -270,12 +278,7 @@ def solve(self, science, fringes):
self.log.debug("Solution %d: %s", i, solution)
newNum = good.sum()
if newNum == 0:
# No good pixels; doesn't matter what we return
self.log.warn("Unable to solve for fringes: no good pixels after %d iterations", i)
out = [0]
if len(fringes) > 1:
out = out*len(fringes)
return numpy.array(out)
return emptyResult(" after %d rejection iterations" % i)

if doPlot:
import matplotlib.pyplot as plot
Expand Down