Details
-
Type:
RFC
-
Status: Implemented
-
Resolution: Done
-
Component/s: DM
-
Labels:
Description
Our current ImageDifferenceTask in pipe_tasks was written long before the Gen 3 middleware was developed, and is a monolithic block of code that attempts to support a wide variety of use cases. Most of those use cases are untested and contain heavily bit-rotted code, and we have found it difficult to debug and extend to new use cases. On DM-33001 we provided a proposed new implementation of image differencing in ip_diffim which now consists of three distinct PipelineTasks:
- GetTemplateTask which constructs the warped and cropped (and possibly DCR-corrected) templateExp. This step was implemented previously as part of ImageDifferenceFromTemplateTask.
- AlardLuptonSubtractTask which PSF-matches either the template or science image, and subtracts the template from the science image. This Task can be replaced by other algorithms, such as a (yet to be written) ZogySubtractTask with the appropriate input and output connections.
- DetectAndMeasureTask which runs source detection and measurement on the difference image, including adding sky sources and forced measurement. For a future ZogySubtractTask or other image subtraction Task that produces a maximum likelihood image as an output connection we can create a new DetectAndMeasureLikelihoodTask that inherits from DetectAndMeasureTask.
As documented on DM-33001, each step of the new image differencing pipeline returns results that are within floating point precision of the old ImageDifferenceTask if forceCompatibility=True for AlardLuptonSubtractTask, except that the results of ScaleVarianceTask appear sensitive to these small differences. With compatibility mode turned off, the differences are:
- ScaleVarianceTask is applied separately to the science and template images, rather than once to the difference image. This is necessary to ensure that the relative weight of the science and template variances is correct before they are combined.
- pipe_tasks.ImageDifferenceTask has a minor bug that ignores the border pixels of the template and performs an unnecessary extra warping step. This behavior is duplicated in compatibility mode.
- The image to be convolved will be programmatically determined based on the seeing of the science and template images.
For this RFC, I am proposing that we transition to using the new code in stages:
- Immediately switch the AP pipeline to the new tasks, using forceCompatibility=True.
- After the current RC2 run of DRP is completed, also switch the DRP pipeline to the new tasks, using forceCompatibility=True.
- Add deprecation warnings to ImageDifferenceTask in pipe_tasks.
- Turn off compatibility mode for the AP pipeline.
- Turn off compatibility mode for the DRP pipeline.
- Remove deprecated code in pipe_tasks and ip_diffim.
Attachments
Issue Links
- is triggering
-
DM-35639 Switch AP and DRP pipelines to use new image differencing
- Done
- relates to
-
DM-33911 Test the performance of refactored image differencing
- Done
-
DM-35175 Debug convolveScience option of new image differencing
- Done
-
DM-33001 Design refactoring of ImageDifferenceTask
- Done
I am excited to see the more modular ImageDifference as our stack default as I think it will speed our development and debugging.