Lasair API Client ∞
The Lasair-Sherlock client allows developers to run queries and cone-searches with the Lasair API, to listen for outputs from streaming queries, and to query the Sherlock sky-context system.
Installation:
pip3 install lasair
Sample Notebooks ∞
There is an accompanying set of jupyter notebooks
Throttling of API Usage ∞
The client has a throttling system in the backend: users with an account get up to 100 calls per hour, but “power” users get up to 10,000 calls per hour. If you wish your account to be upgraded to power user, please put answers to the following in an email to email Lasair-help:
Name and academic position
Institute
Institutional email (not gmail, hotmail, etc)
Are you an LSST data rights holder ?
Brief scientific description of what you want to do with Lasair (max 300 words)
Required rate of API calls in numbers per minute (or hour) and justification for the power user request (max 300 words).
Note: WE ASK YOU TO PLEASE NOT SHARE YOUR API TOKEN. If you share code that uses the Lasair API, please put the token in a separate, imported file or environment variable, that you do not share, and is not put in github.
Methods ∞
Click on the method name to jump to documentation in the reference below.
cone: runs a cone search on all the objects in the Lasair database.
query: runs a SQL SELECT query on the Lasair database.
object: returns a machine-readable version of the object web page.
sherlock_object: returns Sherlock information about a named object.
sherlock_position: returns Sherlock information about a sky position.
cone ∞
This method runs a cone search on all the objects in the Lasair database. The arguments are:
ra: (float) the right ascension in decimal degrees,dec: (float) the declination in decimal degrees,radius: (float) the angular radius of the cone in arcseconds, the maximum being 1000 arcseconds.requestType: (string) the type of request, which can be:nearest: returns only the nearest objects within the coneall: returns all the objects within the conecount: returns the number of objects within the cone
Example:
import lasair
token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
L = lasair.lasair_client(token)
c = L.cone(ra, dec, radius=240.0, requestType='all')
print(c)
and the return has object identifiers, and their separations in arcseconds, something like:
[
{
"object": "ZTF17aaajmtw",
"separation": 2.393511865261539
}
]
query ∞
This method runs a query on the Lasair database. There is an interactive query builder(must be logged in), and a schema description. The arguments are:
selected: (string) the list of attributes to be returned,tables: (string) the list of tables to be joined,conditions: (string) the “WHERE” criteria to restrict what is returnedlimit: (int) (not required) the maximum number of records to return (default is 1000)offset: (int) (not required) offset of record number (default is 0)
Example:
import lasair
token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
L = lasair.lasair_client(token)
selected = 'objectId, gmag'
tables = 'objects'
conditions = 'gmag < 12.0'
c = L.query(selected, tables, conditions, limit=10)
print(c)
and the return is something like:
[
{
"objectId": "ZTF17aaagaie",
"gmag": 11.4319
},
{
"objectId": "ZTF18aaadvxy",
"gmag": 11.8582
},
.... ]
In order to make an API query that involves a watchlist (or watchmap), first find its ID, the number at the end of the URL when you click through to your watchlist.
For example watchlist 8 is named ‘E+A galaxies’. Now add to the selected and tables variables like this:
selected = 'objects.objectId, watchlist_hits.name, watchlist_hits.arcsec'
tables = 'objects,watchlists:139'
which returns the name of the associated watchlist entry and its distance in arcseconds.
It is also possible to query the JSON dictionary associated with an annotator. See the section filtering on an annotator.
object ∞
This method returns a machine-readable version of the information on a named object, which replicates the information on the object page of the web server. The arguments are:
objectId: an objectId for which data is wantedlasair_added: Set to ‘true’ to get the lasair added information such as sherlock, cutout URLs, etclite: set to ‘True’ to get all attributes, including extended (default False).
Example:
import lasair
token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
L = lasair.lasair_client(token)
c = L.object(objectId, lasair_added=True, lite=True)
print(c)
There is a notebook in github, ObjectAPI.ipynb which illustrates the flags lasair_added and lite.
This is how to see exactly what the flags do.
With the arguments above, the lasairData section of the dictionary will have
everything on the object page, including the object and candidates, as well as the
Sherlock and TNS information. The candidate section has bot detections, that have a candid
attribute, and the much smaller non-detections (upper limits). Each candidate has
links to the cutout images that are shown on the object web page.
Note that lasair_added=False and lite=True returns the lightcurve of the object.
sherlock_object ∞
This method returns Sherlock information for a named object, either the “lite” record that is also in the Lasair database, or the full record including many possible crossmatches. The arguments are:
objectIds: an objectIdlite: Set to ‘true’ to get the lite information only
Example
import lasair
token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
L = lasair.lasair_client(token)
c = L.sherlock_object('ZTF20acgrvqo)
print(c)
and the return is something like:
{
"classifications": {
"ZTF20acpwljl": [
"SN",
"The transient is possibly associated with <em><a href='http://skyserver.sdss.org/dr12/en/tools/explore/Summary.aspx?id=1237673709862061782'>SDSS J081931-060114.9</a></em>; a J=17.01 mag galaxy found in the SDSS/2MASS/PS1 catalogues. It's located 1.09 arcsec N, 1.11 arcsec W from the galaxy centre."
]
},
"crossmatches": [
{
"catalogue_object_id": "1237673709862061782",
"J": 17.007,
"JErr": 0.215,
"H": 15.974,
"HErr": 0.179,
"K": 15.389,
sherlock_position ∞
This method returns Sherlock information for an arbitrary position in the sky, either the “lite” record that is also in the Lasair database, or the full record including many possible crossmatches. It is meant as an illustration of what Sherlock can do. If you would like to use Sherlock for high volume work, please Email Lasair-help. The arguments are:
ra: Right ascension of a point in the sky in degreesdec: Declination of a point in the sky in degreeslite: Set to ‘true’ to get the lite information only
Example:
import lasair
token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
L = lasair.lasair_client(token)
c = L.sherlock_position('ZTF20acgrvqo')
print(c)
and the return is something like:
status= 200
{
"classifications": {
"query": [
"VS",
"The transient is synonymous with
annotate ∞
Annotate a Lasair object: For information about this method see Making an Annotator.
annotate_list ∞
Annotate a list of Lasair objects: For information about this method see Making an Annotator.