LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes | List of all members
lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask Class Reference
Inheritance diagram for lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask:
lsst.pipe.tasks.match_tract_catalog_probabilistic.MatchTractCatalogProbabilisticTask

Public Member Functions

Set[str] columns_in_ref (self)
 
Set[str] columns_in_target (self)
 
Tuple[pd.DataFrame, pd.DataFrame, Dict[int, str]] match (self, pd.DataFrame catalog_ref, pd.DataFrame catalog_target, np.array select_ref=None, np.array select_target=None, afwGeom.SkyWcs wcs=None, logging.Logger logger=None, int logging_n_rows=None)
 
pipeBase.Struct run (self, pd.DataFrame catalog_ref, pd.DataFrame catalog_target, afwGeom.SkyWcs wcs=None, **kwargs)
 
 __init__ (self, **kwargs)
 

Public Attributes

 matcher
 

Static Public Attributes

 ConfigClass = MatchProbabilisticConfig
 

Static Protected Member Functions

np.array _apply_select_bool (pd.DataFrame catalog, List[str] columns_true, List[str] columns_false, Optional[np.array] selection)
 

Static Protected Attributes

str _DefaultName = "matchProbabilistic"
 

Detailed Description

Run MatchProbabilistic on a reference and target catalog covering the same tract.

Definition at line 44 of file match_probabilistic_task.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.__init__ ( self,
** kwargs )

Reimplemented in lsst.pipe.tasks.match_tract_catalog_probabilistic.MatchTractCatalogProbabilisticTask.

Definition at line 229 of file match_probabilistic_task.py.

229 def __init__(self, **kwargs):
230 super().__init__(**kwargs)
231 self.matcher = MatcherProbabilistic(self.config)

Member Function Documentation

◆ _apply_select_bool()

np.array lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask._apply_select_bool ( pd.DataFrame catalog,
List[str] columns_true,
List[str] columns_false,
Optional[np.array] selection )
staticprotected
Apply additional boolean selection columns.

catalog : `pandas.DataFrame`
    The catalog to select from.
columns_true : `list` [`str`]
    Columns that must be True for selection.
columns_false : `list` [`str`]
    Columns that must be False for selection.
selection : `numpy.array`
    A prior selection array. Default all true.

Returns
-------
selection : `numpy.array`
    The final selection array.

Definition at line 51 of file match_probabilistic_task.py.

56 ) -> np.array:
57 """Apply additional boolean selection columns.
58
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.
67
68 Returns
69 -------
70 selection : `numpy.array`
71 The final selection array.
72
73 """
74 select_additional = (len(columns_true) + len(columns_false)) > 0
75 if select_additional:
76 if selection is None:
77 selection = np.ones(len(catalog), dtype=bool)
78 for column in columns_true:
79 # This is intended for boolean columns, so the behaviour for non-boolean is not obvious
80 # More config options and/or using a ConfigurableActionField might be best
81 values = catalog[column].values
82 selection &= (np.isfinite(values) & (values != 0))
83 for column in columns_false:
84 selection &= (catalog[column].values == 0)
85 return selection
86

◆ columns_in_ref()

Set[str] lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.columns_in_ref ( self)

Definition at line 88 of file match_probabilistic_task.py.

88 def columns_in_ref(self) -> Set[str]:
89 return self.config.columns_in_ref
90

◆ columns_in_target()

Set[str] lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.columns_in_target ( self)

Definition at line 92 of file match_probabilistic_task.py.

92 def columns_in_target(self) -> Set[str]:
93 return self.config.columns_in_target
94

◆ match()

Tuple[pd.DataFrame, pd.DataFrame, Dict[int, str]] lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.match ( self,
pd.DataFrame catalog_ref,
pd.DataFrame catalog_target,
np.array select_ref = None,
np.array select_target = None,
afwGeom.SkyWcs wcs = None,
logging.Logger logger = None,
int logging_n_rows = None )
Match sources in a reference tract catalog with a target catalog.

Parameters
----------
catalog_ref : `pandas.DataFrame`
    A reference catalog to match objects/sources from.
catalog_target : `pandas.DataFrame`
    A target catalog to match reference objects/sources to.
select_ref : `numpy.array`
    A boolean array of the same length as `catalog_ref` selecting the sources that can be matched.
select_target : `numpy.array`
    A boolean array of the same length as `catalog_target` selecting the sources that can be matched.
wcs : `lsst.afw.image.SkyWcs`
    A coordinate system to convert catalog positions to sky coordinates. Only used if
    `self.config.coords_ref_to_convert` is set.
logger : `logging.Logger`
    A Logger for logging.
