Using Curl with GraceDB [public]

How to fetch a Skymap

The following program builds the curl commands that you can use to communicate with the LIGO-Virgo event database, GraceDB. You should already be able to log in and get a password, then put that in your .netrc file as in the example below, and then you can download the FITS-HEALPIX file with the probability density of the counterpart location.

# Download a LIGO-Virgo skymap using curl.
# Roy Williams <roy.williams@ligo.org>

# 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

import os

def download_skymap(grace_id, name='bayestar', base_url='https://gracedb.ligo.org/gracedb'):
    """
    Download a sky map from GraceDb.

    Parameters
    ----------
    grace_id : string
        The GraceDb identifier of the event
    name : string
        The filename, less the '.fits.gz' extension
    base_url : string
        The base URL of the GraceDb server. By default, the production server.
    """

    command = 'curl --netrc {base_url}/apibasic/events/{grace_id}/files/{name}.fits.gz -o {grace_id}_{name}.fits.gz'.format(
        base_url=base_url, grace_id=grace_id, name=name)
    print(command)
    os.system(command)


# Example using the function above:
if __name__ == '__main__':
    grace_id = 'T125738'        # identifier for the event
    download_skymap(grace_id)   # fetch the sky map

-- RoyWilliams - 20 Apr 2015

This topic: LV_EM > WebHome > TechInfo > CurlGetSkymap
Topic revision: 2018-05-29, adminuser
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