206.1. Deblender outputs#
206.1. Deblender outputs¶
For the Rubin Science Platform at data.lsst.cloud.
Data Release: Data Preview 2
Container Size: Large
LSST Science Pipelines version: v30.0.11
Last verified to run: 2026-11-17
Repository: github.com/lsst/tutorial-notebooks
DOI: 10.11578/rubin/dc.20250909.20
Learning objective: This notebook demonstrates the meaning and basic use of deblender data products cataloged in the Object table.
LSST data products: Object table, deep_coadd
Packages: lsst.rsp, lsst.daf.butler, lsst.afw.display, lsst.images
Credit: Originally developed by the Rubin Community Science team. Please consider acknowledging them if this notebook is used for the preparation of journal articles, software releases, or other notebooks.
Get Support: Everyone is encouraged to ask questions or raise issues in the Support Category of the Rubin Community Forum. Rubin staff will respond to all questions posted there.
1. Introduction¶
This notebook is an introduction to the data products associated with deblending in the Object table. The deblender packages are based on Melchior et al. 2018 and the Scarlet software written by Peter Melchior and Fred Moolekamp.
See the Scarlet documentation for further information.
Detection
The first step in the deblending process is detection. A region of pixels connected by flux is a blend. Each blend (called a "parent" object) is identified if it has a signal-to-noise ratio (S/N) > 5 in a deep_coadd image. Each parent is given a unique parentObjectId, and the region occupied by the parent is called a footprint. If this footprint contains multiple flux peaks, it is classified as a blend. Each footprint may have one or more peaks, which the deblender uses to infer the number and positions of objects blended in each footprint.
Deconvolution and the blend hierarchy
In DP2, a partial deconvolution is performed prior to deblending. This convolves each deep_coadd to a Gaussian PSF with sigma=0.8, a well sampled kernel that is smaller than the best seeing in any band. The deconvolution process unblurs the footprints, enabling most blends to be sub-divided into smaller sub-blends that do not overlap in the deconvolved space. Because of this two-step spatial grouping, the hierarchy of a blended object contains multiple IDs:
parentObjectId: The ID of the original blended flux footprint.deblend_blendId: The ID of the intermediate deconvolved parent source that the final object was deblended from.objectId: The unique ID of the final deblended object.
Deblending
Once the sub-blends are isolated, the pipeline uses Scarlet Lite to characterize the individual objects making up the blend. The deblended sub-peaks are referred to as "children" of the parent. The algorithm separates the flux by simultaneously modeling the shape and multi-band flux of each child source to minimize the residual between the sum of the models and the actual observed flux.
The Object catalog consists only of isolated objects, objects that don't overlap with any other peaks, and the deblended child sources (parent objects are excluded).
References:
- An introduction to all of the available deblending flags, and the processes that produce the deblender data products discussed in this tutorial can be found in this overview of the deblending flags.
- A general discussion of blending impacts to LSST can be found in this article titled "The challenge of blending in large sky surveys" by Melchior et al. 2021.
- Some more in-depth presentations on the deblending implementation in the LSST Science Pipelines are available from recorded talks during the Rubin Project and Community Workshop 2022's session on Deblending Plans and Challenges.
Note: In DP2, visit images use a completely different deblending algorithm based on the SDSS deblender.
Related tutorials: A notebook demonstrating how to work with blend footprints is available as 206.2 Deblender footprints.
1.1. Import packages¶
The matplotlib, and astropy libraries are widely used Python libraries for plotting, scientific computing, and astronomical data analysis.
The RSPDiscovery class in the lsst.rsp package provides access to the Table Access Protocol (TAP) service for queries to the DP2 catalogs. Import LSST Science Pipelines packages for image display lsst.afw.display, lsst.images for working with images, and the lsst.daf.butler library is used to access data products via the butler.
import numpy as np
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
from lsst.daf.butler import Butler
from lsst.rsp import RSPDiscovery
import lsst.afw.display as afwDisplay
from lsst.images import Box
1.2. Define functions and parameters¶
The following cutout_coadd function enables the visualization of deblended products by making a cutout.
def cutout_coadd(butler, ra, dec, band='r', datasetType='deep_coadd',
cutoutSideLength=200, **kwargs):
"""
Produce a cutout from a coadd at the given ra, dec position.
Parameters
----------
butler: lsst.daf.persistence.Butler
Helper object providing access to a data repository
ra: float
Right ascension of the center of the cutout, in degrees
dec: float
Declination of the center of the cutout, in degrees
band: string
Filter of the image to load
datasetType: string ['deep_coadd']
Which type of coadd to load. Doesn't support 'calexp'
cutoutSideLength: float [optional]
Size of the cutout region in pixels.
Returns
-------
MaskedImage
"""
query = "band.name=band AND patch.region OVERLAPS POINT(ra, dec)"
refs = butler.query_datasets("deep_coadd", where=query,
bind={"band": band, "ra": ra, "dec": dec})
dataId = refs[0].dataId
point = SkyCoord(ra, dec, unit='deg')
wcs = butler.get('deep_coadd.sky_projection', dataId=dataId)
xy = wcs.sky_to_pixel(point)
selection_bbox = Box.factory[round(xy.y):round(xy.y)+1,
round(xy.x):round(xy.x)+1].padded(cutoutSideLength)
params = {'bbox': selection_bbox}
subset = butler.get(refs[0], parameters=params)
return subset
Set the backend for afwDisplay to matplotlib.
afwDisplay.setDefaultBackend('matplotlib')
Get an instance of the TAP service.
discovery = RSPDiscovery("dp2")
service = discovery.get_tap_client()
Instantiate the butler.
butler = Butler('dp2', collections=["dp2"])
2. The deblender data products¶
The Object table contains columns that can be used to identify and characterize blended objects in the deep_coadd images; they key columns are described below.
Scarlet blend flags
detect_fromBlend(boolean): If True, this source is deblended from a parent with more than one child.detect_isIsolated(boolean): If True, this source was not part of a blend.
Scarlet Lite blend measurements
parentObjectId(long): Unique ID of parent source.deblend_parentNPeaks(int): Total number of peaks in the parent footprint, even if some of them were skipped or failed to deblenddeblend_parentNChild(int): Number of objects with the sameparentObjectId(ie. share the same parent Footprint)deblend_blendId(long): Unique ID of sub-blend (in PSF-deconvolved space)deblend_blendNChild(long): Number of objects with the samedeblend_blendId(ie. from the same sub-blend in PSF-deconvolved space).footprintArea(int): Number of pixels in the deblended object's detection "footprint", in the "reference band".deblend_chi2(float): reduced chi^2 for the Scarlet Lite fit.
Known issues
In DP2, the meas_extensions_scarlet routine in the LSST pipelines had a bug. These issues are summarized in the DP2 known issues documentation. These are expected to be fixed in DR1 but in the meantime the following columns (blendedness parameters) of the Object table should not be used.
{band}_blendedness(dbl): For each filter ({band}= u, g, r, i, z, or y), a measure of how much the flux is affected by neighbors, (1 -child_flux/parent_flux). The measurement is in the observed, not point spread function (PSF)-deconvolved, space. Operates on the absolute value of the pixels to try to obtain a de-noised value. These are not performed by the deblender (Scarlet Lite) but rather from a blendedness algorithm (see section 4.9.11 of Bosch et al. 2018, PASJ, 70, S5 for details).{band}_deblend_blendedness(dbl): Blendedness in filter{band}in the PSF-deconvolved space.{band}_blendedness_flag(boolean): Flag set for any failure in the blendedness algorithm.{band}_deblend_fluxOverlap(dbl): The total flux from neighboring objects that overlaps with this sources footprint in the deconvolved space. See also{band}_deblend_fluxOverlapFraction. Fraction of flux from neighbors / source flux in the deconvolved footprint.
2.1. Identify blended objects¶
Set the location for the query for blends to be in the center of the Extended Chandra Deep Field South (ECDFS) field.
ra = 53.2
dec = -28.1
Query for objects in a small region of ECDFS for exploration of the deblender data products stored in the Object table.
query = """SELECT objectId, coord_ra, coord_dec, tract, patch,
deblend_peak_center_x, deblend_peak_center_y,
refExtendedness, detect_fromBlend, detect_isIsolated,
parentObjectId, deblend_parentNChild,
footprintArea, deblend_blendNChild
FROM dp2.Object
WHERE CONTAINS(POINT('ICRS', coord_ra, coord_dec ),
CIRCLE('ICRS',{}, {}, 0.01)) = 1""".format(ra, dec)
Run the TAP query. Store the resulting objects and columns from the Object table to a table called results.
job = service.submit_job(query)
job.run()
job.wait(phases=['COMPLETED', 'ERROR'])
print('Job phase is', job.phase)
if job.phase == 'ERROR':
job.raise_if_error()
assert job.phase == 'COMPLETED'
results = job.fetch_result().to_table()
Job phase is COMPLETED
Option to view the results table.
# results
2.2. Identify isolated objects¶
A sample of objects that are not near any neighbors, and therefore were not deblended, can be identified using the detect_isIsolated keyword. Similarly, a set of objects that were identified as part of a blend can be identified using the detect_fromBlend keyword.
whiso = np.where(results['detect_isIsolated'] == 1)[0]
whblend = np.where(results['detect_fromBlend'] == 1)[0]
Generate a cutout of the i-band deep_coadd imaging that overlaps the queried objects, centered at (RA, Dec) = 53.2, -28.1. degrees, with a cutout edge size of 200 pixels.
cutout = cutout_coadd(butler, ra, dec, band='i')
Display the cutout with isolated objects identified by red circles and blended objects identified as cyan plus signs. To ensure that afwDisplay will make the low surface brightness connecting the blends together visible, set the scale to linear, set the min and max pixel values to be relatively low and also indicate with units=Absolute that these should be in actual count units.
fig = plt.figure(figsize=(6, 6))
display = afwDisplay.Display(frame=fig)
display.scale('linear', min=0.1, max=10, unit='Absolute')
display.image(cutout.image)
with display.Buffering():
for ci in range(len(whiso)):
display.dot('o', results['deblend_peak_center_x'][whiso][ci],
results['deblend_peak_center_y'][whiso][ci],
size=10, ctype=afwDisplay.RED)
for ci in range(len(whblend)):
display.dot('+', results['deblend_peak_center_x'][whblend][ci],
results['deblend_peak_center_y'][whblend][ci],
size=8, ctype=afwDisplay.CYAN)
plt.gca().axis('off')
display.show_colorbar(False)
plt.show()
Figure 1: The cutout image displayed in greyscale, with cyan + marking objects that are blended in the
deep_coadd, red circles marking objects that are isolated (and is not part of a blend).
blends = results[results['deblend_parentNChild'] == 9]
parentId_blend = blends['parentObjectId'][0]
Use TAP to retrieve all children for the selected parent.
query = """SELECT objectId, coord_ra, coord_dec, parentObjectId,
deblend_peak_center_x, deblend_peak_center_y, detect_isIsolated,
deblend_blendNChild, deblend_parentNChild,
i_cModelFlux/i_cModelFluxErr AS i_S2N, footprintArea
FROM dp2.Object
WHERE CONTAINS(POINT('ICRS', coord_ra, coord_dec),
CIRCLE('ICRS', {}, {}, 0.1)) = 1
AND parentObjectId = {}""".format(ra, dec, parentId_blend)
Run the TAP query. Store the query results in a table called children.
job = service.submit_job(query)
job.run()
job.wait(phases=['COMPLETED', 'ERROR'])
print('Job phase is', job.phase)
if job.phase == 'ERROR':
job.raise_if_error()
assert job.phase == 'COMPLETED'
children = job.fetch_result().to_table()
Job phase is COMPLETED
Display the table of child sources.
children
| objectId | coord_ra | coord_dec | parentObjectId | deblend_peak_center_x | deblend_peak_center_y | detect_isIsolated | deblend_blendNChild | deblend_parentNChild | i_S2N | footprintArea |
|---|---|---|---|---|---|---|---|---|---|---|
| deg | deg | pix | pix | pix | ||||||
| int64 | float64 | float64 | int64 | int32 | int32 | bool | int32 | int32 | float64 | int32 |
| 755369573523417649 | 53.195381647215086 | -28.09167411634946 | 755369573523393095 | 13287 | 4720 | False | 1 | 9 | 23.134622584059656 | 661 |
| 755369573523417657 | 53.19813219130708 | -28.089153730759758 | 755369573523393095 | 13243 | 4765 | False | 2 | 9 | 24.83021634129162 | 869 |
| 755369573523417656 | 53.19839171042369 | -28.0895291123896 | 755369573523393095 | 13239 | 4758 | False | 2 | 9 | 59.377194217972146 | 1309 |
| 755369573523417655 | 53.19823813180421 | -28.091640521761732 | 755369573523393095 | 13241 | 4720 | False | 2 | 9 | 51.57546089197509 | 1346 |
| 755369573523417654 | 53.19750831869274 | -28.09166987329906 | 755369573523393095 | 13253 | 4719 | False | 2 | 9 | 57.78613021709485 | 1460 |
| 755369573523417653 | 53.19961517576545 | -28.09036474932871 | 755369573523393095 | 13220 | 4743 | False | 1 | 9 | 113.66700412484708 | 1318 |
| 755369573523417652 | 53.196679499925445 | -28.092128022740095 | 755369573523393095 | 13266 | 4711 | False | 1 | 9 | 16.95651970227494 | 1031 |
| 755369573523417651 | 53.19506400989808 | -28.092243447040055 | 755369573523393095 | 13292 | 4709 | False | 1 | 9 | 6.228329277070706 | 507 |
| 755369573523417650 | 53.19848562388947 | -28.09046463236648 | 755369573523393095 | 13237 | 4741 | False | 1 | 9 | 10.611796962888741 | 1476 |
The table above confirms that the children returned by the query were deblended from the same parent source, since they all show the same parentObjectId.
Above, the blend was selected by the number of objects that were blended in the same parent (by searching for objects with the same parentObjectId). After deblending the parent object, the deconvolved light profile of the blended sources may or may not also be blended in deconvolved space. This is what the keyword
deblend_blendNChild tracks. Below, identify those deblended children that are still blended with other sources in devolved space.
whNchild = np.where(children['deblend_blendNChild'] > 1)[0]
Next, visualize these test cases along with the other child sources of this parentObjectId. Use the cutout_coadd function to obtain a cutout image to visualize the blend. Set the size of the cutout to be the square root of the footprintArea.
cutout_children = cutout_coadd(butler, children['coord_ra'][0],
children['coord_dec'][0], band='i',
cutoutSideLength=1.0 * np.sqrt(np.sum(children['footprintArea'])))
Display the deepCoadd cutout made for this parent, with all deblended children identified with red circles. Identify the children which are close enough neighbors to still be blended in the PSF-decolved space, i.e. deblend_blendNChild > 1, with a cyan circle.
fig = plt.figure(figsize=(6, 6))
display = afwDisplay.Display(frame=fig)
display.scale('linear', min=0.1, max=10, unit='Absolute')
display.image(cutout_children.image)
with display.Buffering():
for ci in range(len(children)):
display.dot('o', children['deblend_peak_center_x'][ci],
children['deblend_peak_center_y'][ci],
size=10, ctype=afwDisplay.RED)
for ci in range(len(whNchild)):
display.dot('o', children['deblend_peak_center_x'][whNchild][ci],
children['deblend_peak_center_y'][whNchild][ci],
size=8, ctype=afwDisplay.CYAN)
plt.gca().axis('off')
display.show_colorbar(False)
plt.show()
Figure 2: The cutout image displayed in greyscale, with red circles marking all of the deblended children, and cyan circles indicating any children who are still blended with neighbors in the devolved space. Very close pairs are identified from the blend, compared to the red-only circles that indicate isolated sources once deconvolved.
4. Identify isolated or lightly blended sample¶
As mentioned in Section 2, a number of parameters that were used to flag or remove heavy blends in DP1 are impacted by a bug in DP2 (but will be fixed in DR1). In the meantime, the flags presented below can be used to identify a clean sample of objects for analysis that is not compromised by heavy blending, and also not restricted to completely isolated objects (flagged by detect_isIsolated).
Since the blendedness keyword is typically used as a cleanliness flag to ensure a sample is not impacted by serious blending, an alternative option is to use the column deblend_blendNChild to select all of the sources that are isolated after deblending (in the PSF-deconvolved space), in combination with the detect_isIsolated flag to identify objects that are isolated in observed space. Thus using (deblend_blendNChild == 1) | detect_isIsolated in combination in object queries can approximate typical cleanliness cuts that use blendedness outputs (e.g. blendedness < 0.1).
Using the results table from Section 2, determine which objects meet this cleanliness cut.
wh_selected = np.where((results['deblend_blendNChild'] == 1)
| (results['detect_isIsolated'] == 1))[0]
fig = plt.figure(figsize=(6, 6))
display = afwDisplay.Display(frame=fig)
display.scale('linear', min=0.1, max=10, unit='Absolute')
display.image(cutout.image)
with display.Buffering():
for ci in range(len(results)):
display.dot('o', results['deblend_peak_center_x'][ci],
results['deblend_peak_center_y'][ci],
size=10, ctype=afwDisplay.RED)
for ci in range(len(wh_selected)):
display.dot('+', results['deblend_peak_center_x'][wh_selected][ci],
results['deblend_peak_center_y'][wh_selected][ci],
size=8, ctype=afwDisplay.CYAN)
plt.gca().axis('off')
display.show_colorbar(False)
plt.show()
Figure 3: The cutout image displayed in greyscale, with red circles marking all objects in the search radius, and cyan plus signs indicating the selected objects which met the required cleanliness cut for analysis, namely
(deblend_blendNChild == 1) | detect_isIsolatedin lieu of using a blendedness threshold.