@@ -134,6 +134,13 @@ class DeblendCoaddSourcesMultiConnections(PipelineTaskConnections,
134134 multiple = True ,
135135 dimensions = ("tract" , "patch" , "band" , "skymap" )
136136 )
137+ deconvolvedCoadds = cT .Input (
138+ doc = "Deconvolved coadds" ,
139+ name = "deconvolved_{inputCoaddName}_coadd" ,
140+ storageClass = "ExposureF" ,
141+ multiple = True ,
142+ dimensions = ("tract" , "patch" , "band" , "skymap" )
143+ )
137144 outputSchema = cT .InitOutput (
138145 doc = "Output of the schema used in deblending task" ,
139146 name = "{outputCoaddName}Coadd_deblendedFlux_schema" ,
@@ -169,6 +176,12 @@ class DeblendCoaddSourcesMultiConnections(PipelineTaskConnections,
169176 storageClass = "ScarletModelData" ,
170177 dimensions = ("tract" , "patch" , "skymap" ),
171178 )
179+ objectParents = cT .Output (
180+ doc = "Parents of the deblended objects" ,
181+ name = "object_parents" ,
182+ storageClass = "SourceCatalog" ,
183+ dimensions = ("tract" , "patch" , "skymap" ),
184+ )
172185
173186 def __init__ (self , * , config = None ):
174187 super ().__init__ (config = config )
@@ -286,21 +299,33 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
286299 coadds = exposures
287300 else :
288301 coadds = inputs .pop ("coadds" )
302+
303+ # Ensure that the coadd bands and deconvolved coadd bands match
304+ deconvBands = [dRef .dataId ["band" ] for dRef in inputRefs .deconvolvedCoadds ]
305+ if bands != deconvBands :
306+ self .log .error ("Coadd bands %s != deconvolved coadd bands %s" , bands , deconvBands )
307+ raise RuntimeError ("Number of coadd bands and deconvolved coadd bands do not match" )
308+
309+ deconvolvedCoadds = inputs .pop ("deconvolvedCoadds" )
310+
311+ # Check that all inputs have been extracted correctly.
289312 assert not inputs , "runQuantum got extra inputs"
313+
290314 outputs = self .run (
291315 coadds = coadds ,
292316 bands = bands ,
293317 mergedDetections = mergedDetections ,
294318 idFactory = self .config .idGenerator .apply (butlerQC .quantum .dataId ).make_table_id_factory (),
319+ deconvolvedCoadds = deconvolvedCoadds ,
295320 )
296321 butlerQC .put (outputs , outputRefs )
297322
298- def run (self , coadds , bands , mergedDetections , idFactory ):
323+ def run (self , coadds , bands , mergedDetections , deconvolvedCoadds , idFactory ):
299324 sources = self ._makeSourceCatalog (mergedDetections , idFactory )
300325 multiExposure = afwImage .MultibandExposure .fromExposures (bands , coadds )
301- catalog , modelData = self . multibandDeblend . run ( multiExposure , sources )
302- retStruct = Struct ( deblendedCatalog = catalog , scarletModelData = modelData )
303- return retStruct
326+ mDeconvolved = afwImage . MultibandExposure . fromExposures ( bands , deconvolvedCoadds )
327+ result = self . multibandDeblend . run ( multiExposure , mDeconvolved , sources )
328+ return result
304329
305330 def _makeSourceCatalog (self , mergedDetections , idFactory ):
306331 # There may be gaps in the mergeDet catalog, which will cause the
0 commit comments