Skip to content

Commit

Permalink
Updates from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
djreiss committed Jun 28, 2016
1 parent c0da2c8 commit 4d3428d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions python/lsst/pipe/tasks/imageDifference.py
Expand Up @@ -36,7 +36,7 @@
from lsst.ip.diffim import ImagePsfMatchTask, DipoleAnalysis, \
SourceFlagChecker, KernelCandidateF, cast_KernelCandidateF, makeKernelBasisList, \
KernelCandidateQa, DiaCatalogSourceSelectorTask, DiaCatalogSourceSelectorConfig, \
GetCoaddAsTemplateTask, GetCalexpAsTemplateTask, DipoleFitTask, ImageDecorrelationTask
GetCoaddAsTemplateTask, GetCalexpAsTemplateTask, DipoleFitTask, DecorrelateALKernelTask
import lsst.ip.diffim.diffimTools as diffimTools
import lsst.ip.diffim.utils as diUtils

Expand Down Expand Up @@ -66,7 +66,7 @@ class ImageDifferenceConfig(pexConfig.Config):
"Ignored if doPreConvolve false.")
doDetection = pexConfig.Field(dtype=bool, default=True, doc="Detect sources?")
doDecorrelation = pexConfig.Field(dtype=bool, default=False,
doc="Perform diffim decorrelation to undo pixel correlation due to convolution? "
doc="Perform diffim decorrelation to undo pixel correlation due to A&L kernel convolution? "
"If True, also update the diffim PSF.")
doMerge = pexConfig.Field(dtype=bool, default=True,
doc="Merge positive and negative diaSources with grow radius set by growFootprint")
Expand Down Expand Up @@ -108,8 +108,8 @@ class ImageDifferenceConfig(pexConfig.Config):
doc="Warp and PSF match template to exposure, then subtract",
)
decorrelate = pexConfig.ConfigurableField(
target=ImageDecorrelationTask,
doc="Decorrelate image difference",
target=DecorrelateALKernelTask,
doc="Decorrelate effects of A&L kernel convolution on image difference, only if doSubtract is True",
)
detection = pexConfig.ConfigurableField(
target=SourceDetectionTask,
Expand Down Expand Up @@ -170,7 +170,9 @@ def setDefaults(self):
# DiaSource Detection
self.detection.thresholdPolarity = "both"
self.detection.thresholdValue = 5.5
if self.doDecorrelation:
# If decorrelation is turned on, no need to "hack" the detection threshold to decrease the number of
# false detections, so set it back to 5.0
if self.doDecorrelation and self.doSubtract:
self.detection.thresholdValue = 5.0
self.detection.reEstimateBackground = False
self.detection.thresholdType = "pixel_stdev"
Expand Down Expand Up @@ -522,10 +524,13 @@ def run(self, sensorRef, templateIdList=None):
template = self.getTemplate.run(exposure, sensorRef, templateIdList=templateIdList)
subtractedExposure.setPsf(template.exposure.getPsf())

# If doSubtract is False, then subtractedExposure was fetched from disk (above), thus it may have
# already been decorrelated. Thus, we do not do decorrelation if doSubtract is False.
if self.config.doDecorrelation and self.config.doSubtract:
subtractedExposure, _ = self.decorrelate.decorrelateExposure(templateExposure, exposure,
subtractedExposure,
subtractRes.psfMatchingKernel)
decorrResult = self.decorrelate.run(templateExposure, exposure,
subtractedExposure,
subtractRes.psfMatchingKernel)
subtractedExposure = decorrResult.correctedExposure

if self.config.doDetection:
self.log.info("Running diaSource detection")
Expand Down

0 comments on commit 4d3428d

Please sign in to comment.