ZTF API Queries

Overview

IRSA provides access to the ZTF image archive through an application program interface (API). Search and retrieval parameters are specified using HTTP URLs. The output is a table of image metadata satisfying the search constraints. This service is intended to be accessed by scripts or other software. For example, to construct the full URL/path/filename to a product for later retrieval, you will need to write a script that combines the metadata as described here. The URLs can also be used in a web browser by entering the desired URL into the browser address bar.

Access Control

At the current time, all ZTF data are proprietary. Access requires a password. Instructions for using the API with a password are provided here.

Examples:

  1. Use curl to access proprietary data: curl --user myemail@astronomy.edu:mypassword -o out.tbl "https://irsa.ipac.caltech.edu/ibe/search/ztf/products/sci?POS=358.3,25.6"

  2. Use wget to access proprietary data: wget --auth-no-challenge --user=myemail@astronomy.edu --pass=mypassword -o out.tbl "https://irsa.ipac.caltech.edu/ibe/search/ztf/products/sci?POS=358.3,25.6"

  3. Use curl with cookies and $USER and $PASS variables to access proprietary data: curl -c cookies.txt "https://irsa.ipac.caltech.edu/account/signon/login.do?josso_cmd=login&josso_username=$USER&josso_password=$PASS"

    curl -b cookies.txt -o out.tbl "https://irsa.ipac.caltech.edu/ibe/search/ztf/products/sci?POS=358.3,25.6"

    curl -c cookies.txt "https://irsa.ipac.caltech.edu/account/signon/logout.do"

  4. Use wget with cookies and $USER and $PASS variables to access proprietary data: wget --save-cookies=cookies.txt -O /dev/null "https://irsa.ipac.caltech.edu/account/signon/login.do?josso_cmd=login&josso_username=$USER&josso_password=$PASS"

    wget --load-cookies=cookies.txt -O out.tbl "https://irsa.ipac.caltech.edu/ibe/search/ztf/products/sci?POS=358.3,25.6"

    wget --save-cookies=cookies.txt -O /dev/null "https://irsa.ipac.caltech.edu/account/signon/logout.do"

Base URL

A query is specified by encoding search parameters into a URL. ZTF query URLs start with one of three prefixes, depending on the category of data desired:

ZTF image type query URL prefix
raw https://irsa.ipac.caltech.edu/ibe/search/ztf/products/raw?
science https://irsa.ipac.caltech.edu/ibe/search/ztf/products/sci?
calibration https://irsa.ipac.caltech.edu/ibe/search/ztf/products/cal?

Query Parameters

FORMAT=ra,dec

To see the columns of a particular image metadata table, append the FORMAT parameter with a value equal to METADATA to the base URL.

Examples:

POS=ra,dec

The POS parameter value must consist of an ICRS right ascension and declination in decimal degrees. It identifies the point which returned images must contain, or the center of the search region. The coordinate values must be separated by a comma; no embedded whitespace is allowed.

POS is required in the absence of where.

Examples:


SIZE=width[,height]

The SIZE parameter consists of one or two (comma separated) values in decimal degrees. The first SIZE value is taken to be the full-width of the search region along the east axis at POS, and the second is taken to be the full-height along the north axis. Taken together, POS and SIZE define a convex spherical polygon on the sky with great circle edges - the search region. During a query, this region is compared against the convex spherical polygons formed by connecting the 4 corners of each image in a data-set to determine which images should be returned.

If only one size value is specified, it is used as both the full-width and full-height. Negative sizes are illegal, and a width and height of zero indicate that the search region is a point.

SIZE is an optional parameter. If unspecified, the default search region width and height is 0 (i.e. the search region is just the point POS). Note also that if INTERSECT=CENTER (see below), SIZE is ignored.

Examples:


INTERSECT=value

