177 deconvolvedRefs = inputRefs.deconvolvedCoadds
178 bandOrder = [dRef.dataId[
"band"]
for dRef
in deconvolvedRefs]
180 inputRefs = reorderRefs(inputRefs, bandOrder, dataIdKey=
"band")
181 inputs = butlerQC.get(inputRefs)
182 bands = [dRef.dataId[
"band"]
for dRef
in deconvolvedRefs]
183 mergedDetections = inputs.pop(
"mergedDetections")
184 if self.config.useCellCoadds:
185 exposures = [mcc.stitch().asExposure()
for mcc
in inputs.pop(
"coadds_cell")]
186 backgrounds = inputs.pop(
"backgrounds")
187 for exposure, background
in zip(exposures, backgrounds):
188 exposure.image -= background.getImage()
191 coadds = inputs.pop(
"coadds")
194 coaddRefs = inputRefs.coadds_cell
if self.config.useCellCoadds
else inputRefs.coadds
195 coaddBands = [dRef.dataId[
"band"]
for dRef
in coaddRefs]
196 if bands != coaddBands:
197 self.log.error(
"Coadd bands %s != deconvolved coadd bands %s", bands, coaddBands)
199 "Number of coadd bands and deconvolved coadd bands do not match. "
200 "This should never happen and indicates a bug in reorderRefs."
203 deconvolvedCoadds = inputs.pop(
"deconvolvedCoadds")
206 assert not inputs,
"runQuantum got extra inputs"
211 mergedDetections=mergedDetections,
212 idFactory=self.config.idGenerator.apply(butlerQC.quantum.dataId).make_table_id_factory(),
213 deconvolvedCoadds=deconvolvedCoadds,
215 butlerQC.put(outputs, outputRefs)
217 def run(self, coadds, bands, mergedDetections, deconvolvedCoadds, idFactory):
219 multiExposure = afwImage.MultibandExposure.fromExposures(bands, coadds)
220 mDeconvolved = afwImage.MultibandExposure.fromExposures(bands, deconvolvedCoadds)
221 result = self.multibandDeblend.run(multiExposure, mDeconvolved, sources)
228 maxId = np.max(mergedDetections[
"id"])
229 idFactory.notify(maxId)
230 table = afwTable.SourceTable.make(self.
schema, idFactory)
231 sources = afwTable.SourceCatalog(table)