Resampling posteriorsΒΆ

Convert sampling parameters to derived parameters

This example shows how to change parameterization of the posterior samples. The GBMCMC sampler uses frequency, frequency derivative, and GW amplitude in its waveform model. For systems whose dynamics are driven by GR, those parameters can be converted to chirp mass and luminosity distance. Here is a demonstration of how to do that by producing a chirpmass-distance corner plot. Import modules

import matplotlib.pyplot as plt
from chainconsumer import ChainConsumer

from lisacattools import get_DL
from lisacattools import get_Mchirp
from lisacattools.catalog import GWCatalog
from lisacattools.catalog import GWCatalogs
from lisacattools.catalog import GWCatalogType

# Start by loading the main catalog file processed from GBMCMC outputs
catPath = "../../tutorial/data/ucb"
catalogs = GWCatalogs.create(GWCatalogType.UCB, catPath, "cat15728640_v2.h5")
final_catalog = catalogs.get_last_catalog()
detections_attr = final_catalog.get_attr_detections()
detections = final_catalog.get_detections(detections_attr)

# Sort table by SNR and select highest SNR source
detections.sort_values(by="SNR", ascending=False, inplace=True)
sourceId = detections.index[0]
samples = final_catalog.get_source_samples(sourceId)

# Reject chain samples with negative fdot (enforce GR-driven prior)
samples_GR = samples[(samples["Frequency Derivative"] > 0)]

# Add distance and chirpmass to samples
get_DL(samples_GR)
get_Mchirp(samples_GR)

# Make corner plot
parameters = ["Chirp Mass", "Luminosity Distance"]
parameter_symbols = [r"$\mathcal{M}\ [{\rm M}_\odot]$", r"$D_L\ [{\rm kpc}]$"]

df = samples_GR[parameters].values

c = ChainConsumer().add_chain(df, parameters=parameter_symbols, cloud=True)
c.configure(flip=False)
fig = c.plotter.plot(figsize=1.5)
plt.show()
$\mathcal{M}\ [{\rm M}_\odot] = \left( 427.7^{+3.6}_{-4.8} \right) \times 10^{-3}$, $D_L\ [{\rm kpc}] = 0.522^{+0.014}_{-0.025}$

Out:

Init the memory cache
(lisacattools.utils._read_chain_file:130) 2023-02-06 17:36:29,480 INFO utils newfunc Init the memory cache
Cache LDC0092117281-cat15728640_v2_chains_1100s.h5
(lisacattools.utils._read_chain_file:133) 2023-02-06 17:36:29,480 INFO utils newfunc Cache LDC0092117281-cat15728640_v2_chains_1100s.h5
INFO:matplotlib.mathtext:Substituting symbol M from STIXNonUnicode
INFO:matplotlib.mathtext:Substituting symbol M from STIXNonUnicode
INFO:matplotlib.mathtext:Substituting symbol M from STIXNonUnicode

Total running time of the script: ( 0 minutes 1.576 seconds)

Gallery generated by Sphinx-Gallery