From c4b248578f9ada360ba8c414db4704f4655b20bc Mon Sep 17 00:00:00 2001 From: Josh Meyers Date: Fri, 3 Nov 2023 16:42:11 -0700 Subject: [PATCH] Add doRepair config to CharacterizeImage --- python/lsst/pipe/tasks/characterizeImage.py | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/python/lsst/pipe/tasks/characterizeImage.py b/python/lsst/pipe/tasks/characterizeImage.py index c5d0513699..91db66e434 100644 --- a/python/lsst/pipe/tasks/characterizeImage.py +++ b/python/lsst/pipe/tasks/characterizeImage.py @@ -198,6 +198,11 @@ class CharacterizeImageConfig(pipeBase.PipelineTaskConfig, target=MeasurePsfTask, doc="Measure PSF", ) + doRepair = pexConfig.Field( + dtype=bool, + default=True, + doc="Repair image? (interpolate over cosmic rays)", + ) repair = pexConfig.ConfigurableField( target=RepairTask, doc="Remove cosmic rays", @@ -423,8 +428,9 @@ def run(self, exposure, exposureIdInfo=None, background=None, idGenerator=None): self.display("psf", exposure=dmeRes.exposure, sourceCat=dmeRes.sourceCat) # perform final repair with final PSF - self.repair.run(exposure=dmeRes.exposure) - self.display("repair", exposure=dmeRes.exposure, sourceCat=dmeRes.sourceCat) + if self.config.doRepair: + self.repair.run(exposure=dmeRes.exposure) + self.display("repair", exposure=dmeRes.exposure, sourceCat=dmeRes.sourceCat) # mask streaks if self.config.doMaskStreaks: @@ -513,16 +519,17 @@ def detectMeasureAndEstimatePsf(self, exposure, idGenerator, background): self.installSimplePsf.run(exposure=exposure) # run repair, but do not interpolate over cosmic rays (do that elsewhere, with the final PSF model) - if self.config.requireCrForPsf: - self.repair.run(exposure=exposure, keepCRs=True) - else: - try: + if self.config.doRepair: + if self.config.requireCrForPsf: self.repair.run(exposure=exposure, keepCRs=True) - except LengthError: - self.log.warning("Skipping cosmic ray detection: Too many CR pixels (max %0.f)", - self.config.repair.cosmicray.nCrPixelMax) + else: + try: + self.repair.run(exposure=exposure, keepCRs=True) + except LengthError: + self.log.warning("Skipping cosmic ray detection: Too many CR pixels (max %0.f)", + self.config.repair.cosmicray.nCrPixelMax) - self.display("repair_iter", exposure=exposure) + self.display("repair_iter", exposure=exposure) if background is None: background = BackgroundList()