52 catalog: pd.DataFrame,
53 columns_true: List[str],
54 columns_false: List[str],
55 selection: Optional[np.array],
57 """Apply additional boolean selection columns.
59 catalog : `pandas.DataFrame`
60 The catalog to select from.
61 columns_true : `list` [`str`]
62 Columns that must be True for selection.
63 columns_false : `list` [`str`]
64 Columns that must be False for selection.
65 selection : `numpy.array`
66 A prior selection array. Default all true.
70 selection : `numpy.array`
71 The final selection array.
74 select_additional = (len(columns_true) + len(columns_false)) > 0
77 selection = np.ones(len(catalog), dtype=bool)
78 for column
in columns_true:
81 values = catalog[column].values
82 selection &= (np.isfinite(values) & (values != 0))
83 for column
in columns_false:
84 selection &= (catalog[column].values == 0)
97 catalog_ref: pd.DataFrame,
98 catalog_target: pd.DataFrame,
99 select_ref: np.array =
None,
100 select_target: np.array =
None,
101 wcs: afwGeom.SkyWcs =
None,
102 logger: logging.Logger =
None,
103 logging_n_rows: int =
None,
104 ) -> Tuple[pd.DataFrame, pd.DataFrame, Dict[int, str]]:
105 """Match sources in a reference tract catalog with a target catalog.
109 catalog_ref : `pandas.DataFrame`
110 A reference catalog to match objects/sources from.
111 catalog_target : `pandas.DataFrame`
112 A target catalog to match reference objects/sources to.
113 select_ref : `numpy.array`
114 A boolean array of the same length as `catalog_ref` selecting the sources that can be matched.
115 select_target : `numpy.array`
116 A boolean array of the same length as `catalog_target` selecting the sources that can be matched.
117 wcs : `lsst.afw.image.SkyWcs`
118 A coordinate system to convert catalog positions to sky coordinates. Only used if
119 `self.config.coords_ref_to_convert` is set.
120 logger : `logging.Logger`
121 A Logger for logging.
122 logging_n_rows : `int`
123 Number of matches to make before outputting incremental log message.
127 catalog_out_ref : `pandas.DataFrame`
128 Reference matched catalog with indices of target matches.
129 catalog_out_target : `pandas.DataFrame`
130 Reference matched catalog with indices of target matches.
137 if config.column_ref_order
is None:
138 flux_tot = np.nansum(
139 catalog_ref.loc[:, config.columns_ref_flux].values, axis=1
141 catalog_ref[
"flux_total"] = flux_tot
142 if config.mag_brightest_ref != -np.inf
or config.mag_faintest_ref != np.inf:
144 -2.5 * np.log10(flux_tot) + config.coord_format.mag_zeropoint_ref
146 select_mag = (mag_tot >= config.mag_brightest_ref) & (
147 mag_tot <= config.mag_faintest_ref
150 select_mag = np.isfinite(flux_tot)
151 if select_ref
is None:
152 select_ref = select_mag
154 select_ref &= select_mag
158 columns_true=config.columns_ref_select_true,
159 columns_false=config.columns_ref_select_false,
160 selection=select_ref,
163 catalog=catalog_target,
164 columns_true=config.columns_target_select_true,
165 columns_false=config.columns_target_select_false,
166 selection=select_target,
170 "Beginning MatcherProbabilistic.match with %d/%d ref sources selected vs %d/%d target",
173 np.sum(select_target),
177 catalog_out_ref, catalog_out_target, exceptions = self.
matcher.
match(
180 select_ref=select_ref,
181 select_target=select_target,
183 logging_n_rows=logging_n_rows,
185 radec_to_xy_func=radec_to_xy,
188 return catalog_out_ref, catalog_out_target, exceptions
193 catalog_ref: pd.DataFrame,
194 catalog_target: pd.DataFrame,
195 wcs: afwGeom.SkyWcs =
None,
197 ) -> pipeBase.Struct:
198 """Match sources in a reference tract catalog with a target catalog.
202 catalog_ref : `pandas.DataFrame`
203 A reference catalog to match objects/sources from.
204 catalog_target : `pandas.DataFrame`
205 A target catalog to match reference objects/sources to.
206 wcs : `lsst.afw.image.SkyWcs`
207 A coordinate system to convert catalog positions to sky coordinates.
208 Only needed if `config.coords_ref_to_convert` is used to convert
209 reference catalog sky coordinates to pixel positions.
210 kwargs : Additional keyword arguments to pass to `match`.
214 retStruct : `lsst.pipe.base.Struct`
215 A struct with output_ref and output_target attribute containing the
216 output matched catalogs, as well as a dict
218 catalog_ref.reset_index(inplace=
True)
219 catalog_target.reset_index(inplace=
True)
220 catalog_ref, catalog_target, exceptions = self.
match(
221 catalog_ref, catalog_target, wcs=wcs, **kwargs
223 return pipeBase.Struct(
224 cat_output_ref=catalog_ref,
225 cat_output_target=catalog_target,
226 exceptions=exceptions,