The INTERSECT parameter specifies a spatial predicate that specifies how the search region S and the spatial extents of a candidate image X must be related. Four values are allowed:

  • COVERS: X must completely contain S. Equivalent to CENTER and OVERLAPS if S is a point.
  • ENCLOSED: S must completely contain X. If S is a point, the query will always return an empty image table.
  • CENTER: X must contain the center of S. If S is a point, this is equivalent to COVERS and OVERLAPS.
  • OVERLAPS: The intersection of S and X is non-empty. If S is a point, this is equivalent to CENTER and COVERS.

The INTERSECT parameter is optional; if unspecified, it defaults to OVERLAPS.

The spatial extent of an image is approximated by connecting its corners with great circles to form a spherical convex polygon. The search region as defined by this service is also a spherical convex polygon (or a point). Spatial predicate evaluation is performed on pairs of spherical convex polygons without recourse to any performance motivated short-cuts. Nevertheless, the implementation uses floating point arithmetic and results are therefore not guaranteed to be mathematically exact. Note also that the spatial extent of an image with a non-gnomonic projection (or large distortion terms) may not be well approximated by the technique employed. However, the images currently being served have gnomonic or orthographic projections, are of small area and have small distortion terms - hence, we believe our approximations are accurate enough to be useful.

Examples:

COLUMNS=name1,name2,....

The columns parameter value must be set to a comma separated list of the column names that should be output. If this argument is omitted, a table specific default column-set is used.

Examples:


WHERE=SQL

The where parameter can be set to a SQL WHERE clause, with some restrictions. Notably, function calls and sub-queries are not supported. You can use AND, OR, NOT, IN, BETWEEN, LIKE, IS, the usual arithmetic and comparison operators, and literal values.

Note that the where parameter is required in the absence of POS (a spatial constraint).

WHERE clauses should be URL encoded.

Examples:

MCEN

The mcen parameter indicates that only the most centered image/image set (with respect to POS) should be returned, rather than all images/image sets containing POS. If the SIZE parameter is specified and non-zero, the mcen parameter is ignored (except when INTERSECT=CENTER).

Note that mcen is not required to have a value. If one is nevertheless specified, it is ignored.

Examples:

CT

The query output format is controlled by the ct parameter, which may always be specified, regardless of the query type. The following values are recognized:

ct=htmlHTML
ct=ipac_tableIPAC ASCII table format
ct=csvComma-separated-value format
ct=tsvTab-separated-value format

Examples:

Table uploads

It is also possible to search for multiple positions in one query (rather than issuing a series of spatial queries). This can be accomplished by setting the value of the POS parameter to the contents of an IPAC ASCII table file containing search positions. The query must be submitted via an HTTP POST rather than a GET, and the table file must contain two columns named ra and dec such that each row corresponds to a single POS value. Any other columns in the table are ignored. Here's an example IPAC ASCII table:

|ra     |dec    |
|double |double |
   358.3    25.6
    19.5    39.5 
   270.0   -30.3 

And here is the UNIX shell command that demonstrate how to query for images overlapping these positions using curl:

curl -F INTERSECT=CENTER -F "POS=@ztf_example.tbl" "https://irsa.ipac.caltech.edu/ibe/search/ztf/products/sci"

Retrieving ZTF Data Products

Once you have the metadata for a data product that you wish to retrieve, you can construct the URL to that data product using the file path patterns described on the ZTF Metadata Page.

Cutouts

Once you have identified the path to a ZTF image, you can create a cutout by appending center and size parameters.

Examples:

Here is the path to a full-sized ZTF science exposure:
https://irsa.ipac.caltech.edu/ibe/data/ztf/products/sci/2017/1015/354109/ztf_20171015354109_000656_zr_c02_o_q4_sciimg.fits

To get a 5 arcmin cutout centered on ra = 61.5 deg, dec = 30 deg, use the following URL:

https://irsa.ipac.caltech.edu/ibe/data/ztf/products/sci/2017/1015/354109/ztf_20171015354109_000656_zr_c02_o_q4_sciimg.fits?center=61.5,30deg&size=5arcmin

Getting Help

If you've run into a problem, think you've found a bug, or simply have questions, please contact IRSA User Support.