TheDocumentation 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.
ztfquery.query module is your gateway to the full ZTF archive held at IRSA. Every workflow follows the same two-step pattern: first call load_metadata() to discover what data exists and receive a summary table, then call download_data() to fetch the files you need. The four scenarios below cover the most common use-cases, from a targeted sky-position search to bulk parallel downloads.
You need a free IRSA account to access data. For private ZTF partnership data your IRSA account must also be linked to a ZTF program. Public data releases (e.g. DR3 and later) are available to all registered users. Make sure the environment variable
$ZTFDATA is set; it controls where downloaded files are stored.Scenario 1: Query by sky position with filter and time range
Query all i-band (fid=3) science images within 0.01 deg of a target position observed since 14 May 2018.
Run the positional metadata query
Inspect the metatable
metatable is a pandas DataFrame that holds one row per matching image. Key columns include obsjd (observation Julian Date), ccdid (CCD identifier, 1–16), filtercode (e.g. zi, zr, zg), field, qid (quadrant ID), and seeing (FWHM in arcsec). The full schema is documented at the ZTF IRSA API.Scenario 2: Generic SQL query (no coordinates)
Query any observation with a seeing smaller than 2 arcsec between 1 May 2018 and 1 June 2018 without specifying a sky position.Execute the SQL-style query
When no
radec position is provided the sql_query argument is required by the IRSA API. You can use any SQL WHERE clause syntax supported by IRSA: AND, OR, BETWEEN, IN, LIKE, and standard arithmetic comparisons. Function calls and sub-queries are not supported.Scenario 3: Reference image query
Reference images are deep coadds used as the template for difference imaging. They have their own metadata kind (kind="ref").
Filter to a single band
Pass a
sql_query argument to restrict results to one filter. Both of the following are equivalent for g-band:When matching string values in
sql_query you must wrap the value in single quotes inside the double-quoted Python string, e.g. sql_query="filtercode='zg'". Filter IDs are: fid=1 → g-band (zg), fid=2 → r-band (zr), fid=3 → i-band (zi).Scenario 4: Downloading data
Onceload_metadata() has been called you can download any of the associated data products.
Partial download using metatable indexes
indexes argument accepts any list of integer row labels from zquery.metatable.Available science image products
Each science exposure queried throughload_metadata(kind="sci") (the default) has up to eleven associated data products. Pass the filename suffix to download_data() to choose which one to fetch.
Science exposure file products
Science exposure file products
| Suffix | Description |
|---|---|
sciimg.fits | Primary science image (default) |
mskimg.fits | Bit-mask image |
psfcat.fits | PSF-fit photometry catalog |
sexcat.fits | Nested-aperture photometry catalog |
sciimgdao.psf | Spatially varying PSF estimate in DAOPhot look-up table format |
sciimgdaopsfcent.fits | PSF estimate at science image centre as a FITS image |
sciimlog.txt | Log output from the instrumental calibration pipeline |
scimrefdiffimg.fits.fz | Difference image (science minus reference), fpack-compressed |
diffimgpsf.fits | PSF estimate for the difference image |
diffimlog.txt | Log output from the image subtraction and extraction pipeline |
log.txt | Overall system summary log from the realtime pipeline |
Reference image file products
Reference image file products
| Suffix | Description |
|---|---|
refimg.fits | Reference image (default) |
refcov.fits | Coverage map |
refunc.fits | Uncertainty image |
refpsfcat.fits | PSF-fit photometry catalog for the reference |
refsexcat.fits | Aperture photometry catalog for the reference |
refimlog.txt | Calibration pipeline log |
log.txt | Overall system log |