Skip to content

Commit

Permalink
Add doRepair config to CharacterizeImage
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyers314 committed Nov 30, 2023
1 parent 3637e94 commit 0f2a059
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0f2a059

Please sign in to comment.