Using Curl with GraceDB [public]

How to fetch a Skymap using Python

Suppose you know the graceid of an event and you want to upload coordinates of an observation you have performed to follow it up. This program shows an example using the GraceDB Python client. (The results is the same does as in the corresponding example using curl: CurlUploadFootprints.)

# Upload observation footprints to GraceDB
#
# Include a line similar to this in your .netrc file:
#    machine gracedb.ligo.org login albert.einstein@LIGO.ORG password JKJKJKJkjkjkjkj1223
#
# You can get the password from 
#    https://gracedb.ligo.org/gracedb/options/manage_password
#
# Also, first install the GraceDB REST client package:
#   pip install ligo-gracedb

from ligo.gracedb.rest import GraceDbBasic, HTTPError

if __name__ == '__main__':

    # Define the parameters of the observation to be reported
    grace_id      = 'M158044'           # identifier for the event this report concerns
    group         = 'CRTS'              # the MOU group responsible 
    comment       = 'hello my friend'   # the human-made part of the report
    raList        = [123.0,124.0,125.0] # a list of RA of centers of footprints (degrees)
    decList       = [10.0,11.0,13.0]    # a list of Dec of centers of footprints (degrees)
    startTimeList = [                   # list of beginnings of exposures (UTC)
        '2015-05-31T12:45:00',
        '2015-05-31T12:49:00',
        '2015-05-31T12:53:00']
    raWidthList   = 10.0       # list (or one for all) of footprint widths in RA (degrees)
    decWidthList  = 10.0       # list (or one for all) of footprint widths in Dec (degrees)
    durationList  = 20.0       # list (or one for all) of exposure times in sec

    # Instantiate the GraceDB client
    client = GraceDbBasic()

    # Write the EMObservation record to GraceDB
    r = client.writeEMObservation(grace_id, group, raList, raWidthList,
        decList, decWidthList, startTimeList, durationList, comment)

    if r.status == 201:       # 201 means 'Created'
        print 'Success!'

-- BransonStephens - 11 Jun 2015
Topic revision: r4 - 2018-05-29, adminuser
Warning: Can't find topic LV_EM.WebLeftBarExample

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GW-Astronomy wiki? Send feedback