Skip to main content

lasair_api

Client package for Lasair

NAME lasair - Lasair API

DESCRIPTION This class enables programmatic access to the Lasair database and Sherlock service, as described at http://lasair-ztf.lsst.ac.uk/api/.

Args:
    token (string): The Calls are throttled by the lasair server, by use of an 
    'authorization token', as described in the api documentation above. 
    There is a free token listed there, but it is throttled at 10 calls per hour. 
    Once a user has an account at the Lasair webserver, they can get their own token
    allowing 100 calls per hour, or request to be a power user, with infinite usage.

    cache (string): Results can be cached on local filesystem, by providing 
    the name of a writable directory. If the same calls are made repeatedly, 
    this will be much more efficient.

CLASSES class LasairError(builtins.Exception) Raised by the client on bad arguments, HTTP errors (400, 401, 429, 500, ...), request timeouts, or a missing cache directory. The text is in .message

class lasair_client(builtins.object)
   Methods defined here:
   
   __init__(self, token, cache=None, endpoint='https://api.lasair.lsst.ac.uk/api', timeout=60.0)
       Args:
           token: Lasair API token
           cache: name of a directory where results can be cached 
           endpoint: endpoint of the Lasair API service
           timeout: seconds to wait for the server before raising LasairError
   
   cone(self, ra, dec, radius=5, requestType='all')
       Run a cone search on the Lasair database.
       Args:
           ra (float): Right Ascension in decimal degrees
           dec (float): Declination in decimal degrees
           radius (float): cone radius in arcseconds (default is 5)
           requestType: Can be 'all' to return all objects in the cone
               Can be 'nearest', only the nearest object within the cone
               Can be 'count', the number of objects within the cone
       
       Returns a dictionary with:
           objectId: The ID of the nearest object
           separation: the separation in arcseconds
   
   query(self, selected, tables, conditions, limit=1000, offset=0)
       Run a database query on the Lasair server.
       args: 
           selected (string): The attributes to be returned by the query
           tables (string): Comma-separated list of tables to be joined
           conditions (string): the "WHERE" criteria to restrict what is returned
           limit: (int) (default 1000) the maximum number of records to return
           offset: (int) (default 0) offset of record number
       return:
           a list of dictionaries, each representing a row
   
   object(self, objectId, lite=True, lasair_added=True)
       Get object page in machine-readable form
       args:
           objectId: objectId
           lite: less or more output
           lasair_added: include lasair_added value or not
       return:
           dictionary of all the information 
   
   sherlock_object(self, objectId, lite=True)
       Query the Sherlock database for context information about an object
           in the database.
       args:
           objectId: objectId
           lite (boolean): If true (default), get only the summary classification.
               If false, get extended information including a list of
               possible crossmatches.
       return:
           dictionary
   
   sherlock_position(self, ra, dec, lite=True)
       Query the Sherlock database for context information about a position
           in the sky.
       args:
           ra (float): Right Ascension in decimal degrees
           dec (float): Declination in decimal degrees
           lite (boolean): If true (default), get only the summary classification.
               If false, get extended information including a list of
               possible crossmatches.
       return:
           dictionary of contect information
   
   mark(self, objectId, mark)
       Create a mark, favourite or hidden
       args:
           objectId      : the object to be marked, or a list of objectIds
           mark          : one of the MARKS
       return:
           Status message
   
   annotate(self, topic, objectId, classification, \
       version='0.1', explanation='', classdict={}, url='')
       Send an annotation to Lasair
       Note: Only the registered owner of this topic can send annotations to it
       args:
           topic         : the topic for which this user is authenticated
           objectId      : the object that this annotation should be attached to
           classification: short string for the classification
           version       : the version of the annotation engine (16 characters or less)
           explanation   : natural language explanation
           classdict     : dictionary with further information
           url           : url with further information about this classification
       return:
           Status message
   
   annotate_list(self, annotations_input)
       Send a batch of annotations to Lasair
       args:
           annotations_input: list of dictionaries, each with the same keys as
               the arguments of annotate(). topic, objectId and classification
               are required; if any is missing the whole batch is rejected.
               version is truncated to 16 characters.
       return:
           Status message
   
   Data and other attributes defined here:
   
   MARK_FAVOURITE = 'favourite'
   MARK_HIDDEN = 'hidden'
   MARKS = ('favourite', 'hidden')

class lasair_consumer(builtins.object)
   Consume a Kafka stream from Lasair
   
   __init__(self, host, group_id, topic_in):
        Consume a Kafka stream from Lasair
        args:
            host:     Host name:port for consuming Kafka
            group_id: a string. If used before, the server will start from last message
            topic_in: The topic to be consumed. Example 'lasair_2SN-likecandidates'
        Will fail if for some reason the confluent_kafka library cannot be imported.
        Connects to Lasair public kafka to get the chosen topic.
        Once you have the returned consumer object, run it with poll() like this:
        loop:
            msg = consumer.poll(timeout=20)
            if msg is None: break  # no messages to fetch
            if msg.error(): 
                print(str(msg.error()))
                break
            jmsg = json.loads(msg.value())  # msg will be in json format

    poll(self, timeout = 10):
        Polls for a message on the consumer with timeout is seconds

    close():
        Closes the consumer

Copyright 2022 The University of Edinburgh and Queen's University Belfast

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this code except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for lasair 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lasair 0.1.6
File Size Uploaded Provenance Actions
lasair-0.1.6.tar.gz 11.1 kB Without provenance Details for lasair-0.1.6.tar.gz

Release files / lasair-0.1.6.tar.gz

Download URL lasair-0.1.6.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
24991c1a2ce4b816462a6380d0566ca2ef4089812c0b281422b364b75fd6de12
BLAKE2b-256 checksum
How to use checksums
b4c12d109314da069af8e463ee91515cbc637ebaa6012c040e8a981c21fab6bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for lasair 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page