Skip to content

Commit

Permalink
Merge pull request #367 from lsst/tickets/DM-22952
Browse files Browse the repository at this point in the history
DM-22952: Gen 3 version of DCR image differencing
  • Loading branch information
isullivan committed Apr 22, 2020
2 parents 8a917ba + 529dafe commit d10b56b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
7 changes: 6 additions & 1 deletion python/lsst/pipe/tasks/dcrAssembleCoadd.py
Expand Up @@ -553,7 +553,12 @@ def prepareDcrInputs(self, templateCoadd, warpRefList, weightList):
self.log.info("Selected parallactic angles:\n%s", angleDict)
self.log.info("Selected PSF sizes:\n%s", psfSizeDict)
self.bufferSize = int(np.ceil(np.max(dcrShifts)) + 1)
psf = self.selectCoaddPsf(templateCoadd, warpRefList)
try:
psf = self.selectCoaddPsf(templateCoadd, warpRefList)
except Exception as e:
self.log.warn("Unable to calculate restricted PSF, using default coadd PSF: %s" % e)
else:
psf = templateCoadd.psf
dcrModels = DcrModel.fromImage(templateCoadd.maskedImage,
self.config.dcrNumSubfilters,
filterInfo=filterInfo,
Expand Down
28 changes: 22 additions & 6 deletions python/lsst/pipe/tasks/imageDifference.py
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 d10b56b

Please sign in to comment.