Print median values for all parameters in GWTC-3

I recently got a question, asking me how to print all parameter values for a catalog of events. Following the example code in the GWTC-3 PE data release, I wrote some example code to do this.

This uses the pesummary package, which is included in the IGWN Conda distribution.

import numpy as np
from pesummary.io import read
import glob

# -- GWTC-3 PE from zenodo: https://doi.org/10.5281/zenodo.5546662
indir = '/cvmfs/gwosc.osgstorage.org/gwdata/zenodo/ligo-virgo-kagra/2021/5546662/1/'
filelist = glob.glob(indir + '*_cosmo.h5')

for fn in filelist:

    # Get event name from file name
    eventname_spl = fn.split('-')[-1].split('_')[0:2]
    eventname     = '_'.join(eventname_spl)

    # Read in posterior samples
    pedata = read(fn)
    samples = pedata.samples_dict["C01:Mixed"]

    # print out median value for each parameter
    print('\n--- ', eventname, ' ---')    
    for param in sorted(samples.keys()):
        value = np.median(samples[param])
        print(param, value)
2 Likes