Skip to content
Open
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
10 changes: 8 additions & 2 deletions python/lsst/pipe/tasks/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ class TooManyCosmicRays(pipeBase.AlgorithmError):
----------
maxCosmicRays : `int`
Maximum number of cosmic rays allowed.
maxCosmicRaySpans : `int`
Maximum number of cosmic ray spans allowed.
"""
def __init__(self, maxCosmicRays, **kwargs):
def __init__(self, maxCosmicRays, maxCosmicRaySpans=-1, **kwargs):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, so it's not an API change?

msg = f"Cosmic ray task found more than {maxCosmicRays} cosmics."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message should be updated (to either identify which condition wasn't met or at least indicate it was one of two...)

self.msg = msg
self._metadata = kwargs
super().__init__(msg, **kwargs)
self._metadata["maxCosmicRays"] = maxCosmicRays
self._metadata["maxCosmicRaySpans"] = maxCosmicRaySpans

def __str__(self):
# Exception doesn't handle **kwargs, so we need a custom str.
Expand Down Expand Up @@ -231,7 +234,10 @@ def cosmicRay(self, exposure, keepCRs=None):
keepCRs,
)
except LengthError:
raise TooManyCosmicRays(self.config.cosmicray.nCrPixelMax) from None
raise TooManyCosmicRays(
self.config.cosmicray.nCrPixelMax,
maxCosmicRaySpans=self.config.cosmicray.nCrSpanMax,
) from None

if modelBg:
# Add back background image
Expand Down
Loading