Skip to content

Commit

Permalink
Change reference object prefix to ref_
Browse files Browse the repository at this point in the history
  • Loading branch information
taranu authored and jtmccann committed May 2, 2024
1 parent d1f6059 commit fd66298
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
54 changes: 29 additions & 25 deletions doc/lsst.source.injection/reference/41_match_injected_outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,27 @@ The matching tasks are ``MatchTractCatalogTask`` and ``DiffMatchedTractCatalogTa
The first task performs a spatial probablistic match with minimal flag cuts, and the second computes any relevant statistics.
These tasks are located under ``pipelines/match_injected_tract_catalog.yaml#match_object_to_truth,compare_object_to_truth`` alongside ``ConsolidateInjectedCatalogsTask``.
The pipeline graph for the consolidation and matching process is shown below:
○ injected_deepCoadd_catalog
○ │ skyMap
├─┤
│ ■ consolidate_injected_catalogs
│ │
│ ○ injected_deepCoadd_catalog_tract
│ │
○ │ │ injected_objectTable_tract
╭─┼─┼─┤
■ │ │ │ match_object_to_truth
│ │ │ │
◍ │ │ │ match_target_injected_deepCoadd_catalog_tract_injected_objectTable_tract, match_ref_injected_deepCoadd_catalog_tract_injected_objectTable_tract
╰─┴─┴─┤
■ compare_object_to_truth
○ matched_injected_deepCoadd_catalog_tract_injected_objectTable_tract

.. code::
○ injected_deepCoadd_catalog
○ │ skyMap
├─┤
│ ■ consolidate_injected_catalogs
│ │
│ ○ injected_deepCoadd_catalog_tract
│ │
○ │ │ injected_objectTable_tract
╭─┼─┼─┤
■ │ │ │ match_object_to_truth
│ │ │ │
◍ │ │ │ match_target_injected_deepCoadd_catalog_tract_injected_objectTable_tract, match_ref_injected_deepCoadd_catalog_tract_injected_objectTable_tract
╰─┴─┴─┤
■ compare_object_to_truth
○ matched_injected_deepCoadd_catalog_tract_injected_objectTable_tract
Matching two tract-level catalogs can be done trivially with a ``pipetask run`` command as below:

.. code::
Expand Down Expand Up @@ -98,7 +102,7 @@ Matching two tract-level catalogs can be done trivially with a ``pipetask run``

Within ``pipelines/match_injected_tract_catalog.yaml`` there are various config options for pre-matching flag selections, columns to copy from the reference and target catalogs, etc.

Vizualize the matched catalog and compute metrics
Visualize the matched catalog and compute metrics
=================================================

One metric to determine the quality of an injection run is completeness, or the ratio of matched sources to injected sources.
Expand All @@ -107,6 +111,7 @@ The following is an example of a completeness plot using ``matplotlib.pyplot``.
.. code-block:: python
from lsst.daf.butler import Butler
import astropy.units as u
import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -123,33 +128,33 @@ The following is an example of a completeness plot using ``matplotlib.pyplot``.
# Make a completeness plot.
band="i"
mag = f"refcat_{band}_mag"
flux = f"ref_{band}_flux"
mags = ((data[flux] * u.nJy).to(u.ABmag)).value
fig, axLeft = plt.subplots()
axRight = axLeft.twinx()
axLeft.tick_params(axis="y", labelcolor="C0")
axLeft.set_ylabel("Fraction Recovered", color="C0")
axLeft.set_xlabel("PSF Magnitude (mag)")
axRight.set_ylabel("Number of Sources")
nInput, bins, _ = axRight.hist(
data[mag],
range=(np.nanmin(data[mag]), np.nanmax(data[mag])),
mags,
range=(np.nanmin(mags), np.nanmax(mags)),
bins=121,
log=True,
histtype="step",
label="Synthetic Inputs",
color="black",
)
nOutput, _, _ = axRight.hist(
data[mag][matched],
range=(np.nanmin(data[mag][matched]), np.nanmax(data[mag][matched])),
mags[matched],
range=(np.nanmin(mags[matched]), np.nanmax(mags[matched])),
bins=bins,
log=True,
histtype="step",
label="Synthetic Recovered",
color="grey",
)
xlims = plt.gca().get_xlim()
# Find bin where the fraction recovered first falls below 0.5
lessThanHalf = np.where((nOutput / nInput < 0.5))[0]
if len(lessThanHalf) == 0:
Expand All @@ -170,7 +175,6 @@ The following is an example of a completeness plot using ``matplotlib.pyplot``.
alpha=0.5,
zorder=10,
)
# Add useful information to the plot.
bboxDict = dict(boxstyle="round", facecolor="white", alpha=0.75)
info50 = "Magnitude at 50% recovered: {:0.2f}".format(mag50)
axLeft.text(0.3, 0.15, info50, transform=fig.transFigure, bbox=bboxDict, zorder=11)
Expand Down
1 change: 1 addition & 0 deletions pipelines/match_injected_tract_catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tasks:
config:
connections.name_input_cat_ref: injected_deepCoadd_catalog_tract
connections.name_input_cat_target: injected_objectTable_tract
column_matched_prefix_ref: "ref_"
column_ref_extended: source_type
# TODO: Remove as part of DM-44139
columns_ref_mag_to_nJy: {
Expand Down

0 comments on commit fd66298

Please sign in to comment.