Skip to main content

Read and analyse results generated by rapidpe-rift-pipe

Project description

Read Rapid-PE

This is a package to read Rapid-PE outputs.

Install

Install from PyPI

This read-rapidpe package is available on PyPI: https://pypi.org/project/read-rapidpe/

pip install read-rapidpe

Install in dev mode

git clone git@git.ligo.org:yu-kuang.chu/read-rapidpe.git
cd read-rapidpe
pip install -e . 

Example Usage

Reading files

from read_rapidpe import RapidPE_result

run_dir = "path/to/run_dir"
result = RapidPE_result.from_run_dir(run_dir)

There are three optional arguments:

  • use_ligolw ( default = True ) : whether to use ligo.lw to read XML files.
  • extrinsic_table ( default = True ) : whether to load extrinsic parameter as well.
  • parallel_n ( default = 1 ) : number of parallel jobs when reading XML files.

For example, one can do the following to speed up the reading process:

result = RapidPE_result.from_run_dir(run_dir, use_ligolw=False, extrinsic_table=False, parallel_n=4)

Plot marginalized log-likelihood on m1-m2 grid points

import matplotlib.pyplot as plt

# Plot marginalized-log-likelihood over intrinsic parameter (mass_1/mass_2) grid points
plt.scatter(result.mass_1, result.mass_2, c=result.marg_log_likelihood )
plt.xlabel("$m_1$")
plt.ylabel("$m_2$")
plt.colorbar(label="$\ln(L_{marg})$")

Plot interpolated likelihood

import matplotlib.pyplot as plt
import numpy as np


# Create Random m1, m2 samples
m1 = np.random.random(10000)*5
m2 = np.random.random(10000)*5


# After calling result.do_interpolate_marg_log_likelihood_m1m2(), 
# the method result.log_likelihood(m1, m2) will be avalible.
result.do_interpolate_marg_log_likelihood_m1m2()

# Calculate interpolated log_likelihood
log_likelihood = result.log_likelihood(m1, m2)


# =============== Plotting ===============
# Plot interpolated likelihood 
plt.scatter(m1, m2, c=np.exp(log_likelihood), marker=".", s=3, alpha=0.1)

# Plot marginalized likelihood on grid points
plt.scatter(result.mass_1, result.mass_2, c=np.exp(result.marg_log_likelihood), marker="+", vmin=0)

plt.xlabel("$m_1$")
plt.ylabel("$m_2$")
plt.colorbar(label=r"$\mathcal{L}$")

Convert to Pandas DataFrame

import pandas as pd
from read_rapidpe import RapidPE_grid_point


grid_point = RapidPE_grid_point.from_xml("ILE_iteration_xxxxxxxxxx.samples.xml.gz")
pd.DataFrame(grid_point.extrinsic_table)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

read_rapidpe-0.1.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

read_rapidpe-0.1.2-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file read_rapidpe-0.1.2.tar.gz.

File metadata

  • Download URL: read_rapidpe-0.1.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Darwin/21.6.0

File hashes

Hashes for read_rapidpe-0.1.2.tar.gz
Algorithm Hash digest
SHA256 58b91e7b155c97e84cced3afe92f20900450518e425cdeff2e61d6f36de79668
MD5 d707730490a2ed6b78558e5b93f4deaa
BLAKE2b-256 2a0f62238f0d0195a6729cbf0b8c91cd6896e41a1c0eff1db2633a5818b6c970

See more details on using hashes here.

File details

Details for the file read_rapidpe-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: read_rapidpe-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Darwin/21.6.0

File hashes

Hashes for read_rapidpe-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1e42a1f886e41b05e50e9ed4a50749a5f2c8ba24078fb8ee456593adc5aa7ac
MD5 8db75884a191d3d14badeddbc5b06f4e
BLAKE2b-256 f0ef6fbba879d7e77a9ca1281bd53f323945f4059744b15ec300521df5414cb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page