logging_n_rows : `int`
    Number of matches to make before outputting incremental log message.

Returns
-------
catalog_out_ref : `pandas.DataFrame`
    Reference matched catalog with indices of target matches.
catalog_out_target : `pandas.DataFrame`
    Reference matched catalog with indices of target matches.

Definition at line 95 of file match_probabilistic_task.py.

104 ) -> Tuple[pd.DataFrame, pd.DataFrame, Dict[int, str]]:
105 """Match sources in a reference tract catalog with a target catalog.
106
107 Parameters
108 ----------
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.
124
125 Returns
126 -------
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.
131 """
132 if logger is None:
133 logger = self.log
134
135 config = self.config
136
137 if config.column_ref_order is None:
138 flux_tot = np.nansum(
139 catalog_ref.loc[:, config.columns_ref_flux].values, axis=1
140 )
141 catalog_ref["flux_total"] = flux_tot
142 if config.mag_brightest_ref != -np.inf or config.mag_faintest_ref != np.inf:
143 mag_tot = (
144 -2.5 * np.log10(flux_tot) + config.coord_format.mag_zeropoint_ref
145 )
146 select_mag = (mag_tot >= config.mag_brightest_ref) & (
147 mag_tot <= config.mag_faintest_ref
148 )
149 else:
150 select_mag = np.isfinite(flux_tot)
151 if select_ref is None:
152 select_ref = select_mag
153 else:
154 select_ref &= select_mag
155
156 select_ref = self._apply_select_bool(
157 catalog=catalog_ref,
158 columns_true=config.columns_ref_select_true,
159 columns_false=config.columns_ref_select_false,
160 selection=select_ref,
161 )
162 select_target = self._apply_select_bool(
163 catalog=catalog_target,
164 columns_true=config.columns_target_select_true,
165 columns_false=config.columns_target_select_false,
166 selection=select_target,
167 )
168
169 logger.info(
170 "Beginning MatcherProbabilistic.match with %d/%d ref sources selected vs %d/%d target",
171 np.sum(select_ref),
172 len(select_ref),
173 np.sum(select_target),
174 len(select_target),
175 )
176
177 catalog_out_ref, catalog_out_target, exceptions = self.matcher.match(
178 catalog_ref,
179 catalog_target,
180 select_ref=select_ref,
181 select_target=select_target,
182 logger=logger,
183 logging_n_rows=logging_n_rows,
184 wcs=wcs,
185 radec_to_xy_func=radec_to_xy,
186 )
187
188 return catalog_out_ref, catalog_out_target, exceptions
189

◆ run()

pipeBase.Struct lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.run ( self,
pd.DataFrame catalog_ref,
pd.DataFrame catalog_target,
afwGeom.SkyWcs wcs = None,
** kwargs )
Match sources in a reference tract catalog with a target catalog.

Parameters
----------
catalog_ref : `pandas.DataFrame`
    A reference catalog to match objects/sources from.
catalog_target : `pandas.DataFrame`
    A target catalog to match reference objects/sources to.
wcs : `lsst.afw.image.SkyWcs`
    A coordinate system to convert catalog positions to sky coordinates.
    Only needed if `config.coords_ref_to_convert` is used to convert
    reference catalog sky coordinates to pixel positions.
kwargs : Additional keyword arguments to pass to `match`.

Returns
-------
retStruct : `lsst.pipe.base.Struct`
    A struct with output_ref and output_target attribute containing the
    output matched catalogs, as well as a dict

Reimplemented in lsst.pipe.tasks.match_tract_catalog_probabilistic.MatchTractCatalogProbabilisticTask.

Definition at line 191 of file match_probabilistic_task.py.

197 ) -> pipeBase.Struct:
198 """Match sources in a reference tract catalog with a target catalog.
199
200 Parameters
201 ----------
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`.
211
212 Returns
213 -------
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
217 """
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
222 )
223 return pipeBase.Struct(
224 cat_output_ref=catalog_ref,
225 cat_output_target=catalog_target,
226 exceptions=exceptions,
227 )
228

Member Data Documentation

◆ _DefaultName

str lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask._DefaultName = "matchProbabilistic"
staticprotected

Definition at line 48 of file match_probabilistic_task.py.

◆ ConfigClass

lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.ConfigClass = MatchProbabilisticConfig
static

Definition at line 47 of file match_probabilistic_task.py.

◆ matcher

lsst.meas.astrom.match_probabilistic_task.MatchProbabilisticTask.matcher

Definition at line 231 of file match_probabilistic_task.py.


The documentation for this class was generated from the following file: