301.1. Prompt Products overview#
301.1. Prompt Products overview¶
For the Rubin Science Platform at data.lsst.cloud.
Data Release: Prompt Products database
Container Size: Large
LSST Science Pipelines version: r30.0.11
Last verified to run: 2026-11-30
Repository: github.com/lsst/tutorial-notebooks
DOI: 10.11578/rubin/dc.20250909.20
Learning objective: Learn about the data in the Prompt Products Database (PPDB).
LSST data products: ppdb
Packages: lsst.rsp
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 provides tools to explore the data included in the Prompt Products Database (PPDB; https://prompt-products.lsst.io). These data include catalogs resulting from the execution of the alert production pipeline, which performs difference imaging in real time, detecting and measuring sources in the difference images. The PPDB is a database accessible via TAP from the Rubin Science Platform (RSP).
The PPDB will be continuously updated throughout the LSST survey, whenever new observations are taken and the alert production pipeline is run. Thus, the PPDB's datasets will evolve and grow with time.
This notebook mostly uses information from the ppdb.DiaSource table. Because DiaSource contains detections and measurements from each visit's difference image, it is the basis of most of the other tables, which are aggregations or augmentations of the initial diaSource information.
Related tutorials: Refer to the 100-level tutorials for how to use the RSP's PPDB TAP service, and the 200-level tutorials for details on the tables included in the PPDB.
1.1. Import packages¶
Import numpy, a fundamental package for scientific computing with arrays in Python
(numpy.org), and
matplotlib, a comprehensive library for data visualization
(matplotlib.org; matplotlib gallery). Import Astropy (astropy.org) tools for astronomy-specific functionality.
From the lsst package, import modules for accessing the Table Access Protocol (TAP) service, and plotting utility functions from the LSST Science Pipelines (pipelines.lsst.io).
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
from astropy.table import Table
from astropy.time import Time
from lsst.utils.plotting import (
get_multiband_plot_colors,
get_multiband_plot_symbols,
set_rubin_plotstyle
)
from lsst.rsp import RSPDiscovery
1.2. Define parameters and functions¶
Define filter names, colors, and symbols to represent the six LSST filters, $ugrizy$, in plots.
set_rubin_plotstyle()
filter_colors = get_multiband_plot_colors()
filter_names = filter_colors.keys()
filter_symbols = get_multiband_plot_symbols()
Get an instance of the TAP service, loading the "prompt" instance.
discovery = RSPDiscovery("prompt")
tap_service = discovery.get_tap_client()
query = """
SELECT * FROM tap_schema.tables
WHERE tap_schema.tables.schema_name = 'ppdb'
ORDER BY table_index ASC
"""
tables = tap_service.search(query).to_table()
tables
| schema_name | table_name | table_type | utype | description | table_index |
|---|---|---|---|---|---|
| str512 | str64 | str8 | str512 | str512 | int32 |
| ppdb | ppdb.DiaObject | table | Astronomical objects detected on one or more difference images, containing only the latest version of each record (i.e., with an open validity interval) | 40 | |
| ppdb | ppdb.DiaSource | table | Difference image sources detected on difference images | 50 | |
| ppdb | ppdb.DiaForcedSource | table | Forced-photometry source measurement on an individual difference Exposure for all objects in the DiaObject table | 60 | |
| ppdb | ppdb.mpc_orbits | table | Table of orbital elements and related information of known (sun-orbiting and unbound) Solar System objects. Replicated from the Minor Planet Center (Postgres) database. This schema will generally closely follow the schema of the upstream table, to allow end-users to rerun queries developed elsewhere on the RSP. | 100 | |
| ppdb | ppdb.SSObject | table | LSST-computed per-object quantities. | 110 | |
| ppdb | ppdb.SSObservation | table | Solar System source measurements: one row per Rubin observation submitted to and accepted by the MPC (obs_sbn), with the measurement it was submitted from (a DiaSource or a Source, see measuredOn) and its ephemeris from mpc_orbits. Built from the record of submitted measurements, independent of the PPDB DiaSource table (RFC-1188). | 120 | |
| ppdb | ppdb.NearbySSO | table | For each DiaSource, the nearest known Solar System object predicted (from mpc_orbits) within its matching radius (5 arcsec; 15 arcsec for comets and interstellar objects) with an uncertainty small enough for a meaningful association; and, with a NULL diaSourceId, each such prediction that matched no DiaSource but falls on, or within 30 arcsec of, a detector of the visit. Predictions are at the shutter-corrected mid-exposure time on the detector. Regenerated daily (RFC-1188). | 125 | |
| ppdb | ppdb.current_identifications | table | All single-designations, and all identifications between designations. Always uses primary provisional designation (even for numbered objects). Includes all comets and satellites. Replicated from the Minor Planet Center (Postgres) database. This schema will generally closely follow the schema of the upstream table, to allow end-users to rerun queries developed elsewhere on the RSP. | 140 | |
| ppdb | ppdb.numbered_identifications | table | The numbered identification table contains all the numbered objects (minor planets, comets and natural satellites) with their primary provisional designations. The table is continously updated everytime a new object is numbered. Replicated from the Minor Planet Center (Postgres) database. This schema will generally closely follow the schema of the upstream table, to allow end-users to rerun queries developed elsewhere on the RSP. | 150 |
Use the COUNT function in the TAP service to extract the number of rows in each table. Print the result to the screen.
table_cts = {}
for tab in tables['table_name']:
query = f"""
SELECT
COUNT(*)
FROM {tab}
"""
job = tap_service.submit_job(query)
job.run()
job.wait(phases=['COMPLETED', 'ERROR'])
print(f"Job phase for {tab} is", job.phase)
if job.phase == 'ERROR':
job.raise_if_error()
assert job.phase == 'COMPLETED'
count = job.fetch_result().to_table()
table_cts[tab.item()] = count['COUNT1'].value.data[0]
Table([table_cts])
Job phase for ppdb.DiaObject is COMPLETED Job phase for ppdb.DiaSource is COMPLETED Job phase for ppdb.DiaForcedSource is COMPLETED Job phase for ppdb.mpc_orbits is COMPLETED Job phase for ppdb.SSObject is COMPLETED Job phase for ppdb.SSObservation is COMPLETED Job phase for ppdb.NearbySSO is COMPLETED Job phase for ppdb.current_identifications is COMPLETED Job phase for ppdb.numbered_identifications is COMPLETED
| ppdb.DiaObject | ppdb.DiaSource | ppdb.DiaForcedSource | ppdb.mpc_orbits | ppdb.SSObject | ppdb.SSObservation | ppdb.NearbySSO | ppdb.current_identifications | ppdb.numbered_identifications |
|---|---|---|---|---|---|---|---|---|
| int64 | int64 | int64 | int64 | int64 | int64 | int64 | int64 | int64 |
| 5536740 | 18988816 | 27079617 | 1594887 | 307254 | 8224815 | 4260994 | 2119376 | 896611 |
2.2. Visit dates¶
To see the date range and number of observations per night and per-band, use SELECT DISTINCT in a TAP query of the DiaSource table to retrieve all unique combinations of visit, midpointMjdTai, and band.
query = """
SELECT DISTINCT visit, midpointMjdTai, band
FROM ppdb.DiaSource
"""
job = tap_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
If the status returned was "COMPLETED", execute this cell to retrieve the query results as an astropy table using the to_table method, and print the table to the screen.
assert job.phase == 'COMPLETED'
results = job.fetch_result().to_table()
results
| visit | midpointMjdTai | band |
|---|---|---|
| d | ||
| int64 | float64 | str1 |
| 2026112900875 | 61374.10733631319 | z |
| 2026112900876 | 61374.107794420765 | z |
| 2026112600024 | 61371.24740591447 | i |
| 2026112600026 | 61371.247898136455 | i |
| 2026112600042 | 61371.25663565576 | g |
| 2025121800203 | 61028.327190168304 | r |
| 2025110400322 | 60984.23132443137 | r |
| 2026011700316 | 61058.10139262001 | r |
| 2026011600063 | 61057.174238343505 | g |
| ... | ... | ... |
| 2025111600075 | 60996.05940347299 | g |
| 2025111800151 | 60998.18750933875 | i |
| 2026070600689 | 61228.320835615785 | i |
| 2026071300750 | 61235.37558614818 | z |
| 2026110700021 | 61352.01422913479 | i |
| 2026110700081 | 61352.11276200015 | g |
| 2026110700137 | 61352.142120834906 | r |
| 2026111200137 | 61357.07325929629 | r |
| 2025121600142 | 61026.24132631821 | i |
Count the number of visits in each band by looping over the bands and counting the number of unique visits in that band.
for filt in filter_names:
filt_count = len(np.where(results['band'] == filt)[0])
print(f"{filt}-band visits: {filt_count}")
u-band visits: 121 g-band visits: 1003 r-band visits: 1429 i-band visits: 2731 z-band visits: 1407 y-band visits: 80
Extract the observation times of the earliest and latest visits and print their dates to the screen. Use the Astropy Time class to facilitate conversion between representations.
mintime = results['midpointMjdTai'].min()
mintime_mjd = Time(mintime, format="mjd", scale="tai")
maxtime = results['midpointMjdTai'].max()
maxtime_mjd = Time(maxtime, format="mjd", scale="tai")
print(f"Earliest visit: {mintime_mjd.iso}")
print(f"Latest visit: {maxtime_mjd.iso}")
Earliest visit: 2025-10-25 03:07:35.085 Latest visit: 2026-11-30 05:24:36.644
Plot a histogram showing the number of visits per filter, per night. Plot the midpoint MJD time of observation on the x-axis, with the time in decimal years along the top (this requires defining two short functions to do the conversions).
def decimalyear_to_mjd(x):
return Time(x, format="decimalyear", scale="tai").mjd
def mjd_to_decimalyear(mjd):
return Time(mjd, format="mjd", scale="tai").decimalyear
fig, ax = plt.subplots(figsize=(9, 4))
days = np.arange(np.floor(results['midpointMjdTai'].min()), results['midpointMjdTai'].max(), 1.0)
bottom = np.zeros(len(days)-1)
for band in filter_names:
idx = (results['band'] == band)
hist, day_bins = np.histogram(results[idx]['midpointMjdTai'], bins=days)
p = ax.bar(days[:-1], hist, bottom=bottom, label=band, width=1.0, color=filter_colors[band])
bottom += hist
ax.set_title("Number of visits in each band per night")
ax.legend(loc="upper left")
plt.tick_params(axis="both", which="both", top=False)
sec_ax = ax.secondary_xaxis("top", functions=(mjd_to_decimalyear, decimalyear_to_mjd))
sec_ax.set_xlabel("date (decimal year)")
sec_ax.minorticks_on()
plt.semilogy()
plt.minorticks_on()
plt.xlabel('midpoint MJD')
plt.ylabel('number of visits')
plt.show()
Figure 1: Histogram showing the number of visits per night in each of the six $ugrizy$ bands from the list of visits taken from
ppdb.DiaSource. The lower x-axis labels dates by MJD, and the upper axis shows the corresponding date in decimal years.
3. Spatial distribution of diaObjects¶
Run a query to extract the number of diaObjects per degree in RA and Dec.
Warning: Note that the following query is not returning the number density per square degree, because it is not accounting for the distortion of boxes due to sky coordinates being in a spherical frame. It is meant solely to give a rough idea of the sky distribution of diaObjects.
query = """
SELECT
FLOOR(ra / 1.0) * 1.0 AS ra_bin,
FLOOR(dec / 1.0) * 1.0 AS dec_bin,
COUNT(*) AS count_per_bin
FROM ppdb.DiaObject
GROUP BY ra_bin, dec_bin
"""
job = tap_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'
radec_bins = job.fetch_result().to_table()
radec_bins
Job phase is COMPLETED
| ra_bin | dec_bin | count_per_bin |
|---|---|---|
| float64 | float64 | int64 |
| 258.0 | -20.0 | 11470 |
| 258.0 | -21.0 | 10862 |
| 259.0 | -20.0 | 9928 |
| 258.0 | -22.0 | 11259 |
| 259.0 | -22.0 | 2872 |
| 258.0 | -23.0 | 4254 |
| 259.0 | -23.0 | 1135 |
| 259.0 | -21.0 | 16073 |
| 256.0 | -21.0 | 2022 |
| ... | ... | ... |
| 0.0 | -6.0 | 7 |
| 0.0 | -10.0 | 13 |
| 52.0 | -31.0 | 5 |
| 0.0 | -7.0 | 55 |
| 1.0 | -10.0 | 10 |
| 37.0 | -7.0 | 6 |
| 53.0 | -31.0 | 4 |
| 150.0 | 1.0 | 66712 |
| 151.0 | 0.0 | 3719 |
| 150.0 | 0.0 | 28376 |
Plot the distribution of diaObjects on the sky.
fig = plt.figure(figsize=(9, 4))
norm = LogNorm()
plt.scatter(radec_bins['ra_bin'], radec_bins['dec_bin'], c=radec_bins['count_per_bin'],
norm=norm, s=5, cmap='Blues')
plt.colorbar(label='number of diaObjects')
plt.xlim(360, 0)
plt.minorticks_on()
plt.xlabel('RA (deg)')
plt.ylabel('Dec (deg)')
plt.show()
Figure 2: Sky distribution in RA and Dec of entries in the
ppdb.DiaObjecttable. Each point is color-coded by the number ofdiaObjects in that bin. The Deep Drilling Fields and the First Look field in Virgo have the mostdiaObjects, as they have been visited the most.
The number of diaObjects in each bin of the above figure is a function of the density of objects on the sky as well as the number of visits and the availability of templates for image differencing.