Skip to content

Commit

Permalink
Address review concerns.
Browse files Browse the repository at this point in the history
 * Log message updates.
 * Data type template variable updates for more consistency.
 * Minor updates in runQuantum().
 * getTemplate.runGen3() now returns Struct similarly to run().
  • Loading branch information
Gabor Kovacs committed Jan 31, 2020
1 parent 4d2b038 commit fe2a3d7
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions python/lsst/pipe/tasks/imageDifference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import random
import numpy

import lsst.utils
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
import lsst.daf.base as dafBase
Expand All @@ -48,13 +49,11 @@
IqrToSigma = 0.741


class ImageDifferenceTaskConnections(
pipeBase.PipelineTaskConnections,
dimensions=("instrument", "visit", "detector", "skymap"),
defaultTemplates={"coaddName": "deep",
"warpTypeSuffix": "",
"fakesType": ""}
):
class ImageDifferenceTaskConnections(pipeBase.PipelineTaskConnections,
dimensions=("instrument", "visit", "detector", "skymap"),
defaultTemplates={"coaddName": "deep",
"warpTypeSuffix": "",
"fakesType": ""}):

exposure = pipeBase.connectionTypes.Input(
doc="Input science exposure to subtract from.",
Expand All @@ -73,27 +72,27 @@ class ImageDifferenceTaskConnections(

skyMap = pipeBase.connectionTypes.Input(
doc="Input definition of geometry/bbox and projection/wcs for template exposures",
name="{fakesType}{coaddName}Coadd_skyMap",
name="{coaddName}Coadd_skyMap",
dimensions=("skymap", ),
storageClass="SkyMap",
)
coaddExposures = pipeBase.connectionTypes.Input(
doc="Input template to match and suntract from the exposure",
doc="Input template to match and subtract from the exposure",
dimensions=("tract", "patch", "skymap", "abstract_filter"),
storageClass="ExposureF",
name="{fakesType}{coaddName}Coadd{warpTypeSuffix}",
multiple=True,
)
subtractedExposure = pipeBase.connectionTypes.Output(
doc="Output subtracted exposure",
doc="Output difference image",
dimensions=("instrument", "visit", "detector"),
storageClass="ExposureF",
name="{coaddName}Diff_differenceExp",
name="{fakesType}{coaddName}Diff_differenceExp",
)

diaSources = pipeBase.connectionTypes.Output(
doc="Output detected diaSources",
doc="Output detected diaSources on the difference image",
storageClass="SourceCatalog",
name="{coaddName}Diff_diaSrc",
name="{fakesType}{coaddName}Diff_diaSrc",
)

# TODO DM-22953: Add support for refObjLoader (kernelSourcesFromRef)
Expand Down Expand Up @@ -311,7 +310,7 @@ def getTargetList(parsedCmd, **kwargs):
**kwargs)


class ImageDifferenceTask(pipeBase.PipelineTask, pipeBase.CmdLineTask):
class ImageDifferenceTask(pipeBase.CmdLineTask, pipeBase.PipelineTask):
"""Subtract an image from a template and measure the result
"""
ConfigClass = ImageDifferenceConfig
Expand Down Expand Up @@ -401,37 +400,26 @@ def makeIdFactory(expId, expBits):
"""
return afwTable.IdFactory.makeSource(expId, 64 - expBits)

@lsst.utils.inheritDoc(pipeBase.PipelineTask)
def runQuantum(self, butlerQC: pipeBase.ButlerQuantumContext,
inputRefs: pipeBase.InputQuantizedConnection,
outputRefs: pipeBase.OutputQuantizedConnection):
"""Pipelinetask gen3 entry point.
Parameters
----------
expId : `int`
Exposure id.
expBits: `int`
Number of used bits in ``expId``.
Returns
-------
None
"""
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)
inputs['idFactory'] = self.makeIdFactory(expId=expId, expBits=expBits)
inputs['templateExposure'] = self.getTemplate.assembleTemplateExposure(
butlerQC, inputRefs.skyMap, inputRefs.coaddExposures, inputs['exposure']
idFactory = self.makeIdFactory(expId=expId, expBits=expBits)
templateStruct = self.getTemplate.runGen3(
inputs['exposure'], butlerQC, inputRefs.skyMap, inputRefs.coaddExposures
)
del inputs['coaddExposures']
del inputs['skyMap']
outputs = self.run(**inputs)

outputs = self.run(exposure=inputs['exposure'],
templateExposure=templateStruct.exposure,
idFactory=idFactory)
butlerQC.put(outputs, outputRefs)

@pipeBase.timeMethod
Expand Down

0 comments on commit fe2a3d7

Please sign in to comment.