AlardLuptonSubtractTask#

class lsst.ip.diffim.AlardLuptonSubtractTask(**kwargs)#

Bases: PipelineTask

Compute the image difference of a science and template image using the Alard & Lupton (1998) algorithm.

Methods Summary

chooseConvolutionMethod(template, science)

Determine whether the template should be convolved with the PSF matching kernel.

finalize(template, science, difference, kernel)

Decorrelate the difference image to undo the noise correlations caused by convolution.

run(template, science, sources[, visitSummary])

PSF match, subtract, and decorrelate two images.

runConvolveScience(template, science, ...[, ...])

Convolve the science image with a PSF-matching kernel and subtract the template image.

runConvolveTemplate(template, science, ...)

Convolve the template image with a PSF-matching kernel and subtract from the science image.

runKernelSourceDetection(template, science)

Run detection on the science image and use the template mask plane to reject candidate sources.

runMakeKernel(template, science[, sources, ...])

Construct the PSF-matching kernel.

runQuantum(butlerQC, inputRefs, outputRefs)

Do butler IO and transform to provide in memory objects for tasks run method.

updateMasks(template, science)

Update the science and template mask planes before differencing.

Methods Documentation

chooseConvolutionMethod(template, science)#

Determine whether the template should be convolved with the PSF matching kernel.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

Returns#

convolveTemplatebool

Convolve the template to match the two images?

Raises#

RuntimeError

If an unsupported convolution mode is supplied.

finalize(template, science, difference, kernel, templateMatched=True, preConvMode=False, preConvKernel=None, spatiallyVarying=False)#

Decorrelate the difference image to undo the noise correlations caused by convolution.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

differencelsst.afw.image.ExposureF

Result of subtracting template and science.

kernellsst.afw.math.Kernel

An (optionally spatially-varying) PSF matching kernel

templateMatchedbool, optional

Was the template PSF-matched to the science image?

preConvModebool, optional

Was the science image preconvolved with its own PSF before PSF matching the template?

preConvKernellsst.afw.detection.Psf, optional

If not None, then the science image was pre-convolved with (the reflection of) this kernel. Must be normalized to sum to 1.

spatiallyVaryingbool, optional

Compute the decorrelation kernel spatially varying across the image?

Returns#

correctedExposurelsst.afw.image.ExposureF

The decorrelated image difference.

run(template, science, sources, visitSummary=None)#

PSF match, subtract, and decorrelate two images.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

sourceslsst.afw.table.SourceCatalog

Identified sources on the science exposure. This catalog is used to select sources in order to perform the AL PSF matching on stamp images around them.

visitSummarylsst.afw.table.ExposureCatalog, optional

Exposure catalog with external calibrations to be applied. Catalog uses the detector id for the catalog id, sorted on id for fast lookup.

Returns#

resultslsst.pipe.base.Struct
differencelsst.afw.image.ExposureF

Result of subtracting template and science.

matchedTemplatelsst.afw.image.ExposureF

Warped and PSF-matched template exposure.

backgroundModellsst.afw.math.Function2D

Background model that was fit while solving for the PSF-matching kernel

psfMatchingKernellsst.afw.math.Kernel

Kernel used to PSF-match the convolved image.

``kernelSources`lsst.afw.table.SourceCatalog

Sources from the input catalog that were used to construct the PSF-matching kernel.

runConvolveScience(template, science, psfMatchingKernel, backgroundModel=None)#

Convolve the science image with a PSF-matching kernel and subtract the template image.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

psfMatchingKernellsst.afw.math.Kernel

Kernel to be used to PSF-match the science image to the template.

backgroundModellsst.afw.math.Function2D, optional

Background model that was fit while solving for the PSF-matching kernel.

Returns#

results : lsst.pipe.base.Struct

differencelsst.afw.image.ExposureF

Result of subtracting template and science.

matchedTemplatelsst.afw.image.ExposureF

Warped template exposure. Note that in this case, the template is not PSF-matched to the science image.

backgroundModellsst.afw.math.Function2D

Background model that was fit while solving for the PSF-matching kernel

psfMatchingKernellsst.afw.math.Kernel

Kernel used to PSF-match the science image to the template.

runConvolveTemplate(template, science, psfMatchingKernel, backgroundModel=None)#

Convolve the template image with a PSF-matching kernel and subtract from the science image.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

psfMatchingKernellsst.afw.math.Kernel

Kernel to be used to PSF-match the science image to the template.

backgroundModellsst.afw.math.Function2D, optional

Background model that was fit while solving for the PSF-matching kernel.

Returns#

results : lsst.pipe.base.Struct

differencelsst.afw.image.ExposureF

Result of subtracting template and science.

matchedTemplatelsst.afw.image.ExposureF

Warped and PSF-matched template exposure.

backgroundModellsst.afw.math.Function2D

Background model that was fit while solving for the PSF-matching kernel

psfMatchingKernellsst.afw.math.Kernel

Kernel used to PSF-match the template to the science image.

runKernelSourceDetection(template, science)#

Run detection on the science image and use the template mask plane to reject candidate sources.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

Returns#

kernelSourceslsst.afw.table.SourceCatalog

Sources from the input catalog to use to construct the PSF-matching kernel.

runMakeKernel(template, science, sources=None, convolveTemplate=True, runSourceDetection=False)#

Construct the PSF-matching kernel.

Parameters#

templatelsst.afw.image.ExposureF

Template exposure, warped to match the science exposure.

sciencelsst.afw.image.ExposureF

Science exposure to subtract from the template.

sourceslsst.afw.table.SourceCatalog

Identified sources on the science exposure. This catalog is used to select sources in order to perform the AL PSF matching on stamp images around them. Not used if runSourceDetection is set.

convolveTemplatebool, optional

Construct the matching kernel to convolve the template?

runSourceDetectionbool, optional

Run a minimal version of source detection to determine kernel candidates? If False, a source list to select kernel candidates from must be supplied.

Returns#

resultslsst.pipe.base.Struct
backgroundModellsst.afw.math.Function2D

Background model that was fit while solving for the PSF-matching kernel

psfMatchingKernellsst.afw.math.Kernel

Kernel used to PSF-match the convolved image.

``kernelSources`lsst.afw.table.SourceCatalog

Sources from the input catalog that were used to construct the PSF-matching kernel.

runQuantum(butlerQC, inputRefs, outputRefs)#

Do butler IO and transform to provide in memory objects for tasks run method.

Parameters#

butlerQCQuantumContext

A butler which is specialized to operate in the context of a lsst.daf.butler.Quantum.

inputRefsInputQuantizedConnection

Datastructure whose attribute names are the names that identify connections defined in corresponding PipelineTaskConnections class. The values of these attributes are the lsst.daf.butler.DatasetRef objects associated with the defined input/prerequisite connections.

outputRefsOutputQuantizedConnection

Datastructure whose attribute names are the names that identify connections defined in corresponding PipelineTaskConnections class. The values of these attributes are the lsst.daf.butler.DatasetRef objects associated with the defined output connections.

updateMasks(template, science)#

Update the science and template mask planes before differencing.

Parameters#

templatelsst.afw.image.Exposure

Template exposure, warped to match the science exposure. The template mask planes will be erased, except for a few specified in the task config.

sciencelsst.afw.image.Exposure

Science exposure to subtract from the template. The DETECTED and DETECTED_NEGATIVE mask planes of the science image will be erased.