SimplifiedSubtractTask¶
Description¶
This task implements a streamlined image differencing pipeline designed to operate without requiring an input source catalog, while optionally allowing the reuse of an existing point spread function (PSF) matching kernel. The pipeline supports two primary execution methods, each aligned with distinct scientific objectives:
Existing Kernel Method—Utilizes a previously computed PSF matching kernel to reproduce the results of a prior image differencing run.
Derived Kernel Method—Computes the PSF matching kernel internally by performing a streamlined source detection and measurement process, enabling image differencing with minimal required inputs.
Simplified Image Differencing Pipeline with the Existing Kernel Method¶
Use a local version of the AP pipeline configuration to run the pipeline by reusing a precomputed PSF matching kernel. The sample pipeline file, simpleDiffim_existingKernel.yaml, shown below, demonstrates the recommended configuration settings for this method.
description: A simplified single-visit difference image pipeline that reuses an existing PSF matching kernel to reproduce the results of a previous image differencing run.
instrument: lsst.obs.lsst.LsstCam
tasks:
rewarpTemplate:
class: lsst.ip.diffim.getTemplate.GetTemplateTask
config:
connections.bbox: preliminary_visit_image.bbox
connections.wcs: preliminary_visit_image.wcs
connections.coaddExposures: template_coadd
connections.template: template_detector
simplifiedSubtractImages:
class: lsst.ip.diffim.SimplifiedSubtractTask
config:
connections.template: template_detector
connections.science: preliminary_visit_image
connections.difference: difference_image_predetection
connections.matchedTemplate: template_matched
connections.inputPsfMatchingKernel: difference_kernel
useExistingKernel: True
detectAndMeasureDiaSource:
class: lsst.ip.diffim.detectAndMeasure.DetectAndMeasureTask
config:
connections.science: preliminary_visit_image
connections.matchedTemplate: template_matched
connections.difference: difference_image_predetection
connections.outputSchema: dia_source_schema
connections.diaSources: dia_source_unfiltered
connections.subtractedMeasuredExposure: difference_image
connections.maskedStreaks: goodSeeingDiff_streaks
doSkySources: True
doCalculateResidualMetics: False
Simplified Image Differencing Pipeline with the Derived Kernel Method¶
Alternatively, the pipeline can compute the PSF matching kernel internally by performing source detection and measurement. This method requires the minimal set of inputs necessary to execute image differencing. The sample pipeline tailored for this mode, simpleDiffim_derivedKernel.yaml, shown below, includes the recommended configuration settings for the Derived Kernel Method.
description: A simplified single-visit difference image pipeline to produce image differencing results with the minimal reqired inputs.
instrument: lsst.obs.lsst.LsstCam
tasks:
rewarpTemplate:
class: lsst.ip.diffim.getTemplate.GetTemplateTask
config:
connections.bbox: preliminary_visit_image.bbox
connections.wcs: preliminary_visit_image.wcs
connections.coaddExposures: template_coadd
connections.template: template_detector
simplifiedSubtractImages:
class: lsst.ip.diffim.SimplifiedSubtractTask
config:
connections.template: template_detector
connections.science: preliminary_visit_image
connections.difference: difference_image_predetection
connections.matchedTemplate: template_matched
connections.kernelSources: difference_kernel_sources
connections.psfMatchingKernel: difference_kernel
useExistingKernel: False
detectAndMeasureDiaSource:
class: lsst.ip.diffim.detectAndMeasure.DetectAndMeasureTask
config:
connections.science: preliminary_visit_image
connections.matchedTemplate: template_matched
connections.difference: difference_image_predetection
connections.kernelSources: difference_kernel_sources
connections.outputSchema: dia_source_schema
connections.diaSources: dia_source_unfiltered
connections.subtractedMeasuredExposure: difference_image
connections.maskedStreaks: goodSeeingDiff_streaks
doSkySources: True
doCalculateResidualMetics: True
Execute the Simplified Image Differencing Pipeline Using pipetask run¶
To execute the pipline using the pipetask run method, implement the following code:
pipetask run -b /repo/main -i /input/collections -o /your/output/collection -d "instrument='LSSTCam' and exposure=2025050100367 and detector=30 and skymap='lsst_cells_v1'" -p /path/to/your/simpleDiffim.yaml
Python API summary¶
from lsst.ip.diffim.subtractImages import SimplifiedSubtractTask
-
class
SimplifiedSubtractTask(**kwargs) Compute the image difference of a science and template image using the Alard & Lupton (1998) algorithm
...
- attributeconfig
Access configuration fields and retargetable subtasks.
-
method
run(template, science, visitSummary=None, inputPsfMatchingKernel=None) PSF match, subtract, and decorrelate two images
...
See also
See the SimplifiedSubtractTask API reference for complete details.
Retargetable subtasks¶
decorrelate¶
- Default
lsst.ip.diffim.imageDecorrelation.DecorrelateALKernelTask- Field type
Task to decorrelate the image difference.
fallbackSourceSelector¶
Task to select sources to be used for PSF matching.Used only if the kernel calculation fails and`allowKernelSourceDetection` is set. The fallback source detection will not include all of the same plugins as the original source detection, so not all of the same flags can be used.
makeKernel¶
- Default
lsst.ip.diffim.makeKernel.MakeKernelTask- Field type
Task to construct a matching kernel for convolution.
scaleVariance¶
- Default
lsst.meas.algorithms.scaleVariance.ScaleVarianceTask- Field type
Subtask to rescale the variance of the template to the statistically expected level.
sourceSelector¶
Task to select sources to be used for PSF matching.
Configuration fields¶
allowKernelSourceDetection¶
Re-run source detection for kernel candidates if an error is encountered while calculating the matching kernel.
badMaskPlanes¶
Mask planes to interpolate over.
connections¶
- Data type
lsst.pipe.base.config.SimplifiedSubtractConfigConnections- Field type
Configurations describing the connections of the PipelineTask to datatypes
detectionThreshold¶
Minimum signal to noise ratio of detected sources to use for calculating the PSF matching kernel. Deprecated: No longer used. Will be removed after v30
detectionThresholdMax¶
Maximum signal to noise ratio of detected sources to use for calculating the PSF matching kernel. Deprecated: No longer used. Will be removed after v30
doApplyExternalCalibrations¶
Replace science Exposure’s calibration objects with those in visitSummary. Ignored if `doApplyFinalizedPsf is True.
doDecorrelation¶
Perform diffim decorrelation to undo pixel correlation due to A&L kernel convolution? If True, also update the diffim PSF.
doScaleVariance¶
Scale variance of the image difference?
doSubtractBackground¶
Subtract the background fit when solving the kernel? It is generally better to instead subtract the background in detectAndMeasure.
excludeMaskPlanes¶
Template mask planes to exclude when selecting sources for PSF matching.
maxKernelSources¶
Maximum number of sources to use for calculating the PSF matching kernel.Set to -1 to disable.
minKernelSources¶
Minimum number of sources needed for calculating the PSF matching kernel.
minTemplateFractionForExpectedSuccess¶
Raise NoWorkFound if PSF-matching fails and template covers less than this fraction of pixels. If the fraction of pixels covered by the template is less than this value (and greater than requiredTemplateFraction) this task is attempted but failure is anticipated and tolerated.
mode¶
- Default
'convolveTemplate'- Field type
strChoiceField(optional)- Choices
'auto'Choose which image to convolve at runtime.
'convolveScience'Only convolve the science image.
'convolveTemplate'Only convolve the template image.
NoneField is optional
Choose which image to convolve at runtime, or require that a specific image is convolved.
preserveTemplateMask¶
Mask planes from the template to propagate to the image difference.
renameTemplateMask¶
Mask planes from the template to propagate to the image differencewith ‘_TEMPLATE’ appended to the name.
requiredTemplateFraction¶
Raise NoWorkFound and do not attempt image subtraction if template covers less than this fraction of pixels. Setting to 0 will always attempt image subtraction.
restrictKernelEdgeSources¶
Exclude sources close to the edge from the kernel calculation?
saveLogOutput¶
Flag to enable/disable saving of log output for a task, enabled by default.
useExistingKernel¶
Use a pre-existing PSF matching kernel?If False, source detection and measurement will be run.