Utils : SkyPortal API Helper functions
api(method, endpoint, data=None, token=None)
Make an API call to skyportal
Arguments
method : str
HTTP method to use
endpoint : str
Endpoint to call
data : dict
Data to send with the request
token : str
Skyportal token
Returns
response : requests.Response
Response from skyportal
class_exists_in_fink_taxonomy_hierarchy(classification, branch)
Recursively look for a given fink class in a fink's taxonomy hierarchy
Arguments
classification : str
Classification to look for
branch : list
Branch of a taxonomy hierarchy in which we look for the classification recursively
Returns
!!! class
Classification name found in the taxonomy hierarchy
!!! exists
True if the classification is found in the taxonomy hierarchy, False otherwise
classification_exists_for_objs(object_id, url, token)
Check if a classification exists for a given object
Arguments
object_id : str
Object id to check if classification exists for
url : str
Skyportal url
token : str
Skyportal token
Returns
exists : bool
True if classification exists, False otherwise
classification_id_for_objs(object_id, url, token)
Get classification id for a given object
Arguments
object_id : str
Object id to get classification id for
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of classification ids and their author ids
from_fink_to_skyportal(classification, object_id, mjd, instruments, filter, mag, magerr, limiting_mag, magsys, ra, dec, group_id, filter_id, stream_id, taxonomy_id, url, token)
Post an alert to skyportal using its API, that means posting a candidate, the associated source, the photometry of the observation and the classification given by fink
Arguments
classification : str
Classification of for the object
object_id : str
Id of the object
mjd : float
MJD of the observation (Modified Julian Date)
!!! instruments
List of possible names of the instrument used to observe the object
!!! filter
Filter of the instrument used for the observation
mag : float
Magnitude value of the observation
magerr : float
Magnitude error value of the observation
limiting_mag : float
Limiting magnitude value of the observation
magsys : str
Magnitude system used for the magnitude values
ra : float
Right ascension of object
dec : float
Declination of object
group_id : int
Id of the group in skyportal that will contain the alerts from fink
filter_id : int
Id of the filter in skyportal that contains the alerts from fink (filter called fink_filter)
stream_id : int
Id of the stream in skyportal that contains the alerts from fink (stream called fink_stream)
taxonomy_id : int
Id of the taxonomy in skyportal that contains the alerts from fink (taxonomy called Fink Taxonomy, but can also be omitted. If omitted, the classification will be searched in existing taxonomies)
url : str
Skyportal url
token : str
Skyportal token
Returns
None
get_all_candidate_ids(url, token)
Get all candidate ids from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of candidate ids
get_all_filters(url, token)
Get all filters from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of filters
get_all_group_ids(url, token)
Get all group ids from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status : int
HTTP status code
data : list
List of group ids
get_all_instruments(url, token)
Get all instruments from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of instruments
get_all_source_ids(url, token)
Get all source ids from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of source ids
get_all_stream_ids(url, token)
Get all stream ids from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of stream ids
get_all_streams(url, token)
Get all streams from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of streams
get_all_taxonomies(url, token)
Get all taxonomies from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of taxonomies
get_classification_in_fink_taxonomy(classification, fink_taxonomy_id, url, token)
Get the classification of a fink taxonomy
Arguments
classification : str
Classification to look for
fink_taxonomy_id : int
Id of the fink taxonomy
url : str
Skyportal url
token : str
Skyportal token
Returns
!!! classification
Classification of the fink taxonomy
get_fink_taxonomy_id(url, token)
Get the id of the taxonomy in skyportal that is used to classify the alerts
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
taxonomy_id : int
Id of the taxonomy in skyportal
get_group_ids_and_name(url, token)
Get all group ids and their names from skyportal using its API
Arguments
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : list
List of group ids and their names
init_skyportal(group, url, token)
Creates the different entities needed in skyportal to add the data of alerts from fink (streams, filters, groups) and returns the ids of the entities created, so they can be used to post the alerts to skyportal using its API
Arguments
group : str
Name of the group to create if it doesn't exist, or return the id if it does
url : str
Skyportal url
token : str
Skyportal token
Returns
group_id : int
Id of the group in SkyPortal
stream_id : int
Id of the stream in SkyPortal
filter_id : int
Id of the filter in SkyPortal
post_candidate(object_id, ra, dec, filter_ids, passed_at, url, token)
Post a candidate to skyportal using its API
Arguments
object_id : str
Object id to post candidate for
ra : float
Right ascension of object
dec : float
Declination of object
filter_ids : list
List of filter ids for this candidate
passed_at : str
Date and time candidate was passed
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Candidate id
post_classification(object_id, classification, taxonomy_id, group_ids, url, token)
Post a classification to skyportal using its API
Arguments
object_id : str
Object id to post candidate for
classification : str
Classification of the object, e.g. 'kilonova'
taxonomy_id : int
id of the taxonomy in which the classification is defined
groups_ids : list
List of group ids to post classification to
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Classification id
post_filters(name, stream_id, group_id, url, token)
Post a filter to skyportal using its API
Arguments
name : str
Name of the filter to post
stream_id : int
id of the stream to post filter to
group_id : int
id of the group to post filter to
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Filter id
post_groups(name, url, token)
Post a group to skyportal using its API
Arguments
name : str
Name of the group to post
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Group id
post_instruments(name, type, telescope_id, filters, url, token)
Post an instrument to skyportal using its API
Arguments
name : str
Name of the instrument to post
type : str
Type of the instrument to post
telescope_id : int
Id of the telescope to which the instrument is attached
filters : list
List of filters the instrument has
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Instrument id
post_photometry(object_id, mjd, instrument_id, filter, mag, magerr, limiting_mag, magsys, ra, dec, group_ids, stream_ids, url, token)
Post a photometry to skyportal using its API Arguments
object_id : str
Object id to post candidate for
mjd : float
Modified Julian Date of the observation
instrument_id : int
id of the instrument used to observe the object
filter : str
Filter used by the instrument to observe the object
mag : float
Magnitude value of the observation
magerr : float
Magnitude error value of the observation
limiting_mag : float
Limiting magnitude value of the observation
magsys : str
Magnitude system used for the magnitude values
ra : float
Right ascension of object
dec : float
Declination of object
group_ids : list
List of group ids to post photometry to
stream_ids : list
List of stream ids to post photometry to
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Source id
post_source(object_id, ra, dec, group_ids, url, token)
Post a source to skyportal using its API
Arguments
object_id : str
Object id to post source for
ra : float
Right ascension of object
dec : float
Declination of object
group_ids : list
List of group ids to post source to
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Source id
post_stream_access_to_group(stream_id, group_id, url, token)
Post a stream to skyportal using its API
Arguments
stream_id : int
Id of the stream that the group will be able to access
group_id : int
Id of the group to give access to the stream
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
post_streams(name, url, token)
Post a stream to skyportal using its API
Arguments
name : str
Name of the stream to post
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Stream id
post_taxonomy(name, hierarchy, version, group_ids, url, token)
Post a taxonomy to skyportal using its API
Arguments
!!! name "str"
Name of the taxonomy to post
!!! hierarchy "dict"
Hierarchy of the taxonomy to post
!!! version "str"
Version of the taxonomy to post
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Taxonomy id
post_telescopes(name, nickname, diameter, url, token)
Post a telescope to skyportal using its API
Arguments
name : str
Name of the telescope to post
nickname : str
Nickname of the telescope to post
diameter : float
Diameter of the telescope to post
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code
data : int
Telescope id
update_classification(object_id, classification, taxonomy_id, group_ids, url, token)
Update a classification to skyportal using its API
Arguments
object_id : str
Id of the object for which we update the classification
classification : str
Classification of the object
taxonomy_id : int
id of the taxonomy in which the classification is defined
group_ids : list
List of group ids to post the classification to
url : str
Skyportal url
token : str
Skyportal token
Returns
status_code : int
HTTP status code