match_to_truth#

lsst.analysis.ap.match_to_truth(srcs, truth, radius=<Quantity 0.5 arcsec>, src_ra='ra', src_dec='dec', src_id='diaSourceId', truth_ra='ra', truth_dec='dec', truth_id='injection_id')#

Match a detected catalog against a truth/injection catalog.

Performs the match in both directions to compute purity (fraction of detections that correspond to a real injected source) and completeness (fraction of injected sources recovered).

Parameters#

srcspandas.DataFrame

Detected sources.

truthpandas.DataFrame

Truth catalog, e.g. an injection catalog.

radiusastropy.units.Quantity or float

Maximum separation for a match.

src_ra, src_dec, src_idstr

Column names in srcs.

truth_ra, truth_dec, truth_idstr

Column names in truth.

Returns#

outdict

With keys:

  • "srcs": a copy of srcs with three columns appended: "is_real" (bool), "truth_dist_arcsec" (float), and f"{truth_id}_match" (matched truth id, NA if no match).

  • "truth": a copy of truth with three columns appended: "detected", "detection_dist_arcsec", and f"{src_id}_match".

  • "purity": float, fraction of srcs rows with is_real.

  • "completeness": float, fraction of truth rows with detected.