Skip to main content

Client of the ALeRCE xmatch service

Project description


API to cross the information of astronomical catalogs with your local catalog or a pandas DataFrame with the astronomical position (ra, dec).



This libraries are specify in the requirements.txt file:


Pip installation

pip install alerce_xmatch

Manual installation

Clone this repo, by executing:

git clone

Then, change the current directory to this repo (generally by using cd xmatch_client) and execute:

python install


Import lib

The library is called alerce_xmatch. To import to your current script (or jupyter notebook) use:

import alerce_xmatch

The class and method available are:

from alerce_xmatch import Catalog, crossmatch, OutputCols, TargetCatalogs


To crossmatch and create a Catalog

Catalogs object has a DataFrame with the astronomical position (in [ra, dec] format) and optionally an id (generally called oid) and more useful attributes. Also, it has an optional name. To create a Catalog object use:

my_catalog = Catalog(df=df, name=name)
# By default df=None, and name="input_catalog"

With this catalog you can get the cross information by using the method:

my_catalog.crossmatch(<target>, output=OutputCols.BOTH, radec=True)

The <target> parameter are available by importing alerce_xmatch.TargetCatalogs and the possibilities are:

from alerce_xmatch import TargetCatalogs

# Available catalogs

The other optional parameters are:

Output columns:

The parameter output, define the columns on the output DataFrame of the resulting Catalog. This option are OutputCols as follow:

from alerce_xmatch import OutputCols

OutputCols.BOTH  # Show all the resilting columns
OutputCols.TARGET  # Show the columns of the target catalog (Gaia, Asassn, ZTF, etc...)
OutputCols.SOURCE # Show the columns of your catalog
Show ra, dec coordinates

By default radec is True, which implies that the output DataFrame has the [ra, dec] position. You can hide this attribute (and lose it) setting radec to False.

To crossmatch a DataFrame

If you want to get and provide just the DataFrame with your info, use the crossmatch method provided as follow:

import pandas as pd
from alerce_xmatch import crossmatch, TargetCatalogs, OutputCols

source_catalog = pd.DataFrame(<your data>)

result = crossmatch(source_catalog, TargetCatalogs.ZTF, output=OutputCols.BOTH, radec=True)

Here, the example target catalog is ZTF, and the optional parameters are used with its default value.

The output type, given a DataFrame, it is a pandas DataFrame. This static method can be used identically providing a Catalog as the source_catalog and the output type will be a Catalog object.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for alerce-xmatch, version 0.0.10
Filename, size File type Python version Upload date Hashes
Filename, size alerce_xmatch-0.0.10.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page