API Reference

class alerce.core.Alerce(**kwargs)[source]

The main client class that has all the methods for accessing the different services.

Parameters
**kwargs

Keyword arguments used for setting the configuration of each service

Attributes
ztf_url

The url of the ZTF API

Methods

catshtm_conesearch(ra, dec, radius[, ...])

catsHTM conesearch given an object and catalog_name.

catshtm_crossmatch(ra, dec, radius[, ...])

catsHTM crossmatch given an object and catalog_name.

catshtm_redshift(ra, dec, radius[, format, ...])

Get redshift given an object.

get_avro(oid[, candid])

Download avro of some alert.

get_stamps(oid[, candid, format])

Download Stamps for an specific alert.

plot_stamps(oid[, candid])

Plot stamp in a notebook given oid.

query_classes(classifier_name, ...[, format])

Gets classes from a specified classifier

query_classifiers([format])

Gets all classifiers and their classes

query_detections(oid[, format, index, sort])

Gets all detections of a given object

query_feature(oid, name[, format])

Gets a single feature of a specified object id

query_features(oid[, format, index, sort])

Gets features of a given object

query_lightcurve(oid[, format])

Gets the lightcurve (detections and non_detections) of a given object

query_magstats(oid[, format, index, sort])

Gets magnitude statistics of a given object

query_non_detections(oid[, format, index, sort])

Gets all non detections of a given object

query_object(oid[, format])

Gets a single object by object id

query_objects([format, index, sort])

Gets a list of objects filtered by specified parameters.

query_probabilities(oid[, format, index, sort])

Gets probabilities of a given object

send_query(query[, format, index, sort])

Sends the query directly to the API, returning the byte reply directly

catshtm_catalog_translator

load_config_from_file

load_config_from_object

catshtm_conesearch(ra, dec, radius, catalog_name='all', format='pandas')

catsHTM conesearch given an object and catalog_name.

Parameters
rafloat

Right ascension in Degrees.

deffloat

Declination in Degrees.

catalog_namestr

catsHTM Catalog name, “all” can be used to query all available catalogs. List of available catalogs can be found in here.

radiusfloat

Conesearch radius in arcsec.

formatstr

Output format [votable|pandas]

Returns
dict

Dictionary with the following structure: {

}

catshtm_crossmatch(ra, dec, radius, catalog_name='all', format='pandas')

catsHTM crossmatch given an object and catalog_name.

Parameters
rafloat

Right ascension in Degrees.

def: :py:class:`float`

Declination in Degrees.

catalog_namestr

catsHTM Catalog name, “all” can be used to query all available catalogs. List of available catalogs can be found in here.

radiusfloat

Crossmatch radius in arcsec. (Default 100 arcsec)

formatstr

Output format [votable|pandas]

Returns
dict

Dictionary with the following structure: {

}

catshtm_redshift(ra, dec, radius, format='votable', verbose=False)

Get redshift given an object.

Parameters
oidstr

object ID in ALeRCE DBs.

radiusfloat

catsHTM conesearch radius in arcsec.

formatstr

Output format [votable|pandas]

Returns
float

Check if redshift is in a catsHTM xmatch response.

get_avro(oid, candid=None)

Download avro of some alert.

Parameters
oidstr

object ID in ALeRCE DBs.

candidint

Candid of the avro to be downloaded.

Returns
Avro of a given alert.
get_stamps(oid, candid=None, format='HDUList')

Download Stamps for an specific alert.

Parameters
oidstr

object ID in ALeRCE DBs.

candidint

Candid of the stamp to be displayed.

format:py:class: str

Output format [HDUList|numpy]

Returns
Science, Template and Difference stamps for an specific alert.
plot_stamps(oid, candid=None)

Plot stamp in a notebook given oid. It uses IPython HTML.

Parameters
oidstr

object ID in ALeRCE DBs.

candidint

Candid of the stamp to be displayed.

Returns
Display the stamps on a jupyter notebook.
query_classes(classifier_name, classifier_version, format='json')

Gets classes from a specified classifier

Parameters
classifier_namestr

The classifier unique name

classifier_versionstr

The classifier’s version

query_classifiers(format='json')

Gets all classifiers and their classes

query_detections(oid, format='json', index=None, sort=None)

Gets all detections of a given object

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

indexstr

The name of the column to use as index when format is ‘pandas’

sortstr

The name of the column to sort when format is ‘pandas’

query_feature(oid, name, format='json')

Gets a single feature of a specified object id

Parameters
oidstr

The object identifier

namestr

The feature’s name

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

query_features(oid, format='json', index=None, sort=None)

Gets features of a given object

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

query_lightcurve(oid, format='json')

Gets the lightcurve (detections and non_detections) of a given object

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

query_magstats(oid, format='json', index=None, sort=None)

Gets magnitude statistics of a given object

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

query_non_detections(oid, format='json', index=None, sort=None)

Gets all non detections of a given object

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

query_object(oid, format='json')

Gets a single object by object id

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

query_objects(format='pandas', index=None, sort=None, **kwargs)

Gets a list of objects filtered by specified parameters. It is strongly advised to look at the documentation of `ALERCE ZTF API`_

Parameters
formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

indexstr

Name of the column to use as index when format is ‘pandas’

sortstr

Name of the column to sort when format is ‘pandas’

**kwargs

Keyword arguments. Each argument can be one of the `ALERCE ZTF API`_ object query parameters.

  • classifierstr

    classifier name

  • class_namestr

    class name

  • ndetint[]

    Range of detections.

  • probabilityfloat

    Minimum probability.

  • firstmjdfloat[]

    First detection date range in mjd.

  • lastmjdfloat[]

    Last detection date range in mjd.

  • rafloat

    Ra in degrees for conesearch.

  • decfloat

    Dec in degrees for conesearch.

  • radiusfloat

    Radius in arcsec for conesearch.

  • pageint

    Page or offset to retrieve. Default value : 1

  • page_sizeint

    Number of objects to retrieve in each page. Default value: 10

  • countstr (bool like)

    Whether to count total objects or not. Can be a string representation of boolean like “True”, “true”, “yes”, “false”, …

  • order_bystr

    Column used for ordering. Available values : oid, ndethist, ncovhist, mjdstarthist, mjdendhist, corrected, stellar, ndet, g_r_max, g_r_max_corr, g_r_mean, g_r_mean_corr, meanra, meandec, sigmara, sigmadec, deltamjd, firstmjd, lastmjd, step_id_corr, object, classifier_name, class_name, probability, probabilities

  • order_modestr

    Ordering could be ascendent or descendent. Available values : ASC, DESC

query_probabilities(oid, format='json', index=None, sort=None)

Gets probabilities of a given object

Parameters
oidstr

The object identifier

formatstr

Return format. Can be one of ‘pandas’ | ‘votable’ | ‘json’

send_query(query, format='csv', index=None, sort=None)

Sends the query directly to the API, returning the byte reply directly

Query

query for the database

Format

Format to be returned

Index

index if format is pandas

Sort

sorting column if format is pandas

Returns

reply in the format specified