55 catalog: astropy.table.Table,
56 columns_true: List[str],
57 columns_false: List[str],
58 selection: Optional[np.array],
60 """Apply additional boolean selection columns.
62 catalog : `astropy.table.Table`
63 The catalog to select from.
64 columns_true : `list` [`str`]
65 Columns that must be True for selection.
66 columns_false : `list` [`str`]
67 Columns that must be False for selection.
68 selection : `numpy.array`
69 A prior selection array. Default all true.
73 selection : `numpy.array`
74 The final selection array.
77 select_additional = (len(columns_true) + len(columns_false)) > 0
80 selection = np.ones(len(catalog), dtype=bool)
81 for column
in columns_true:
84 values = catalog[column]
85 selection &= (np.isfinite(values) & (values != 0))
86 for column
in columns_false:
87 values = catalog[column]
88 selection &= (values == 0)
101 catalog_ref: astropy.table.Table,
102 catalog_target: astropy.table.Table,
103 select_ref: np.array =
None,
104 select_target: np.array =
None,
105 wcs: afwGeom.SkyWcs =
None,
106 logger: logging.Logger =
None,
107 logging_n_rows: int =
None,
108 ) -> Tuple[astropy.table.Table, astropy.table.Table, Dict[int, str]]:
109 """Match sources in a reference tract catalog with a target catalog.
113 catalog_ref : `astropy.table.Table`
114 A reference catalog to match objects/sources from.
115 catalog_target : `astropy.table.Table`
116 A target catalog to match reference objects/sources to.
117 select_ref : `numpy.array`
118 A boolean array of the same length as `catalog_ref` selecting the sources that can be matched.
119 select_target : `numpy.array`
120 A boolean array of the same length as `catalog_target` selecting the sources that can be matched.
121 wcs : `lsst.afw.image.SkyWcs`
122 A coordinate system to convert catalog positions to sky coordinates. Only used if
123 `self.config.coords_ref_to_convert` is set.
124 logger : `logging.Logger`
125 A Logger for logging.
126 logging_n_rows : `int`
127 Number of matches to make before outputting incremental log message.
131 catalog_out_ref : `astropy.table.Table`
132 Reference matched catalog with indices of target matches.
133 catalog_out_target : `astropy.table.Table`
134 Reference matched catalog with indices of target matches.
141 if config.column_ref_order
is None:
142 fluxes = [catalog_ref[key]
for key
in config.columns_ref_flux]
143 flux_tot = np.nansum(fluxes, axis=0)
144 catalog_ref[
"flux_total"] = flux_tot
145 if config.mag_brightest_ref != -np.inf
or config.mag_faintest_ref != np.inf:
147 -2.5 * np.log10(flux_tot) + config.coord_format.mag_zeropoint_ref
149 select_mag = (mag_tot >= config.mag_brightest_ref) & (
150 mag_tot <= config.mag_faintest_ref
153 select_mag = np.isfinite(flux_tot)
154 if select_ref
is None:
155 select_ref = select_mag
157 select_ref &= select_mag
159 with warnings.catch_warnings():
161 warnings.filterwarnings(action=
"ignore", category=FutureWarning)
164 columns_true=config.columns_ref_select_true,
165 columns_false=config.columns_ref_select_false,
166 selection=select_ref,
169 catalog=catalog_target,
170 columns_true=config.columns_target_select_true,
171 columns_false=config.columns_target_select_false,
172 selection=select_target,
176 "Beginning MatcherProbabilistic.match with %d/%d ref sources selected vs %d/%d target",
177 len(catalog_ref)
if select_ref
is None else np.sum(select_ref),
179 len(catalog_target)
if select_target
is None else np.sum(select_target),
183 catalog_out_ref, catalog_out_target, exceptions = self.
matcher.
match(
186 select_ref=select_ref,
187 select_target=select_target,
189 logging_n_rows=logging_n_rows,
191 radec_to_xy_func=radec_to_xy,
194 return catalog_out_ref, catalog_out_target, exceptions
199 catalog_ref: astropy.table.Table,
200 catalog_target: astropy.table.Table,
201 wcs: afwGeom.SkyWcs =
None,
203 ) -> pipeBase.Struct:
204 """Match sources in a reference tract catalog with a target catalog.
208 catalog_ref : `astropy.table.Table`
209 A reference catalog to match objects/sources from.
210 catalog_target : `astropy.table.Table`
211 A target catalog to match reference objects/sources to.
212 wcs : `lsst.afw.image.SkyWcs`
213 A coordinate system to convert catalog positions to sky coordinates.
214 Only needed if `config.coords_ref_to_convert` is used to convert
215 reference catalog sky coordinates to pixel positions.
216 kwargs : Additional keyword arguments to pass to `match`.
220 retStruct : `lsst.pipe.base.Struct`
221 A struct with output_ref and output_target attribute containing the
222 output matched catalogs, as well as a dict
224 with warnings.catch_warnings():
226 warnings.filterwarnings(action=
"ignore", category=FutureWarning)
227 catalog_ref, catalog_target, exceptions = self.
match(
228 catalog_ref, catalog_target, wcs=wcs, **kwargs
231 return pipeBase.Struct(
232 cat_output_ref=catalog_ref,
233 cat_output_target=catalog_target,
234 exceptions=exceptions,