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.lightcurve module provides access to ZTF light curves served by the IRSA LightCurve API. These light curves are built by matching the ZTF epochal catalogs — completely independently of the alert broker pipeline — making them the preferred source for variability studies, AGN monitoring, and periodic star searches.
These are not alert-packet light curves. ZTF alert light curves are generated by the real-time difference-imaging pipeline and distributed through alert brokers. The light curves in this module come from matching ZTF’s epochal photometry catalogs against reference-image source detections. They are independent of alerts and are particularly useful for the variable star and AGN community.
Requirements
You need an active account on IRSA to access the light curve service. Store your credentials using the ztfquery setup so they are loaded automatically:LCQuery class
LCQuery is the central class for all light curve queries. It wraps HTTP requests to the IRSA light curve API and stores the results as a pandas DataFrame in its .data property. Three class methods cover the most common query patterns; a static download method handles arbitrary API parameters.
Query by sky position — LCQuery.from_position()
Search for all ZTF sources within a circular aperture on the sky. Returns an LCQuery object whose .data DataFrame contains all matching epochal photometry.
ICRS right ascension of the search center in decimal degrees. Valid range:
[0, 180].ICRS declination of the search center in decimal degrees. Valid range:
[-90, 90].Search radius in arcseconds. For performance reasons the valid range is
(0, 600].Restrict results to one or more filter bands. Accepted values:
"g", "r", "i", or comma-separated combinations such as "g,i". Equivalent to filter IDs 1, 2, and 3 respectively.Restrict to sources whose median magnitude falls in
[mag_min, mag_max]. Implemented as a filter on the medianmag column of the ZTF objects table. Example: mag=[17.0, 17.7].Query by source ID — LCQuery.from_id()
Retrieve light curves for one or more known ZTF source identifiers. Source IDs are the integer object identifiers used in the ZTF catalog.
One or more ZTF source identifiers. Accepts a single integer, a comma-separated string, or a Python list of integers.
Generic query — LCQuery.download_data()
A static method that accepts the full set of IRSA LightCurve API parameters as keyword arguments. Use this when you need fine-grained control over the query that is not covered by from_position() or from_id().
LCQuery instance). Pass it to the LCQuery constructor if you want to use .show() or other instance methods.
Spatial constraint as
[ra, dec, radius], all in degrees. RA valid range: [0, 180]; Dec: [-90, 90]; radius: (0, 0.1667].Filter band name:
"g", "r", or "i", or comma-separated combinations.Minimum number of observation epochs required for a source to be included. Filters on the
nobs column.Modified Julian Date (MJD) range for the light curve data. Provide a single value for an exact epoch or a two-element list
[mjd_start, mjd_end] for a range.Bitmask used to exclude photometry points with flagged data quality issues. Points with any of the indicated
catflag bits set are removed. Example: bad_catflags_mask=15 excludes points with any of bits 0–3 set.The ZTF light curve collection to query. Default corresponds to the most recent public release. Use
"ztf_dr1" for the first data release or "ztf" for the proprietary collection (login required).Construct from an existing DataFrame
If you have already downloaded and saved a light curve as a CSV or Parquet file, you can wrap it in anLCQuery object to regain access to .show() and other methods.
A DataFrame with the same column structure as the IRSA light curve API response (e.g.
mjd, mag, magerr, filtercode). Typically loaded from a file that was saved via lcq.data.to_csv() or lcq.data.to_parquet()..data property
After any successful query, results are stored in the .data property as a pandas DataFrame. Key columns include:
| Column | Description |
|---|---|
mjd | Modified Julian Date of the observation |
mag | Magnitude measurement |
magerr | Magnitude uncertainty |
filtercode | Filter identifier (zg, zr, or zi) |
catflags | Data quality bitmask |
.show() method
Plot the light curve using matplotlib. Each filter band is displayed in a distinct colour (zg → green, zr → red, zi → orange), with error bars. The y-axis is inverted (brighter magnitudes at the top).