Skip to content

Commit

Permalink
Initial Gen 3 version of DCR image differencing
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Apr 22, 2020
1 parent 3044c29 commit 529dafe
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions python/lsst/pipe/tasks/imageDifference.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
class ImageDifferenceTaskConnections(pipeBase.PipelineTaskConnections,
dimensions=("instrument", "visit", "detector", "skymap"),
defaultTemplates={"coaddName": "deep",
"skyMapName": "deep",
"warpTypeSuffix": "",
"fakesType": ""}):

Expand All @@ -72,7 +73,7 @@ class ImageDifferenceTaskConnections(pipeBase.PipelineTaskConnections,

skyMap = pipeBase.connectionTypes.Input(
doc="Input definition of geometry/bbox and projection/wcs for template exposures",
name="{coaddName}Coadd_skyMap",
name="{skyMapName}Coadd_skyMap",
dimensions=("skymap", ),
storageClass="SkyMap",
)
Expand All @@ -84,6 +85,14 @@ class ImageDifferenceTaskConnections(pipeBase.PipelineTaskConnections,
multiple=True,
deferLoad=True
)
dcrCoadds = pipeBase.connectionTypes.Input(
doc="Input DCR template to match and subtract from the exposure",
name="{fakesType}dcrCoadd{warpTypeSuffix}",
storageClass="ExposureF",
dimensions=("tract", "patch", "skymap", "abstract_filter", "subfilter"),
multiple=True,
deferLoad=True
)
subtractedExposure = pipeBase.connectionTypes.Output(
doc="Output difference image",
dimensions=("instrument", "visit", "detector"),
Expand All @@ -97,6 +106,13 @@ class ImageDifferenceTaskConnections(pipeBase.PipelineTaskConnections,
name="{fakesType}{coaddName}Diff_diaSrc",
)

def __init__(self, *, config=None):
super().__init__(config=config)
if config.coaddName == 'dcr':
self.inputs.remove("coaddExposures")
else:
self.inputs.remove("dcrCoadds")

# TODO DM-22953: Add support for refObjLoader (kernelSourcesFromRef)
# Make kernelSources optional

Expand Down Expand Up @@ -396,17 +412,17 @@ def makeIdFactory(expId, expBits):
def runQuantum(self, butlerQC: pipeBase.ButlerQuantumContext,
inputRefs: pipeBase.InputQuantizedConnection,
outputRefs: pipeBase.OutputQuantizedConnection):
if self.getTemplate.config.coaddName == 'dcr':
# TODO DM-22952
raise NotImplementedError("TODO DM-22952: Dcr coadd templates are not yet supported in gen3.")

inputs = butlerQC.get(inputRefs)
self.log.info(f"Processing {butlerQC.quantum.dataId}")
expId, expBits = butlerQC.quantum.dataId.pack("visit_detector",
returnMaxBits=True)
idFactory = self.makeIdFactory(expId=expId, expBits=expBits)
if self.config.coaddName == 'dcr':
templateExposures = inputRefs.dcrCoadds
else:
templateExposures = inputRefs.coaddExposures
templateStruct = self.getTemplate.runQuantum(
inputs['exposure'], butlerQC, inputRefs.skyMap, inputRefs.coaddExposures
inputs['exposure'], butlerQC, inputRefs.skyMap, templateExposures
)

outputs = self.run(exposure=inputs['exposure'],
Expand Down

0 comments on commit 529dafe

Please sign in to comment.