|
19 | 19 | # You should have received a copy of the GNU General Public License |
20 | 20 | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
21 | 21 |
|
22 | | -__all__ = ["DeblendCoaddSourcesSingleConfig", "DeblendCoaddSourcesSingleTask", |
23 | | - "DeblendCoaddSourcesMultiConfig", "DeblendCoaddSourcesMultiTask"] |
| 22 | +__all__ = ["DeblendCoaddSourcesMultiConfig", "DeblendCoaddSourcesMultiTask"] |
24 | 23 |
|
25 | 24 | import numpy as np |
26 | 25 |
|
27 | | -from deprecated.sphinx import deprecated |
28 | | - |
29 | | -from lsst.pipe.base import (Struct, PipelineTask, PipelineTaskConfig, PipelineTaskConnections) |
| 26 | +from lsst.pipe.base import PipelineTask, PipelineTaskConfig, PipelineTaskConnections |
30 | 27 | import lsst.pipe.base.connectionTypes as cT |
31 | 28 |
|
32 | 29 | from lsst.pex.config import ConfigurableField, Field |
33 | 30 | from lsst.meas.base import SkyMapIdGeneratorConfig |
34 | | -from lsst.meas.deblender import SourceDeblendTask |
35 | 31 | from lsst.meas.extensions.scarlet import ScarletDeblendTask |
36 | 32 |
|
37 | 33 | import lsst.afw.image as afwImage |
|
43 | 39 | deblendBaseTemplates = {"inputCoaddName": "deep", "outputCoaddName": "deep"} |
44 | 40 |
|
45 | 41 |
|
46 | | -class DeblendCoaddSourceSingleConnections(PipelineTaskConnections, |
47 | | - dimensions=("tract", "patch", "band", "skymap"), |
48 | | - defaultTemplates=deblendBaseTemplates): |
49 | | - inputSchema = cT.InitInput( |
50 | | - doc="Input schema to use in the deblend catalog", |
51 | | - name="{inputCoaddName}Coadd_mergeDet_schema", |
52 | | - storageClass="SourceCatalog" |
53 | | - ) |
54 | | - peakSchema = cT.InitInput( |
55 | | - doc="Schema of the footprint peak catalogs", |
56 | | - name="{inputCoaddName}Coadd_peak_schema", |
57 | | - storageClass="PeakCatalog" |
58 | | - ) |
59 | | - mergedDetections = cT.Input( |
60 | | - doc="Detection catalog merged across bands", |
61 | | - name="{inputCoaddName}Coadd_mergeDet", |
62 | | - storageClass="SourceCatalog", |
63 | | - dimensions=("tract", "patch", "skymap") |
64 | | - ) |
65 | | - coadd = cT.Input( |
66 | | - doc="Exposure on which to run deblending", |
67 | | - name="{inputCoaddName}Coadd_calexp", |
68 | | - storageClass="ExposureF", |
69 | | - dimensions=("tract", "patch", "band", "skymap") |
70 | | - ) |
71 | | - measureCatalog = cT.Output( |
72 | | - doc="The output measurement catalog of deblended sources", |
73 | | - name="{outputCoaddName}Coadd_deblendedFlux", |
74 | | - storageClass="SourceCatalog", |
75 | | - dimensions=("tract", "patch", "band", "skymap") |
76 | | - ) |
77 | | - outputSchema = cT.InitOutput( |
78 | | - doc="Output of the schema used in deblending task", |
79 | | - name="{outputCoaddName}Coadd_deblendedFlux_schema", |
80 | | - storageClass="SourceCatalog" |
81 | | - ) |
82 | | - |
83 | | - |
84 | | -class DeblendCoaddSourcesSingleConfig(PipelineTaskConfig, |
85 | | - pipelineConnections=DeblendCoaddSourceSingleConnections): |
86 | | - singleBandDeblend = ConfigurableField( |
87 | | - target=SourceDeblendTask, |
88 | | - doc="Task to deblend an image in one band" |
89 | | - ) |
90 | | - idGenerator = SkyMapIdGeneratorConfig.make_field() |
91 | | - |
92 | | - def setDefaults(self): |
93 | | - super().setDefaults() |
94 | | - self.singleBandDeblend.propagateAllPeaks = True |
95 | | - |
96 | | - |
97 | 42 | class DeblendCoaddSourcesMultiConnections(PipelineTaskConnections, |
98 | 43 | dimensions=("tract", "patch", "skymap"), |
99 | 44 | defaultTemplates=deblendBaseTemplates): |
@@ -209,64 +154,6 @@ class DeblendCoaddSourcesMultiConfig(PipelineTaskConfig, |
209 | 154 | idGenerator = SkyMapIdGeneratorConfig.make_field() |
210 | 155 |
|
211 | 156 |
|
212 | | -# TODO[DM-47797] Remove this task. |
213 | | -@deprecated( |
214 | | - "Support for the old single-band deblender on coadds will be removed " |
215 | | - "after v29.", |
216 | | - version="v29", |
217 | | - category=FutureWarning |
218 | | -) |
219 | | -class DeblendCoaddSourcesBaseTask(PipelineTask): |
220 | | - def __init__(self, initInputs, **kwargs): |
221 | | - super().__init__(initInputs=initInputs, **kwargs) |
222 | | - schema = initInputs["inputSchema"].schema |
223 | | - self.peakSchema = initInputs["peakSchema"].schema |
224 | | - self.schemaMapper = afwTable.SchemaMapper(schema) |
225 | | - self.schemaMapper.addMinimalSchema(schema) |
226 | | - self.schema = self.schemaMapper.getOutputSchema() |
227 | | - |
228 | | - def runQuantum(self, butlerQC, inputRefs, outputRefs): |
229 | | - inputs = butlerQC.get(inputRefs) |
230 | | - inputs["idFactory"] = self.config.idGenerator.apply(butlerQC.quantum.dataId).make_table_id_factory() |
231 | | - outputs = self.run(**inputs) |
232 | | - butlerQC.put(outputs, outputRefs) |
233 | | - |
234 | | - def _makeSourceCatalog(self, mergedDetections, idFactory): |
235 | | - # There may be gaps in the mergeDet catalog, which will cause the |
236 | | - # source ids to be inconsistent. So we update the id factory |
237 | | - # with the largest id already in the catalog. |
238 | | - maxId = np.max(mergedDetections["id"]) |
239 | | - idFactory.notify(maxId) |
240 | | - table = afwTable.SourceTable.make(self.schema, idFactory) |
241 | | - sources = afwTable.SourceCatalog(table) |
242 | | - sources.extend(mergedDetections, self.schemaMapper) |
243 | | - return sources |
244 | | - |
245 | | - |
246 | | -# TODO[DM-47797] Remove this task, its connections, and its config. |
247 | | -@deprecated( |
248 | | - "Support for the old single-band deblender on coadds will be removed " |
249 | | - "after v29.", |
250 | | - version="v29", |
251 | | - category=FutureWarning |
252 | | -) |
253 | | -class DeblendCoaddSourcesSingleTask(DeblendCoaddSourcesBaseTask): |
254 | | - ConfigClass = DeblendCoaddSourcesSingleConfig |
255 | | - _DefaultName = "deblendCoaddSourcesSingle" |
256 | | - |
257 | | - def __init__(self, initInputs, **kwargs): |
258 | | - super().__init__(initInputs=initInputs, **kwargs) |
259 | | - self.makeSubtask("singleBandDeblend", schema=self.schema, peakSchema=self.peakSchema) |
260 | | - self.outputSchema = afwTable.SourceCatalog(self.schema) |
261 | | - |
262 | | - def run(self, coadd, mergedDetections, idFactory): |
263 | | - sources = self._makeSourceCatalog(mergedDetections, idFactory) |
264 | | - self.singleBandDeblend.run(coadd, sources) |
265 | | - if not sources.isContiguous(): |
266 | | - sources = sources.copy(deep=True) |
267 | | - return Struct(measureCatalog=sources) |
268 | | - |
269 | | - |
270 | 157 | class DeblendCoaddSourcesMultiTask(PipelineTask): |
271 | 158 | ConfigClass = DeblendCoaddSourcesMultiConfig |
272 | 159 | _DefaultName = "deblendCoaddSourcesMulti" |
|
0 commit comments