201.12. CoaddPatches table#
201.12. CoaddPatches table¶
For the Rubin Science Platform at data.lsst.cloud.
Data Release: Data Preview 2
Container Size: Large
LSST Science Pipelines version: r30.0.10
Last verified to run: 2026-07-24
Repository: github.com/lsst/tutorial-notebooks
DOI: 10.11578/rubin/dc.20250909.20
Learning objective: To understand the contents of the CoaddPatches table and how to access it.
LSST data products: CoaddPatches
Packages: lsst.rsp.RSPDiscovery
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¶
The CoaddPatches table contains static information about the subset of tracts and patches from the standard LSST skymap that apply to coadds in these catalog.
- TAP table name:
dp2.CoaddPatches - columns: 5
Related tutorials: The TAP data access service is demonstrated in the 100-level "How to" tutorials.
1.1. Import packages¶
Import standard python packages numpy, matplotlib, and skyproj for making sky projection plots.
From the lsst package, import RSPDiscovery for accessing the TAP service.
import numpy as np
import matplotlib.pyplot as plt
import skyproj
from lsst.rsp import RSPDiscovery
1.2. Define parameters and functions¶
Instantiate RSPDiscovery with the DP2 release, and get the TAP service from it.
discovery = RSPDiscovery("dp2")
service = discovery.get_tap_client()
2. Schema (columns)¶
To browse the table schema visit the Rubin schema browser, or use the TAP service via the Portal Aspect or as demonstrated in Section 2.1.
2.1. Retrieve table schema¶
To retrieve the table schema, define a query for the schema columns of the CoaddPatches table and run the query job.
query = "SELECT column_name, datatype, description, unit " \
"FROM tap_schema.columns " \
"WHERE table_name = 'dp2.CoaddPatches'"
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()
Job phase is COMPLETED
Retrieve the query results and display them as an astropy table with the to_table() attribute.
assert job.phase == 'COMPLETED'
results = job.fetch_result().to_table()
assert len(results) == 5
results
| column_name | datatype | description | unit |
|---|---|---|---|
| str64 | str64 | str512 | str64 |
| lsst_patch | long | ID number of the second level, 'patch', within the standard LSST skymap | |
| lsst_tract | long | ID number of the top level, 'tract', within the standard LSST skymap | |
| s_dec | double | Central Spatial Position in ICRS; Declination | deg |
| s_ra | double | Central Spatial Position in ICRS; Right ascension | deg |
| s_region | char | Sky region covered by the coadd (expressed in ICRS frame) |
The table displayed above has not been truncated, as it is only 5 rows long.
Delete the job, but not the results.
del query
job.delete()
3. Data access¶
The CoaddPatches table is available via the TAP service.
Recommended access method: TAP.
3.1. TAP (Table Access Protocol)¶
The CoaddPatches table is stored in Qserv and accessible via the TAP services using ADQL queries.
3.1.2. Demo query¶
Avoid full-table queries.
Although the DP2 CoaddPatches table is relatively small, it is good practice to always include spatial constraints and only retrieve necessary columns.
Search for coadd patches within 3 degrees of the center of the Extended Chandra Deep Field South (ECDFS) field, RA, Dec = $53.13, -28.10$. Return the patch ID, tract ID, central RA, DEC, and sky region covered by the coadd.
query = "SELECT lsst_patch, lsst_tract, s_ra, s_dec, s_region " \
"FROM dp2.CoaddPatches " \
"WHERE CONTAINS(POINT('ICRS', s_ra, s_dec), " \
"CIRCLE('ICRS', 53.13, -28.10, 3)) = 1 "
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()
Job phase is COMPLETED
Fetch the results as an astropy table.
assert job.phase == 'COMPLETED'
results = job.fetch_result().to_table()
print(len(results))
1246
Option to display the table.
# results
Draw all patch boundaries on the sky using a McBryde sky projection, using a unique random color for each tract, and zooming in to the patch search region using extent.
tract_colors = {}
for utract in np.unique(results['lsst_tract']):
tract_colors[utract] = np.random.rand(3)
fig, ax = plt.subplots(figsize=(6, 6))
ra_cen = 53.13
dec_cen = -28.10
radius = 3.0
extent = [ra_cen - radius, ra_cen + radius,
dec_cen - radius, dec_cen + radius]
sp = skyproj.McBrydeSkyproj(ax=ax, extent=extent)
for i, s_region in enumerate(results['s_region']):
vertices = np.array(s_region.split()[2:], dtype=float)
ras = vertices[0::2]
decs = vertices[1::2]
sp.draw_polygon(ras, decs, edgecolor=tract_colors[results['lsst_tract'][i]],
alpha=1, linewidth=0.5, facecolor=None)
sp.ax.set_xlabel("Right Ascension", fontsize=14)
sp.ax.set_ylabel("Declination", fontsize=14)
plt.tight_layout()
plt.show()
del sp
Figure 1: Patch boundaries for all patches returned by the query, with each tract a different random color and sky gridlines in grey.
Zoom in on the center region to better show how tracts and patches overlap.
fig, ax = plt.subplots(figsize=(4, 4))
ra_cen = 53.0
dec_cen = -28.2
radius = 0.3
extent = [ra_cen - radius, ra_cen + radius,
dec_cen - radius, dec_cen + radius]
sp = skyproj.McBrydeSkyproj(ax=ax, extent=extent)
for i, s_region in enumerate(results['s_region']):
vertices = np.array(s_region.split()[2:], dtype=float)
ras = vertices[0::2]
decs = vertices[1::2]
sp.draw_polygon(ras, decs, edgecolor=tract_colors[results['lsst_tract'][i]],
alpha=0.8, linewidth=1, facecolor=None)
sp.ax.set_xlabel("Right Ascension", fontsize=14)
sp.ax.set_ylabel("Declination", fontsize=14)
plt.tight_layout()
plt.show()
del sp
Figure 2: A zoom-in on the central region of Figure 1 to show how tracts overlap tracts, and patches overlap patches.
Clean up.
job.delete()
del query, results