23 'MatchTractCatalogSubConfig',
'MatchTractCatalogSubTask',
24 'MatchTractCatalogConfig',
'MatchTractCatalogTask'
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",),
70 cat_output_ref = cT.Output(
71 doc=
"Reference matched catalog with indices of target matches",
72 name=
"match_ref_{name_input_cat_ref}_{name_input_cat_target}",
73 storageClass=
"DataFrame",
74 dimensions=(
"tract",
"skymap"),
76 cat_output_target = cT.Output(
77 doc=
"Target matched catalog with indices of reference matches",
78 name=
"match_target_{name_input_cat_ref}_{name_input_cat_target}",
79 storageClass=
"DataFrame",
80 dimensions=(
"tract",
"skymap"),
85 """Config class for the MatchTractCatalogSubTask to define methods returning
86 values that depend on multiple config settings.
91 raise NotImplementedError()
96 raise NotImplementedError()
100 """An abstract interface for subtasks of MatchTractCatalogTask to match
101 two tract object catalogs.
106 Additional arguments to be passed to the `lsst.pipe.base.Task`
109 ConfigClass = MatchTractCatalogSubConfig
117 catalog_ref: pd.DataFrame,
118 catalog_target: pd.DataFrame,
119 wcs: afwGeom.SkyWcs =
None,
120 ) -> pipeBase.Struct:
121 """Match sources in a reference tract catalog with a target catalog.
125 catalog_ref : `pandas.DataFrame`
126 A reference catalog to match objects/sources from.
127 catalog_target : `pandas.DataFrame`
128 A target catalog to match reference objects/sources to.
129 wcs : `lsst.afw.image.SkyWcs`
130 A coordinate system to convert catalog positions to sky coordinates.
134 retStruct : `lsst.pipe.base.Struct`
135 A struct
with output_ref
and output_target attribute containing the
136 output matched catalogs.
138 raise NotImplementedError()
142 pipeBase.PipelineTaskConfig,
143 pipelineConnections=MatchTractCatalogConnections,
145 """Configure a MatchTractCatalogTask, including a configurable matching subtask.
147 match_tract_catalog = pexConfig.ConfigurableField(
148 target=MatchTractCatalogSubTask,
149 doc="Task to match sources in a reference tract catalog with a target catalog",
153 """Get the set of input columns required for matching.
157 columns_ref : `set` [`str`]
158 The set of required input catalog column names.
159 columns_target : `set` [`str`]
160 The set of required target catalog column names.
165 except AttributeError
as err:
166 raise RuntimeError(f
'{__class__}.match_tract_catalog must have columns_in_ref and'
167 f
' columns_in_target attributes: {err}')
from None
168 return set(columns_ref), set(columns_target)
172 """Match sources in a reference tract catalog with those in a target catalog.
174 ConfigClass = MatchTractCatalogConfig
175 _DefaultName = "MatchTractCatalog"
178 super().
__init__(initInputs=initInputs, **kwargs)
179 self.makeSubtask(
"match_tract_catalog")
182 inputs = butlerQC.get(inputRefs)
183 columns_ref, columns_target = self.config.get_columns_in()
184 skymap = inputs.pop(
"skymap")
187 catalog_ref=inputs[
'cat_ref'].get(parameters={
'columns': columns_ref}),
188 catalog_target=inputs[
'cat_target'].get(parameters={
'columns': columns_target}),
189 wcs=skymap[butlerQC.quantum.dataId[
"tract"]].wcs,
191 butlerQC.put(outputs, outputRefs)
195 catalog_ref: pd.DataFrame,
196 catalog_target: pd.DataFrame,
197 wcs: afwGeom.SkyWcs =
None,
198 ) -> pipeBase.Struct:
199 """Match sources in a reference tract catalog with a target catalog.
203 catalog_ref : `pandas.DataFrame`
204 A reference catalog to match objects/sources from.
205 catalog_target : `pandas.DataFrame`
206 A target catalog to match reference objects/sources to.
207 wcs : `lsst.afw.image.SkyWcs`
208 A coordinate system to convert catalog positions to sky coordinates,
213 retStruct : `lsst.pipe.base.Struct`
214 A struct
with output_ref
and output_target attribute containing the
215 output matched catalogs.
217 output = self.match_tract_catalog.run(catalog_ref, catalog_target, wcs=wcs)
218 if output.exceptions:
219 self.log.warn(
'Exceptions: %s', output.exceptions)
220 retStruct = pipeBase.Struct(cat_output_ref=output.cat_output_ref,
221 cat_output_target=output.cat_output_target)
pexConfig match_tract_catalog
Tuple[Set, Set] get_columns_in(self)
Set[str] columns_in_target(self)
Set[str] columns_in_ref(self)
def __init__(self, **kwargs)
def runQuantum(self, butlerQC, inputRefs, outputRefs)
pipeBase.Struct run(self, pd.DataFrame catalog_ref, pd.DataFrame catalog_target, afwGeom.SkyWcs wcs=None)
def __init__(self, initInputs, **kwargs)