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-25990: Reprocess HSC COSMOS medium dataset with ap_pipe #419

Merged
merged 1 commit into from
Nov 12, 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
19 changes: 18 additions & 1 deletion python/lsst/pipe/tasks/imageDifference.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ class ImageDifferenceConfig(pipeBase.PipelineTaskConfig,
doc="Convolve science image by its PSF before PSF-matching?")
doScaleTemplateVariance = pexConfig.Field(dtype=bool, default=False,
doc="Scale variance of the template before PSF matching")
doScaleDiffimVariance = pexConfig.Field(dtype=bool, default=False,
doc="Scale variance of the diffim before PSF matching. "
"You may do either this or template variance scaling, "
"or neither. (Doing both is a waste of CPU.)")
useGaussianForPreConvolution = pexConfig.Field(dtype=bool, default=True,
doc="Use a simple gaussian PSF model for pre-convolution "
"(else use fit PSF)? Ignored if doPreConvolve false.")
Expand Down Expand Up @@ -323,6 +327,9 @@ def validate(self):
if hasattr(self.getTemplate, "coaddName"):
if self.getTemplate.coaddName != self.coaddName:
raise ValueError("Mis-matched coaddName and getTemplate.coaddName in the config.")
if self.doScaleDiffimVariance and self.doScaleTemplateVariance:
raise ValueError("Scaling the diffim variance and scaling the template variance "
"are both set. Please choose one or the other.")


class ImageDifferenceTaskRunner(pipeBase.ButlerInitializedTaskRunner):
Expand Down Expand Up @@ -353,7 +360,7 @@ def __init__(self, butler=None, **kwargs):
if self.config.subtract.name == 'al' and self.config.doDecorrelation:
self.makeSubtask("decorrelate")

if self.config.doScaleTemplateVariance:
if self.config.doScaleTemplateVariance or self.config.doScaleDiffimVariance:
self.makeSubtask("scaleVariance")

if self.config.doUseRegister:
Expand Down Expand Up @@ -601,8 +608,10 @@ def run(self, exposure=None, selectSources=None, templateExposure=None, template

if self.config.doSubtract:
if self.config.doScaleTemplateVariance:
self.log.info("Rescaling template variance")
templateVarFactor = self.scaleVariance.run(
templateExposure.getMaskedImage())
self.log.info("Template variance scaling factor: %.2f" % templateVarFactor)
self.metadata.add("scaleTemplateVarianceFactor", templateVarFactor)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a log message stating the template variance scaling that is being used.


if self.config.subtract.name == 'zogy':
Expand Down Expand Up @@ -863,6 +872,14 @@ def run(self, exposure=None, selectSources=None, templateExposure=None, template
# END (if self.config.doSubtract)
if self.config.doDetection:
self.log.info("Running diaSource detection")

# Rescale difference image variance plane
if self.config.doScaleDiffimVariance:
self.log.info("Rescaling diffim variance")
diffimVarFactor = self.scaleVariance.run(subtractedExposure.getMaskedImage())
self.log.info("Diffim variance scaling factor: %.2f" % diffimVarFactor)
self.metadata.add("scaleDiffimVarianceFactor", diffimVarFactor)

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a log message stating the difference image variance scaling that is being used.

# Erase existing detection mask planes
mask = subtractedExposure.getMaskedImage().getMask()
mask &= ~(mask.getPlaneBitMask("DETECTED") | mask.getPlaneBitMask("DETECTED_NEGATIVE"))
Expand Down