ZTF distributes real-time transient detections as alert packets encoded in the Apache Avro binary format. EachDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/MickaelRigault/ztfquery/llms.txt
Use this file to discover all available pages before exploring further.
.avro file bundles the candidate photometric measurement, its multi-epoch history, and three image stamps (science, reference, and difference) into a single self-describing record. The ztfquery.alert module provides a lightweight reader and visualiser for these packets without requiring any external account or data service.
No account or authentication is required for this module. It operates entirely on
.avro files that you already have on disk.AlertReader
AlertReader loads a single Avro alert file into memory and exposes its contents as a Python dictionary.
Loading an alert
Absolute or relative path to the
.avro alert packet file on disk.AlertReader.load opens the file with fastavro, deserialises the first record, and returns an AlertReader instance.
Accessing alert data
The parsed alert is available as the.alert attribute — a plain Python dictionary whose structure mirrors the ZTF alert schema:
Key fields inside alert['candidate']
Key fields inside alert['candidate']
| Field | Description |
|---|---|
ra, dec | Sky coordinates of the transient candidate (degrees) |
magpsf, sigmapsf | PSF-fit magnitude and uncertainty |
fid | Filter ID: 1 = ztf:g, 2 = ztf:r, 3 = ztf:i |
jd | Julian date of the observation |
rb | Real/bogus score (0 = bogus, 1 = real) |
fwhm | Full-width at half maximum of the PSF (pixels) |
isdiffpos | Sign of the difference image flux |
candid | Unique candidate identifier |
display_alert
display_alert generates a single-figure summary of an alert, combining the three image stamps with the full photometric history light curve.
Either a path to an
.avro file (string) or a pre-loaded alert dictionary.If provided, the figure is saved to this path at 250 dpi.
If
True, download and display a Pan-STARRS colour cutout (y/g/i) centred on the candidate position alongside the ZTF stamps.- Science stamp — the new observation
- Reference stamp — the template image at the same position
- Difference stamp — science minus reference (the transient signal)
- Pan-STARRS stamp (optional) — a deeper colour context image
- Light curve panel — PSF magnitudes and upper limits across all historical ZTF detections, colour-coded by filter
Figure panel details
Figure panel details
The light curve shows all entries from
prv_candidates that have a candid value (detections) as filled points with error bars, colour-coded by filter (green = ztf:g, red = ztf:r, orange = ztf:i). Non-detections appear as downward-pointing arrows at the limiting magnitude. The current alert candidate is marked with a diamond.query_alert
The unique alert candidate identifier.