202.2. DIA Source table#
202.2. DiaSource table¶
For the Rubin Science Platform at data.lsst.cloud.
Data Release: Prompt Products
Container Size: Large
LSST Science Pipelines version: r30.0.11
Last verified to run: 2026-11-29
Repository: github.com/lsst/tutorial-notebooks
DOI: 10.11578/rubin/dc.20250909.20
Learning objective: To understand the contents of the Prompt Products DiaSource table and how to access it.
LSST data products: ppdb.DiaSource
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¶
The Prompt Products Database (PPDB) DiaSource table is the result of Difference Image Analysis (DIA) processing.
The DiaSource table contains measurements for positive- and negative-flux sources detected in the difference images with signal-to-noise ratio $\geq5$.
These "diaSources" are associated into "diaObjects" in the DiaObject table using a 1-arcsecond radius, or are associated with moving objects (Solar System objects).
Related tutorials: The TAP and butler data access services are demonstrated in the 100-level "How to" tutorials. There are 200-level tutorials on difference_images and DiaObjects.
1.1. Import packages¶
Import standard python packages numpy, matplotlib and astropy.
From the lsst package, import modules for the TAP service, the butler, and plotting.
import re
import numpy as np
import matplotlib.pyplot as plt
from astropy.time import Time
from lsst.rsp import RSPDiscovery
from lsst.utils.plotting import (get_multiband_plot_colors,
get_multiband_plot_symbols,
set_rubin_plotstyle)
1.2. Define parameters and functions¶
Create an instance of the TAP service.
discovery = RSPDiscovery("prompt")
tap_service = discovery.get_tap_client()
Define the colors and symbols to represent the LSST filters in plots.
set_rubin_plotstyle()
filter_colors = get_multiband_plot_colors()
filter_names = filter_colors.keys()
filter_symbols = get_multiband_plot_symbols()
Print the date that this notebook was executed.
now = Time.now()
print("Calendar (UTC):", now.iso)
print("MJD:", np.round(now.mjd, 1))
Calendar (UTC): 2026-12-01 00:20:00.832 MJD: 61375.0
2. Schema (columns)¶
To browse the table schema visit the Rubin schema browser, use the TAP service via the Portal Aspect, or do 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 DiaSource table, run the query job, and retrieve the results.
query = """SELECT column_name, datatype, description, unit
FROM tap_schema.columns
WHERE table_name = '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()
assert job.phase == 'COMPLETED'
schema_results = job.fetch_result().to_table()
Job phase is COMPLETED
Display the schema.
schema_results
| column_name | datatype | description | unit |
|---|---|---|---|
| str64 | str64 | str512 | str64 |
| diaSourceId | long | Unique identifier of this DiaSource. | |
| visit | long | Id of the visit where this diaSource was measured. | |
| detector | short | Id of the detector where this diaSource was measured. Datatype short instead of byte because of DB concerns about unsigned bytes. | |
| diaObjectId | long | Id of the diaObject this source was associated with. NULL if the source is associated with an ssObject instead; each diaSource is associated with either a diaObject or an ssObject. | |
| parentDiaSourceId | long | Id of the parent diaSource this diaSource has been deblended from, if any. | |
| ssObjectReassocTimeMjdTai | double | Time when this diaSource was reassociated from diaObject to ssObject, expressed as Modified Julian Date, International Atomic Time (if such reassociation happens, otherwise NULL). | |
| midpointMjdTai | double | Effective mid-visit time for this diaSource, expressed as Modified Julian Date, International Atomic Time. | d |
| exposureTime | float | Effective exposure time for this diaSource. | s |
| ra | double | Right ascension of the diaSource centroid. For sources with both positive and negative peaks this is the midpoint of the two lobes of the dipole fit. | deg |
| ... | ... | ... | ... |
| pixelFlags_injectedCenter | boolean | The 3x3 region around the centroid includes visit image pixels modified by fake source injection. | |
| pixelFlags_injected_template | boolean | The diaSource footprint includes pixels modified by fake source injection into the template. | |
| pixelFlags_injected_templateCenter | boolean | The 3x3 region around the centroid includes pixels modified by fake source injection into the template. | |
| glint_trail | boolean | Set if the source is likely part of a glint trail, usually from a satellite or debris. | |
| templateMjdMean | double | Weighted mean of the mid-exposure times of the template input images that cover the diaSource centroid, expressed as Modified Julian Date, International Atomic Time. Each input is weighted by its share of the template there, estimated from the coadd weights. | d |
| templateMjdMin | double | Earliest mid-exposure time of the template input images that cover the diaSource centroid, expressed as Modified Julian Date, International Atomic Time. | d |
| templateMjdMax | double | Latest mid-exposure time of the template input images that cover the diaSource centroid, expressed as Modified Julian Date, International Atomic Time. | d |
| templateInstrument | char | Name of the instrument whose observations were coadded to make the template, or UNKNOWN if it is not known. | |
| templateVersion | int | Version of the template. It is 1 if the template is from a different instrument than the diaSource, and 0 otherwise. | |
| mixedInstruments | boolean | Set if the template instrument is known and differs from the instrument that observed the diaSource. |
The table displayed above has been truncated.
Option to print every column name as a list.
# for col in schema_results['column_name']:
# print(col)
Option to use the regular expressions package re to search for column names that contain the string temp.
# temp = 'Err'
# temp = 'Flux'
# temp = 'psf'
# for col in schema_results['column_name']:
# if re.search(temp, col):
# print(col)
Delete the job, but not the schema_results.
del query
job.delete()
2.2. Key columns¶
The key columns in the DiaSource table are described below.
2.2.1. Identifiers¶
The diaSourceId is a long integer that uniquely identifies each row of the DiaSource table.
The diaObjectId is a long integer that identifies an associated DiaObject; if it is not populated, the diaSource is instead associated with a Solar System object.
diaSourceIddiaObjectId
2.2.2. Visit information¶
The visit is a long integer that uniquely identifies the visit the DiaSources were detected. The detector is which of the 9 LSSTComCam detectors the DiaSources were detected on. Together, the visit and detector correspond to a processed visit_image.
The band is the filter that was used for the observation of the DiaSource.
The midpointMjdTai is the effective mid-exposure time for visit where the DiaSource was detected, expressed as Modified Julian Date, International Atomic Time.
visitdetectorbandmidpointMjdTai
2.2.3. Coordinates¶
The sky coordinates in decimal degrees for each DiaSource, and their errors.
ra,raErrdec,decErr
2.2.4. Flux measurements and flags¶
Fluxes are provided in nanoJanskys, which is preferred for difference-image photometry over magnitudes since negative flux measurements would be omitted when converting to magnitudes.
PSF flux on the difference image
A forced fit of the Point Spread Function (PSF) at the diaSource's coordinates in each difference image.
PSF fluxes are best to use for point-like sources.
Note that in the DiaSource table, the psfFlux column contains fluxes measured on the difference image.
In other tables psfFlux is a flux on the direct (science) image.
psfFlux,psfFluxErr
Other flux measurements
apFlux: Flux in a 12 pixel radius aperture on thedifference_image.scienceFlux: Forced PSF flux measured on the directvisit_image.templateFlux: Forced PSF flux measured on the template coadd image.trailFlux: Total flux from a trailed source model, measured on thedifference_image.
Flags
There are a variety of flags named pixelFlags_* that indicate whether, e.g., pixels that are saturated, or affected by cosmic rays, contributed to the diaSource's measurements.
There are also flags from the algorithms that measure quantities such as flux and shape, and have associated flag columns suffixed with _flag.
The boolean flag isDipole indicates whether or not the diaSource is classified as a dipole, with positive and negative lobes.
Dipoles can have a real astrophysical cause (e.g., stellar proper motion between template and visit image) or be DIA artifacts.
2.2.5. Reliability score¶
The purpose of the reliability score in the DiaSource table is to provide a threshold measure to improve the purity of DIA detections.
Reliability scoring, including characterization of the progress in training subsquent versions of the score, is documented in DMTN-337.
reliability,reliabilityVersion
2.3. Descriptions and units¶
For a subset of the key columns show the table of their descriptions and units.
col_list = set(['diaSourceId', 'diaObjectId', 'band', 'visit',
'midpointMjdTai', 'ra', 'dec', 'psfFlux', 'psfFluxErr', 'isDipole'])
tx = [i for i, item in enumerate(schema_results['column_name']) if item in col_list]
schema_results[tx]
| column_name | datatype | description | unit |
|---|---|---|---|
| str64 | str64 | str512 | str64 |
| diaSourceId | long | Unique identifier of this DiaSource. | |
| visit | long | Id of the visit where this diaSource was measured. | |
| diaObjectId | long | Id of the diaObject this source was associated with. NULL if the source is associated with an ssObject instead; each diaSource is associated with either a diaObject or an ssObject. | |
| midpointMjdTai | double | Effective mid-visit time for this diaSource, expressed as Modified Julian Date, International Atomic Time. | d |
| ra | double | Right ascension of the diaSource centroid. For sources with both positive and negative peaks this is the midpoint of the two lobes of the dipole fit. | deg |
| dec | double | Declination of the diaSource centroid. For sources with both positive and negative peaks this is the midpoint of the two lobes of the dipole fit. | deg |
| psfFlux | float | Flux of a point-source (PSF) model fit to the difference image at the diaSource centroid. | nJy |
| psfFluxErr | float | Uncertainty of psfFlux. | nJy |
| band | char | Filter band this source was observed with. | |
| isDipole | boolean | Source well fit by a dipole. |
Clean up.
del col_list, tx, schema_results
3. Data access¶
The Prompt Products DiaSource table is available via the TAP service.
Recommended access method: TAP.
3.1. Advisory: avoid full-table queries¶
Avoid full-table queries. It is ideal to constrain queries by diaObjectId or by visit/detector.
Most queries on the DiaSource table should be for all difference-image detections associated with a given diaObject, or with a given visit and detector combination (as in S.3.2.1).
For the question of "did Rubin ever detect a time-domain object at this RA, Dec?", query the DiaObject table, then get all diaSources associated with that diaObject with a separate query (or use a table join, as in S.3.2.2.).
3.2. TAP (Table Access Protocol)¶
The DiaSource table is accessible via the TAP services using ADQL queries.
Including spatial constraints:
Use either an ADQL cone or polygon search for faster queries (do not use WHERE ... BETWEEN statements to set boundaries on RA and Dec).
3.2.1. Demo query¶
Define a query to return the key columns from Section 2.3.
Impose visit and detector constraints: create a query to return all diaSources detected in the difference image corresponding to detector number 86, visit number 2026021900174. This is not a special image, just a random example from the Euclid Deep Field South region.
visit = 2026021900174
detector = 94
query = """SELECT diaSourceId, diaObjectId, band, visit, detector,
midpointMjdTai, ra, dec, psfFlux, psfFluxErr, isDipole
FROM ppdb.DiaSource
WHERE visit = {} AND detector = {}""".format(visit, detector)
print(query)
SELECT diaSourceId, diaObjectId, band, visit, detector,
midpointMjdTai, ra, dec, psfFlux, psfFluxErr, isDipole
FROM ppdb.DiaSource
WHERE visit = 2026021900174 AND detector = 94
Execute the query and retrieve the results.
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'
dias_results = job.fetch_result().to_table()
print(len(dias_results))
Job phase is COMPLETED 91
Option to display the table.
# dias_results
Plot the coordinates for each diaSource detection, and the histogram of psfFlux values.
fig, ax = plt.subplots(1, 2, figsize=(10, 5))
tx1 = np.where((dias_results['psfFlux'] > 0.0) & (~dias_results['isDipole']))[0]
tx2 = np.where((dias_results['psfFlux'] < 0.0) & (~dias_results['isDipole']))[0]
tx3 = np.where((dias_results['psfFlux'] > 0.0) & (dias_results['isDipole']))[0]
tx4 = np.where((dias_results['psfFlux'] < 0.0) & (dias_results['isDipole']))[0]
ax[0].plot(dias_results['ra'][tx1], dias_results['dec'][tx1], 'o', fillstyle='full',
color='white', ms=7, mew=1, mec='black', alpha=0.5, label='positive')
ax[0].plot(dias_results['ra'][tx2], dias_results['dec'][tx2], 's', fillstyle='full',
color='black', ms=7, mew=1, mec='black', alpha=0.5, label='negative')
ax[0].plot(dias_results['ra'][tx3], dias_results['dec'][tx3], 'o', fillstyle='right',
color='black', ms=7, mew=1, mec='black', alpha=0.5, label='positive; dipole')
ax[0].plot(dias_results['ra'][tx4], dias_results['dec'][tx4], 's', fillstyle='left',
color='black', ms=7, mew=1, mec='black', alpha=0.5, label='negative; dipole')
ax[0].set_xlabel('RA [arcsec]')
ax[0].set_ylabel('Dec [arcsec]')
ax[0].legend(loc='upper left')
bar_data = [dias_results['psfFlux'][tx1], dias_results['psfFlux'][tx2],
dias_results['psfFlux'][tx3], dias_results['psfFlux'][tx4]]
bar_colors = ['white', 'black', 'lightgrey', 'grey']
bar_labels = ['positive', 'negative', 'positive; dipole', 'negative; dipole']
ax[1].hist(bar_data, bins=20, stacked=True, color=bar_colors,
edgecolor='black', label=bar_labels)
ax[1].set_xlabel('psfFlux [nJy]')
ax[1].set_ylabel('Number')
ax[1].legend(loc='upper left')
plt.tight_layout()
plt.show()
del tx1, tx2, tx3, tx4
Figure 1: At left, the RA and Dec for all detected diaSources in the chosen visit+detector, with symbol type and color fill representing positive or negative flux, and whether the source exhibited a dipole morphology. At right, a stacked bar chart of the difference-image PSF flux measurements for detected diaSources.
Clean up.
job.delete()
del query, dias_results
3.2.2. Joinable table: DiaObject¶
The DiaObject table contains statistical information from DiaSource properties associated with the DiaObject.
As an example, query for all the diaSources (difference-image detections) associated with all diaObjects within 1 arcseconds of the target coordinates (the location of SN2026aeud). Return the diaSourceId, psfFlux, and band from the DiaSource table, and the diaObjectId and the number of detections nDiaSources from the DiaObject table.
ra_targ = 63.469749
dec_targ = -46.685906
search_radius = np.round(1./3600.0, 5)
query = """SELECT dias.diaSourceId, dias.psfFlux, dias.psfFluxErr,
dias.band, dias.midpointMjdTai, diao.diaObjectId, diao.nDiaSources
FROM ppdb.DiaSource AS dias
JOIN ppdb.DiaObject AS diao ON dias.diaObjectId = diao.diaObjectId
WHERE CONTAINS(POINT('ICRS', diao.ra, diao.dec),
CIRCLE('ICRS', {}, {}, {})) = 1""".format(ra_targ, dec_targ, search_radius)
print(query)
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'
diao_results = job.fetch_result().to_table()
SELECT dias.diaSourceId, dias.psfFlux, dias.psfFluxErr,
dias.band, dias.midpointMjdTai, diao.diaObjectId, diao.nDiaSources
FROM ppdb.DiaSource AS dias
JOIN ppdb.DiaObject AS diao ON dias.diaObjectId = diao.diaObjectId
WHERE CONTAINS(POINT('ICRS', diao.ra, diao.dec),
CIRCLE('ICRS', 63.469749, -46.685906, 0.00028)) = 1
Job phase is COMPLETED
Option to display the results.
# diao_results
Show that just one unique diaObject was returned by the query by printing the unique values of the diaObjectId column and the number of rows with that value.
values, counts = np.unique(diao_results['diaObjectId'], return_counts=True)
for value, count in zip(values, counts):
print(value, count)
del values, counts
171141218388934752 30
Print the number of detections per band.
string_out = 'Number of detections per filter: '
for f, filt in enumerate(filter_names):
fx = np.where(diao_results['band'] == filt)[0]
string_out += filt + ': ' + str(len(fx)) + ' '
del fx
print(string_out)
del string_out
Number of detections per filter: u: 0 g: 10 r: 9 i: 7 z: 4 y: 0
Plot the light curve.
fig = plt.figure(figsize=(8, 4))
for f, filt in enumerate(filter_names):
fx = np.where(diao_results['band'] == filt)[0]
plt.errorbar(diao_results['midpointMjdTai'][fx], diao_results['psfFlux'][fx],
yerr=diao_results['psfFluxErr'][fx],
fmt=filter_symbols[filt], ms=10, mew=1, mec=filter_colors[filt],
ecolor=filter_colors[filt], alpha=0.8, color='none', label=filt)
del fx
plt.xlabel('Modified Julian Date', fontsize=12)
plt.ylabel('Difference-Image Flux (nJy)', fontsize=12)
plt.legend(loc='upper right', ncol=2, fontsize=12)
plt.title(f"LSST-AP-DO-{diao_results['diaObjectId'][0]}")
plt.show()
Figure 2: The SNR>5 detected difference-image fluxes associated with
diaObjectId= 171141218388934752.
del query, diao_results, ra_targ, dec_targ, search_radius
3.3. Butler¶
The PPDB DiaSource table is not currently available via the Butler.
4. Solar System table connections¶
For diaSources that are associated with moving objects (have NULL diaObjectIds) that were submitted to and accepted by the Minor Planet Center (MPC), the entire DiaSource table record is reproduced and stored in the SSObservation table, alongside other columns required for solar system science.
Solar system science requiring observations that have been reliably associated to a real moving object by the MPC will primarily use SSObservation rather than DiaSource.
If a diaSource was associated with a moving object but it has not (yet) been submitted to or accepted by the MPC, then the record of that association is stored in the NearbySSO table.
The diasources in NearbySSO are, e.g., about to be submitted; associated with a track that does not have enough detections to submit yet; submitted but not (yet) associated with a moving object or established as a new discovery.
For example, the optional code cells below demonstrate how the row of the DiaSoure table with diaSourceId = 171141216525090930 has a NULL diaObjectId.
In NearbySSO, that diaSourceId has been cross-matched to designation "2020 MR56".
However, a search for this diaSourceId in SSObservations yields no result, indicating that this observation has not yet been submitted to the MPC.
Note: while the
SSObservationstable does have a column nameddiaSourceId, this column is not entirely populated by only PPDB diaSource identifiers. The identifier values can come from other data releases (e.g., Data Preview 2). The corresponding release is found in theprocessingTablecolumn ofSSObservations, and "processing tables" with the following names correspond toppdb.DiaSource:ssp.dia_source_prompt_20250905,ssp.dia_source_ppdb_rel2,ssp.dia_source_prompt_20260708, andssp.dia_source_ppdb_sup. There are multiple due to the evolving nature of the Prompt Solar System Processing (SSP) pipelines.
Everyone doing solar system research should refer to the 200-level tutorials for the SS tables to understand how to use them.
Optional exercise: retrieve a subset of diaSources in the ECDFS deep drilling field where the diaObjectId is not populated, and sort the retreived results by diaSourceId.
# query = """SELECT diaSourceId, diaObjectId
# FROM ppdb.DiaSource
# WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', 53.01, -28.35, 1))=1
# AND diaObjectId IS NULL ORDER BY diaSourceId"""
# 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'
# dias_results = job.fetch_result().to_table()
# use_diasid = dias_results['diaSourceId'][0]
# print('use_diasid = ', use_diasid)
Option to search for the first diaSourceId in NearbySSO, and see that there is a match.
# query = """SELECT diaSourceId, ssObjectId, designation
# FROM ppdb.NearbySSO
# WHERE diaSourceId = {}""".format(use_diasid)
# 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'
# nsso_results = job.fetch_result().to_table()
# nsso_results
Option to search for the first diaSourceId in SSObservation, and see that there is not a match.
# query = """SELECT ssObjectId, designation, diaSourceId
# FROM ppdb.SSObservation
# WHERE diaSourceId = {}""".format(use_diasid)
# 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'
# ssobs_results = job.fetch_result().to_table()
# ssobs_results