23 'MatchTractCatalogSubConfig',
'MatchTractCatalogSubTask',
24 'MatchTractCatalogConfig',
'MatchTractCatalogTask'
29import lsst.pipe.base
as pipeBase
30import lsst.pipe.base.connectionTypes
as cT
33from abc
import ABC, abstractmethod
36from typing
import Tuple, Set
39MatchTractCatalogBaseTemplates = {
40 "name_input_cat_ref":
"truth_summary",
41 "name_input_cat_target":
"objectTable_tract",
46 pipeBase.PipelineTaskConnections,
47 dimensions=(
"tract",
"skymap"),
48 defaultTemplates=MatchTractCatalogBaseTemplates,
51 doc=
"Reference object catalog to match from",
52 name=
"{name_input_cat_ref}",
53 storageClass=
"DataFrame",
54 dimensions=(
"tract",
"skymap"),
57 cat_target = cT.Input(
58 doc=
"Target object catalog to match",
59 name=
"{name_input_cat_target}",
60 storageClass=
"DataFrame",
61 dimensions=(
"tract",
"skymap"),
65 doc=
"Input definition of geometry/bbox and projection/wcs for coadded exposures",
66 name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
67 storageClass=
"SkyMap",
68 dimensions=(
"skymap",),
71 cat_output_ref = cT.Output(
72 doc=
"Reference matched catalog with indices of target matches",
73 name=
"match_ref_{name_input_cat_ref}_{name_input_cat_target}",
74 storageClass=
"DataFrame",
75 dimensions=(
"tract",
"skymap"),
77 cat_output_target = cT.Output(
78 doc=
"Target matched catalog with indices of reference matches",
79 name=
"match_target_{name_input_cat_ref}_{name_input_cat_target}",
80 storageClass=
"DataFrame",
81 dimensions=(
"tract",
"skymap"),
86 """Config class for the MatchTractCatalogSubTask to define methods returning
87 values that depend on multiple config settings.
92 raise NotImplementedError()
97 raise NotImplementedError()
101 """An abstract interface for subtasks of MatchTractCatalogTask to match
102 two tract object catalogs.
107 Additional arguments to be passed to the `lsst.pipe.base.Task`
110 ConfigClass = MatchTractCatalogSubConfig
118 catalog_ref: pd.DataFrame,
119 catalog_target: pd.DataFrame,
120 wcs: afwGeom.SkyWcs =
None,
121 ) -> pipeBase.Struct:
122 """Match sources in a reference tract catalog with a target catalog.
126 catalog_ref : `pandas.DataFrame`
127 A reference catalog to match objects/sources from.
128 catalog_target : `pandas.DataFrame`
129 A target catalog to match reference objects/sources to.
130 wcs : `lsst.afw.image.SkyWcs`
131 A coordinate system to convert catalog positions to sky coordinates.
135 retStruct : `lsst.pipe.base.Struct`
136 A struct with output_ref and output_target attribute containing the
137 output matched catalogs.
139 raise NotImplementedError()
143 pipeBase.PipelineTaskConfig,
144 pipelineConnections=MatchTractCatalogConnections,
146 """Configure a MatchTractCatalogTask, including a configurable matching subtask.
148 match_tract_catalog = pexConfig.ConfigurableField(
149 target=MatchTractCatalogSubTask,
150 doc=
"Task to match sources in a reference tract catalog with a target catalog",
154 """Get the set of input columns required for matching.
158 columns_ref : `set` [`str`]
159 The set of required input catalog column names.
160 columns_target : `set` [`str`]
161 The set of required target catalog column names.
166 except AttributeError
as err:
167 raise RuntimeError(f
'{__class__}.match_tract_catalog must have columns_in_ref and'
168 f
' columns_in_target attributes: {err}')
from None
169 return set(columns_ref), set(columns_target)
173 """Match sources in a reference tract catalog with those in a target catalog.
175 ConfigClass = MatchTractCatalogConfig
176 _DefaultName =
"MatchTractCatalog"
179 super().
__init__(initInputs=initInputs, **kwargs)
180 self.makeSubtask(
"match_tract_catalog")
183 inputs = butlerQC.get(inputRefs)
184 columns_ref, columns_target = self.config.get_columns_in()
185 skymap = inputs.pop(
"skymap")
188 catalog_ref=inputs[
'cat_ref'].get(parameters={
'columns': columns_ref}),
189 catalog_target=inputs[
'cat_target'].get(parameters={
'columns': columns_target}),
190 wcs=skymap[butlerQC.quantum.dataId[
"tract"]].wcs,
192 butlerQC.put(outputs, outputRefs)
196 catalog_ref: pd.DataFrame,
197 catalog_target: pd.DataFrame,
198 wcs: afwGeom.SkyWcs =
None,
199 ) -> pipeBase.Struct:
200 """Match sources in a reference tract catalog with a target catalog.
204 catalog_ref : `pandas.DataFrame`
205 A reference catalog to match objects/sources from.
206 catalog_target : `pandas.DataFrame`
207 A target catalog to match reference objects/sources to.
208 wcs : `lsst.afw.image.SkyWcs`
209 A coordinate system to convert catalog positions to sky coordinates,
214 retStruct : `lsst.pipe.base.Struct`
215 A struct with output_ref and output_target attribute containing the
216 output matched catalogs.
218 output = self.match_tract_catalog.run(catalog_ref, catalog_target, wcs=wcs)
219 if output.exceptions:
220 self.log.warn(
'Exceptions: %s', output.exceptions)
221 retStruct = pipeBase.Struct(cat_output_ref=output.cat_output_ref,
222 cat_output_target=output.cat_output_target)
Tuple[Set, Set] get_columns_in(self)
Set[str] columns_in_target(self)
Set[str] columns_in_ref(self)
pipeBase.Struct run(self, pd.DataFrame catalog_ref, pd.DataFrame catalog_target, afwGeom.SkyWcs wcs=None)
pipeBase.Struct run(self, pd.DataFrame catalog_ref, pd.DataFrame catalog_target, afwGeom.SkyWcs wcs=None)
runQuantum(self, butlerQC, inputRefs, outputRefs)
__init__(self, initInputs, **kwargs)