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-26586: Skip initial cosmic ray detection if it fails #410

Merged
merged 1 commit into from
Sep 24, 2020
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
16 changes: 15 additions & 1 deletion python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from lsst.meas.deblender import SourceDeblendTask
from .measurePsf import MeasurePsfTask
from .repair import RepairTask
from lsst.pex.exceptions import LengthError

__all__ = ["CharacterizeImageConfig", "CharacterizeImageTask"]

Expand Down Expand Up @@ -185,6 +186,11 @@ class CharacterizeImageConfig(pipeBase.PipelineTaskConfig,
target=RepairTask,
doc="Remove cosmic rays",
)
requireCrForPsf = pexConfig.Field(
dtype=bool,
default=True,
doc="Require cosmic ray detection and masking to run successfully before measuring the PSF."
)
checkUnitsParseStrict = pexConfig.Field(
doc="Strictness of Astropy unit compatibility check, can be 'raise', 'warn' or 'silent'",
dtype=str,
Expand Down Expand Up @@ -545,7 +551,15 @@ def detectMeasureAndEstimatePsf(self, exposure, exposureIdInfo, background):
self.installSimplePsf.run(exposure=exposure)

# run repair, but do not interpolate over cosmic rays (do that elsewhere, with the final PSF model)
self.repair.run(exposure=exposure, keepCRs=True)
if self.config.requireCrForPsf:
self.repair.run(exposure=exposure, keepCRs=True)
else:
try:
self.repair.run(exposure=exposure, keepCRs=True)
except LengthError:
self.log.warn("Skipping cosmic ray detection: Too many CR pixels (max %0.f)" %
self.config.repair.cosmicray.nCrPixelMax)

self.display("repair_iter", exposure=exposure)

if background is None:
Expand Down