Fetching data

Public data

Through pesummary’s pesummary.gw.fetch module, we can download publicly available posterior samples. For example, we show how to download the posterior samples based on GW190412,

 1from pesummary.gw.fetch import fetch_open_samples
 2import os
 4# For GWTC-1, the posterior samples for a given event are stored in a h5 file.
 5# We can download the data by simply specifying the event name
 6data = fetch_open_samples("GW150914")
 9# For GWTC-2, the LIGO/Virgo/Kagra collaboration releases a tarball for each
10# event which contains multiple files. We may download and unpack the tarball
11# with
12path_to_directory = fetch_open_samples(
13    "GW190412", catalog="GWTC-2", unpack=True, read_file=False,
14    delete_on_exit=False, outdir="./"
16import glob
17print(glob.glob(os.path.join(path_to_directory, "*")))
19# If we wanted to open a specific file within the tarball, we may specify the
20# file with the path kwarg
21data = fetch_open_samples(
22    "GW190412", catalog="GWTC-2", unpack=True, read_file=True,
23    delete_on_exit=False, outdir="./", path="GW190412.h5"

This simply downloads the samples from the LIGO/Virgo Document Control Center and then opens the file with the pesummary.io.read module. For details about how to plot the data stored in this file, see the Plotting from a meta file tutorial.

pesummary.gw.fetch.fetch_open_samples(event, **kwargs)[source]

Download and read publically available gravitational wave posterior samples

  • event (str) – name of the gravitational wave event you wish to download data for

  • **kwargs (dict, optional) – all additional kwargs passed to _fetch_open_data

We may also download publicly available strain data with,

 1from pesummary.gw.fetch import fetch_open_strain
 2import os
 4# Gravitational wave strain data is typically either 32s or 4096s in duration
 5# with a sampling rate of either 4KHz or 16KHz. We can download either by simply
 6# specifying the event name and specifying the duration and sampling rate with
 7# the `duration` and `sampling_rate` kwargs respectively
 8path = fetch_open_strain(
 9    "GW190412", IFO="L1", duration=32, sampling_rate=4096, read_file=False
13# If we wish to read the file, we need to specify the channel name
14data = fetch_open_strain(
15    "GW190412", IFO="L1", duration=32, sampling_rate=4096, read_file=True,
16    channel="L1:GWOSC-4KHZ_R1_STRAIN"
pesummary.gw.fetch.fetch_open_strain(event, format='gwf', **kwargs)[source]

Download and read publically available gravitational wave strain data

  • event (str) – name of the gravitational wave event you wish to download data for

  • format (str, optional) – format of strain data you wish to download. Default “gwf”

  • **kwargs (dict, optional) – all additional kwargs passed to _fetch_open_data

Authenticated data

You may also want to download LIGO/Virgo authenticated posterior samples. This can be done with the following,

>>> from pesummary.gw.fetch import fetch
>>> data = fetch(URL)
Enter username for login.ligo.org: albert.einstein
Enter password for 'albert.einstein' on login.ligo.org:
pesummary.gw.fetch.fetch(url, download_kwargs={}, **kwargs)[source]

Download and read files from LIGO authenticated URLs

  • url (str) – url you wish to download

  • download_kwargs (dict, optional) – optional kwargs passed to _download_autheticated_file

  • **kwargs (dict, optional) – additional kwargs passed to pesummary.io.read function