202.3. DIA Forced Source table#
202.3. Dia Forced Source 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 DiaForcedSource table and how to access it.
LSST data products: ppdb.DiaForcedSource
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) DiaForcedSource table is the result of Difference Image Analysis (DIA) processing.
The DiaForcedSource table contains forced PSF measurements in individual visit_images and difference_images at the sky coordinates of all DiaObjects.
DiaObjects are the union set of all diaSources detected in difference_images.
Note: Forced photometry on Prompt-processed images is only executed if a DIA object has at least 2 detections, and was not implemented prior to April 4 2026.
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 the DiaObject table.
1.1. Import packages¶
Import standard python packages numpy, matplotlib and astropy.
From the lsst package, import modules for the TAP service and plotting.
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,
get_multiband_plot_linestyles,
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()
filter_linestyles = get_multiband_plot_linestyles()
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:19:48.728 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 DiaForcedSource table and run the query job.
query = """SELECT column_name, datatype, description, unit
FROM tap_schema.columns
WHERE table_name = 'ppdb.DiaForcedSource'"""
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'
Job phase is COMPLETED
Retrieve the query results and display them as an astropy table with the to_table() attribute.
schema_results = job.fetch_result().to_table()
schema_results
| column_name | datatype | description | unit |
|---|---|---|---|
| str64 | str64 | str512 | str64 |
| detector | short | Id of the detector where this forcedSource was measured. Datatype short instead of byte because of DB concerns about unsigned bytes. | |
| diaForcedSourceId | long | Unique identifier of this DiaForcedSource. | |
| diaObjectId | long | Id of the DiaObject that set the position for this forced measurement. | |
| ra | double | Right ascension coordinate of the position of the DiaObject. | deg |
| dec | double | Declination coordinate of the position of the DiaObject. | deg |
| visit | long | Id of the visit where this forcedSource was measured. | |
| psfFlux | float | Forced PSF flux on the difference image at the DiaObject position. Positive if the source is brighter in the visit image than in the template. | nJy |
| psfFluxErr | float | Uncertainty of psfFlux. | nJy |
| midpointMjdTai | double | Effective mid-visit time for this diaForcedSource, expressed as Modified Julian Date, International Atomic Time. | d |
| scienceFlux | float | Forced PSF flux on the visit image at the DiaObject position. Unlike psfFlux, it includes the flux of any static source and background. | nJy |
| scienceFluxErr | float | Uncertainty of scienceFlux. | nJy |
| band | char | Filter band this source was observed with. | |
| timeProcessedMjdTai | double | Time when this record was generated, expressed as Modified Julian Date, International Atomic Time. | |
| timeWithdrawnMjdTai | double | Time when this record was marked invalid, expressed as Modified Julian Date, International Atomic Time. NULL unless the record has been withdrawn. |
Delete the job, but not the results.
del query
job.delete()
2.2. Key columns¶
The key columns in the DiaSource table are described below.
2.2.1. Identifier¶
The diaObjectId that identifies the row of the DiaObject table associated with the DiaForcedSource entry.
diaObjectId
2.2.2. Observation metadata¶
The band, MJD, visit, and detector of the image in which the DiaForcedSource was measured.
band,midpointMjdTai,visit,detector
2.2.3. Fluxes¶
A forced fit of the Point Spread Function (PSF) at the object's coordinates in each individual difference_image is stored in psfFlux.
The scienceFlux contains the forced flux in the visit_image (also called the "direct" or "science" image).
Flux measurements can be negative, take care if converting to magnitudes.
psfFlux,psfFluxErrscienceFlux,psfDiffFluxErr
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.
2.3. Descriptions and units¶
For a subset of the key columns show the table of their descriptions and units.
col_list = set(['diaObjectId', 'band', 'midpointMjdTai',
'visit', 'detector', 'psfFlux', 'psfFluxErr'])
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 |
| detector | short | Id of the detector where this forcedSource was measured. Datatype short instead of byte because of DB concerns about unsigned bytes. | |
| diaObjectId | long | Id of the DiaObject that set the position for this forced measurement. | |
| visit | long | Id of the visit where this forcedSource was measured. | |
| psfFlux | float | Forced PSF flux on the difference image at the DiaObject position. Positive if the source is brighter in the visit image than in the template. | nJy |
| psfFluxErr | float | Uncertainty of psfFlux. | nJy |
| midpointMjdTai | double | Effective mid-visit time for this diaForcedSource, expressed as Modified Julian Date, International Atomic Time. | d |
| band | char | Filter band this source was observed with. |
Clean up.
del col_list, tx, schema_results
3. Data access¶
The DiaForcedSource table is available via the TAP service.
Recommended access method: TAP.
3.1. Advisory: avoid full-table and spatial queries¶
Avoid full-table and spatial (cone search) queries. Query by diaObjectId.
The DiaForcedSource table is a large inclusive union set of forced measurements made at the locations of all diaObjects.
The main use-case for queries on the DiaForcedSource table is to return all forced photometry for a given DiaObject.
Method A (S.3.2.1): In two steps, first query the DiaObject table to get the diaObjectId, then retrieve all forced photometry from DiaForcedSource by diaObjectId.
Method B (S.3.2.2): Combine the two steps of Method A with a table join.
3.2. TAP (Table Access Protocol)¶
The DiaForcedSource table is stored in Qserv and accessible via the TAP services using ADQL queries.
3.2.1. Demo query¶
For coordinates of interest - the known transient SN2026aeud) - query the DiaObject table with a search radius of 1 arcsecond.
Assert that there was only one spatial match in the DiaObject table, and print the diaObjectId.
ra_targ = 63.469749
dec_targ = -46.685906
search_radius = 1.0/3600.0
query = """SELECT diaObjectId, ra, dec
FROM ppdb.DiaObject
WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', {}, {}, {})) = 1
""".format(ra_targ, dec_targ, search_radius)
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()
assert len(diao_results) == 1
print(diao_results['diaObjectId'][0])
Job phase is COMPLETED 171141218388934752
Retrieve the forced photometry for this diaObjectId.
query = """SELECT diaObjectId, band, midpointMjdTai, psfFlux, psfFluxErr
FROM ppdb.DiaForcedSource
WHERE diaObjectId = {}""".format(diao_results['diaObjectId'][0])
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'
diafs_results = job.fetch_result().to_table()
print('Number of forced photometry data points retrieved: ', len(diafs_results))
Job phase is COMPLETED Number of forced photometry data points retrieved: 24
Option to display the table.
# diafs_results
Clean up.
job.delete()
del query, diao_results, diafs_results
3.2.2. Joinable table: DiaObject¶
The DiaObject table contains statistical information from DiaSource properties associated with the DiaObject.
The demo query in Section 3.2.1 can be done in one step with a table join between the DiaObject and DiaForcedSource tables.
query = """SELECT diao.diaObjectId, diao.ra, diao.dec,
diafs.band, diafs.midpointMjdTai, diafs.psfFlux, diafs.psfFluxErr
FROM ppdb.DiaObject AS diao
JOIN ppdb.DiaForcedSource AS diafs ON diao.diaObjectid = diafs.diaObjectId
WHERE CONTAINS(POINT('ICRS', diao.ra, diao.dec), CIRCLE('ICRS', {}, {}, {})) = 1
""".format(ra_targ, dec_targ, search_radius)
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'
diafs_results = job.fetch_result().to_table()
print('Number of forced photometry data points retrieved: ', len(diafs_results))
Job phase is COMPLETED Number of forced photometry data points retrieved: 24
Option to view the results table.
# diafs_results
Show the difference-image forced PSF flux light curve.
fig = plt.figure(figsize=(8, 4))
for f, filt in enumerate(filter_names):
fx = np.where(diafs_results['band'] == filt)[0]
plt.errorbar(diafs_results['midpointMjdTai'][fx], diafs_results['psfFlux'][fx],
yerr=diafs_results['psfFluxErr'][fx],
fmt=filter_symbols[filt], ms=10, mew=0, ecolor=filter_colors[filt],
alpha=0.5, color=filter_colors[filt], label=filt)
del fx
plt.xlabel('Modified Julian Date', fontsize=12)
plt.ylabel('Forced Difference-Image Flux (nJy)', fontsize=12)
plt.legend(loc='upper right', ncol=2, fontsize=12)
plt.title(f"LSST-AP-DO-{diafs_results['diaObjectId'][0]}")
plt.show()
Figure 1: The difference-image forced PSF fluxes associated with
diaObjectId= 171141218388934752.
3.4. Butler¶
The PPDB DiaForcedSource table is not currently available via the Butler.
4. Advisories for DIA forced fluxes¶
4.1. Starts after 2 detections¶
There is currently no precovery (pre-detection) forced photometry in DiaForcedSource and the forced fluxes only begin after 2 detections for a given diaObject.
As a demonstration, retrieve the SNR>5 detections from the DiaSource table and co-plot them with the forced photometry.
query = """SELECT diaSourceId, psfFlux, psfFluxErr, band, midpointMjdTai
FROM ppdb.DiaSource
WHERE diaObjectId = {}""".format(171141218388934752)
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()
Job phase is COMPLETED
fig = plt.figure(figsize=(8, 4))
for f, filt in enumerate(filter_names):
fx = np.where(diafs_results['band'] == filt)[0]
plt.errorbar(diafs_results['midpointMjdTai'][fx], diafs_results['psfFlux'][fx],
yerr=diafs_results['psfFluxErr'][fx],
fmt=filter_symbols[filt], ms=9, mew=0, ecolor=filter_colors[filt],
alpha=0.5, color=filter_colors[filt], label=filt)
del fx
for f, filt in enumerate(filter_names):
fx = np.where(dias_results['band'] == filt)[0]
plt.plot(dias_results['midpointMjdTai'][fx], dias_results['psfFlux'][fx],
filter_symbols[filt], ms=11, mew=1, mec=filter_colors[filt],
alpha=1, color='none')
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-{diafs_results['diaObjectId'][0]}")
plt.show()
Figure 2: The same light curve as in Figure 1, but with SNR>5 detections from the
DiaSourcetable as open symbols, to compare with the forced photometry measurements as filled, semi-transparent symbols. The first night with forced photometry is after the first night with detections.
del dias_results, diafs_results
4.2. Starts after Apr 4 2026¶
There is no forced photometry before April 4 2026.
date_fphot = Time("2026-04-04", format="iso", scale="utc")
Retrieve the detected (DiaSource) and forced (DiaForcedSource) PSF fluxes on i-band difference images for diaObjectId = 313888627195641987, which was detected before forced photometry was implemented.
query = """SELECT psfFlux, psfFluxErr, band, midpointMjdTai
FROM ppdb.DiaForcedSource
WHERE diaObjectId = {} AND band = 'i'""".format(313888627195641987)
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'
diafs_i_results = job.fetch_result().to_table()
Job phase is COMPLETED
query = """SELECT diaSourceId, psfFlux, psfFluxErr, band, midpointMjdTai
FROM ppdb.DiaSource
WHERE diaObjectId = {} AND band = 'i'""".format(313888627195641987)
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_i_results = job.fetch_result().to_table()
Job phase is COMPLETED
For this diaObject, plot the detected (open) and forced (filled) fluxes together to show that forced photometry only exists after Apr 4 2026, and in thise case, the detections and forced fluxes do not overlap in time.
filt = 'i'
fig = plt.figure(figsize=(8, 4))
plt.axvline(now.mjd, color='blue', ls='dashed', label='now')
plt.axvline(date_fphot.mjd, color='orange', label='forced begins')
plt.errorbar(diafs_i_results['midpointMjdTai'], diafs_i_results['psfFlux'],
yerr=diafs_i_results['psfFluxErr'],
fmt=filter_symbols[filt], ms=9, mew=0, ecolor=filter_colors[filt],
alpha=0.5, color=filter_colors[filt], label=filt)
plt.plot(dias_i_results['midpointMjdTai'], dias_i_results['psfFlux'],
filter_symbols[filt], ms=11, mew=1, mec=filter_colors[filt],
alpha=1, color='none')
plt.xlabel('Modified Julian Date', fontsize=12)
plt.ylabel('Difference-Image i-band Flux (nJy)', fontsize=12)
plt.legend(loc='upper right', fontsize=12)
plt.title(f"LSST-AP-DO-{313888627195641987}")
plt.show()
Figure 3: For a diaObject detected early in 2026, the SNR>5 detections from the
DiaSourcetable as open symbols are compared with the forced photometry measurements as filled, semi-transparent symbols. The date that forced photometry began is marked with a vertical orange line, and the date the plot was created as a blue dashed line. For this particular object, SNR>5 detections ceased before forced photometry measurements began, and they do not overlap in time.