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.fritz module is a Python interface to fritz.science, the ZTF-II data broker built on the SkyPortal platform. It lets you download and work with photometry, spectra, alerts, and source/group information for any target you have access to on Fritz — all directly from Python, with optional local caching under $ZTFDATA/fritz/.
This documentation covers ztfquery ≥ 1.12.0. The API described here reflects the module as of that version. For the very latest features introduced in v1.14+, refer to the tutorial notebooks which supersede parts of this page.
Requirements
Create a Fritz account
Register at fritz.science and navigate to your profile page to generate an API token.
Module Structure
ztfquery.fritz is organised around two patterns:
| Pattern | Purpose |
|---|---|
download_{type}(name, ...) | Fetch data from Fritz (optionally stores locally) |
Class methods (FritzPhotometry.from_name, etc.) | Load a previously downloaded local copy or download fresh |
lightcurve, spectra, alerts, source, sample, groups) has a corresponding Python class (FritzPhotometry, FritzSpectrum, FritzAlerts, FritzSource, FritzSample, FritzGroups) returned when you pass get_object=True.
Download Functions
download_lightcurve
ZTF source name (e.g.
"ZTF20acmzoxo").If
True, returns a FritzPhotometry instance. Otherwise returns a raw pandas.DataFrame.Fritz API token. Uses the stored token if not provided.
If
True, saves the light curve to $ZTFDATA/fritz/lightcurve/. Set to False to skip storing.SkyPortal API option —
"flux" or "mag". Default uses the API default.SkyPortal API option —
"ab" or "vega". Default uses the API default.download_spectra
ZTF source name.
If
True, returns a FritzSpectrum (or list of FritzSpectrum if multiple spectra exist).Fritz API token.
If
True, saves spectra under $ZTFDATA/fritz/spectra/{name}/.If
True, prints the queried URL.download_alerts
ZTF source name.
Specific alert candidate ID to retrieve. Returns all alerts when
None.Set
True to retrieve all alert fields (not just candidate info).If
True, returns a FritzAlerts instance.Fritz API token.
If
True, saves alerts to $ZTFDATA/fritz/alerts/.download_source
ZTF source name.
If
True, returns a FritzSource instance.Fritz API token.
If
True, saves the source JSON to $ZTFDATA/fritz/source/.download_sample
Downloads all sources belonging to a Fritz group.
Numeric group ID or
"*" / "all" for no group filter.Returns a
FritzSample when True.Fritz API token.
If
True, saves the sample CSV to $ZTFDATA/fritz/sample/.download_groups
Returns a
FritzGroups instance when True.Fritz API token.
If
True (default), saves the groups JSON to $ZTFDATA/fritz/groups/.Fritz Object Classes
- FritzPhotometry
- FritzSpectrum
- FritzAccess
FritzPhotometry wraps the photometry DataFrame returned by Fritz and adds filtering, coordinate extraction, and plotting methods.Accessing the data
Getting coordinates
Retrieve the full set of per-epoch coordinates as a DataFrame:Filtering data
get_data() accepts band, detection flag, and time-range filters:Plotting
Storing locally
store() call (no argument) saves to $ZTFDATA/fritz/lightcurve/fritz_lightcurve_{name}.csv.Smart loading with from_name
FritzPhotometry.from_name() first checks for a local copy; if found it loads from disk, otherwise it downloads from Fritz:Other Fritz Classes
The following classes are used internally and returned by download functions withget_object=True. Each exposes a .store() method and format-specific I/O classmethods.
| Class | Created by | Key attributes |
|---|---|---|
FritzAlerts | download_alerts(..., get_object=True) | .data (DataFrame indexed by candid) |
FritzSource | download_source(..., get_object=True) | .fritzdict, .ra, .dec, .redshift, .classification, get_metaquery(), view_on_fritz() |
FritzSample | download_sample(..., get_object=True) | .data, .names, .sources, get_source(name), get_target_metaquery(name) |
FritzGroups | download_groups(..., get_object=True) | .accessible (DataFrame of user-accessible groups) |
Low-Level API Function
Theapi() function underlies all download functions and can be used directly for any Fritz/SkyPortal endpoint:
| Parameter | Description |
|---|---|
method | HTTP method string: "get", "post", "put", "delete" |
endpoint | Full URL of the SkyPortal API endpoint |
data | Request body (dict), passed as JSON |
load | If True (default), parse and return the JSON response data |
token | Fritz API token; uses stored token if None |
Bulk Downloads
For downloading data for many targets in parallel, usefritz.bulk_download():
fobject values: "lightcurve", "photometry", "spectra", "spectrum", "alerts", "source".
Local Storage Layout
All Fritz data stored viastore=True or .store() land under $ZTFDATA/fritz/: