6060}
6161
6262
63+ def _apply_fakes_prefix (image_datasets , use_fakes ):
64+ """Prepend the fake-source pipeline's prefixes to the science and
65+ template image dataset names when ``use_fakes`` is True: ``fakes_``
66+ for the science image, ``injectedTemplate_`` for the template. The
67+ difference image and all catalogs keep their non-prefixed names
68+ (the fake-source pipeline injects into science + template but
69+ re-uses the same downstream artifacts).
70+ """
71+ if not use_fakes :
72+ return image_datasets
73+ return {
74+ "science" : f"fakes_{ image_datasets ['science' ]} " ,
75+ "template" : f"injectedTemplate_{ image_datasets ['template' ]} " ,
76+ "difference" : image_datasets ["difference" ],
77+ }
78+
79+
6380def _cutout_exists (cpath , dia_source_id ):
6481 """Return True if a cutout PNG for this diaSourceId already exists.
6582
@@ -1427,7 +1444,8 @@ def display_images(butler, visit, detector, backend="firefly", *,
14271444 skymap = None ,
14281445 skymap_ctype = "green" ,
14291446 skymap_label_size = 1.5 ,
1430- image_datasets = _IMAGE_DATASETS ):
1447+ image_datasets = _IMAGE_DATASETS ,
1448+ use_fakes = False ):
14311449 """Display the science, template, and difference images for a given
14321450 visit+detector with diagnostic catalog markers overlaid.
14331451
@@ -1529,8 +1547,16 @@ def display_images(butler, visit, detector, backend="firefly", *,
15291547 Mapping from image-type key (``"science"``, ``"template"``,
15301548 ``"difference"``) to butler dataset name. Override to point at
15311549 alternate dataset types.
1550+ use_fakes : `bool`, optional
1551+ If True, load the fake-source-injected versions of the science
1552+ and template images: ``fakes_`` prefix on the science dataset
1553+ and ``injectedTemplate_`` prefix on the template dataset. The
1554+ difference image and every catalog keep their non-prefixed
1555+ names, per the fake-source pipeline's output convention.
1556+ Default False.
15321557 """
15331558 data_id = {"visit" : visit , "detector" : detector }
1559+ image_datasets = _apply_fakes_prefix (image_datasets , use_fakes )
15341560
15351561 diffim = butler .get (image_datasets ["difference" ], data_id )
15361562 science = butler .get (image_datasets ["science" ], data_id )
@@ -1609,7 +1635,8 @@ def display_images_ab(butler_a, butler_b, visit, detector, *,
16091635 skymap = None ,
16101636 skymap_ctype = "green" ,
16111637 skymap_label_size = 1.5 ,
1612- image_datasets = _IMAGE_DATASETS ):
1638+ image_datasets = _IMAGE_DATASETS ,
1639+ use_fakes = False ):
16131640 """Display one image type side-by-side from two butlers, with overlays.
16141641
16151642 Loads the same (visit, detector) from ``butler_a`` and ``butler_b``,
@@ -1635,13 +1662,14 @@ def display_images_ab(butler_a, butler_b, visit, detector, *,
16351662 show_solar_system, show_apdb, show_reliability_labels, show_dipoles,
16361663 show_trail_geometry, line_length_scale, label_size, color_by,
16371664 mask_transparency, strip_metadata, skymap, skymap_ctype,
1638- skymap_label_size, image_datasets
1665+ skymap_label_size, image_datasets, use_fakes
16391666 Same meaning as in `display_images`. Applied to both frames; the
16401667 tract/patch overlay uses each frame's own exposure WCS.
16411668 """
16421669 if image_type not in image_datasets :
16431670 raise ValueError (
16441671 f"image_type must be one of { sorted (image_datasets )} , got { image_type !r} " )
1672+ image_datasets = _apply_fakes_prefix (image_datasets , use_fakes )
16451673 dataset = image_datasets [image_type ]
16461674 data_id = {"visit" : visit , "detector" : detector }
16471675
@@ -1836,6 +1864,7 @@ def display_footprints(butler=None, visit=None, detector=None,
18361864 catalog_dataset = "dia_source_unfiltered" ,
18371865 style = "outline" ,
18381866 palette = _OBJECT_PALETTE ,
1867+ frame = 0 ,
18391868 mask_transparency = 80 ,
18401869 strip_metadata = True ,
18411870 image_datasets = _IMAGE_DATASETS ):
@@ -1903,6 +1932,8 @@ def display_footprints(butler=None, visit=None, detector=None,
19031932 palette : sequence of `str`, optional
19041933 Colors cycled across footprints. Defaults to the 12-color
19051934 ``_OBJECT_PALETTE`` also used by the cutout plotters.
1935+ frame : `int`, optional
1936+ Display frame to draw the image and footprints in. Default ``0``.
19061937 mask_transparency : `int` or `None`, optional
19071938 Mask-plane transparency forwarded to the display (0 = opaque,
19081939 100 = fully transparent). Pass ``None`` to leave it untouched.
@@ -1969,7 +2000,7 @@ def display_footprints(butler=None, visit=None, detector=None,
19692000 afw_display = lsst .afw .display .Display (backend = backend )
19702001 if mask_transparency is not None :
19712002 afw_display .setMaskTransparency (mask_transparency )
1972- afw_display .frame = 0
2003+ afw_display .frame = frame
19732004 # image() only replaces pixel data; wipe stale region markers first.
19742005 _erase_current_frame_regions (afw_display )
19752006 afw_display .image (exposure , title = title )
0 commit comments