You are here: GW-Astronomy wiki>LV_EM Web>TechInfo>PythonGetSkymap (2018-05-29, adminuser)Edit Attach

Using the GraceDB Python client [public]

How to fetch a Skymap

The following program fetches a skymap from GraceDB, assuming you already know the name of the skymap and the GraceID (UID) of the event in question. This has the same effect as the corresponding example code: CurlGetSkymap.

# Download a LIGO-Virgo skymap using curl.
#
# Add a line like this to 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

from ligo.gracedb.rest import GraceDbBasic

if __name__ == '__main__':

    grace_id = 'T125738'            # identifier for the event
    filename = 'bayestar.fits.gz'  # filename of desired skymap

    # Prepend with grace_id for output filename
    out_filename = grace_id + '_' + filename

    # Instantiate the GraceDB client
    service_url = 'https://gracedb.ligo.org/apibasic/'
    client = GraceDbBasic(service_url)

    # Grab the file from the server and write it 
    out_file = open(out_filename, "w")
    r = client.files(grace_id, filename)
    out_file.write(r.read())
    out_file.close()

-- BransonStephens - 12 Jun 2015
Topic revision: r3 - 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