Skip to main content

Visualize the formation pathways of gravitational-wave sources from binary population synthesis

Project description

bseflow: A visualization tool for BPS

A visualization tool for binary stellar evolution population synthesis simulations.

bseflow is a Python package that traces the formation pathways of gravitational-wave sources -- binary black holes (BBH), binary neutron stars (BNS), and black hole-neutron stars (BHNS) merger -- through their intermediate evolutionary stages, and generates an interactive Sankey diagram.

With a raw COMPAS HDF5 output of a binary population synthesis run, bseflow tracks the intermediate evolutionary stages of all binary systems, generates a table with fractions of the population undergoing each sequence of stages, and turns the table into a Sankey flow diagram showing the fraction of binaries that survive or are lost at each binary evolution stage (e.g. mass transfer, common-envelope episodes, supernovae, etc).


Installation

pip install bseflow

Or from source for development:

git clone https://github.com/ana-lam/bseflow.git
cd bseflow
pip install -e .

Requires Python ≥ 3.9. numpy, pandas, scipy, numba, h5py, plotly, matplotlib, tqdm, pyyaml install automatically with the package.


Quickstart

1. Generate a config file

Since this tool was originally developed with a older COMPAS version output, bseflow reads a bseflow.yaml from your working directory with default configs + mapping of COMPAS output headers.

Create the default template with:

bseflow

2. Read a COMPAS output and calculate intermediate-stage rates

Read the output HDF5 file and write a small CSV with the rates of intermediate stages.

python -m bseflow.output_rates /path/to/COMPAS_Output.h5 --save_path myrun

or from Python:

from bseflow.output_rates import output_results

output_results("/path/to/COMPAS_Output.h5", save_path="myrun")

This writes a rates_*.csv into the configured rates_dir (default: rates_output/).

Useful options:

Flag / argument Description
--save_path Label used in the output filenames (required).
--CEE Split mass-transfer phases by common envelope vs. stable MT.
--Z, --Z_max Restrict to a metallicity (or metallicity range).
--m_min, --m_max Restrict to a ZAMS primary-mass range.
--MT1mask, --MT2mask Select a specific formation channel by mass-transfer pattern.
--prop_filter Filter by an arbitrary group/property range.
--output_dir Override the output directory.

3. Generate a Sankey diagram

import pandas as pd
from bseflow.plotting.sankey import sankey_data_transform, plot_sankey

# load the rates table
rates = pd.read_csv("rates_output/rates_myrun.csv", index_col=0)

# transform the rates into the Sankey diagram, then write an interactive HTML
df = sankey_data_transform(rates)
plot_sankey(df, title="My COMPAS run", save_path="myrun.html")

The output HTML (written to your configured sankey_dir, default sankey_htmls/) is a self-contained, interactive Plotly figure you can open in any browser or embed in a webpage.


Configuration

bseflow.yaml consists of three things:

  • Output directories — where rate CSVs (rates_dir) and Sankey HTMLs (sankey_dir) are written.
  • Plotting options — font size and whether to use LaTeX rendering (usetex).
  • COMPAS field mappingbseflow was developed against a specific COMPAS output schema. Because field and group names differ between COMPAS versions, the compas_fields block maps bseflow's internal names to the names in your HDF5 file. If your run uses different headers (e.g. an Unbound flag vs. an older Survived flag, or integer SN_Type codes vs. boolean PISN/PPISN flags), edit this block rather than your data.

What the diagram shows

Example Sankey Diagram generated with bseflow

Each node is an evolutionary stage; each flow's width is the fraction of systems taking that path. A typical isolated-binary pathway to a merging compact-object binary runs:

ZAMS → first mass transfer → first supernova → second mass transfer (often common envelope) → second supernova → double compact object → merger within a Hubble time.

At every stage some systems are diverted — stellar mergers, disruption of the binary by a supernova kick, or compact-object binaries too wide to merge within a Hubble time. bseflow colors the surviving pathway distinctly from these lost branches, so you can read off the dominant formation channels and the bottlenecks of a population.


Citing

If you use bseflow in published work, please cite it. Paper/Zenodo DOI to come.


License

Released under the MIT License. See LICENSE.

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

bseflow-0.2.2.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

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

bseflow-0.2.2-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

Details for the file bseflow-0.2.2.tar.gz.

File metadata

  • Download URL: bseflow-0.2.2.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bseflow-0.2.2.tar.gz
Algorithm Hash digest
SHA256 bc68d8955931a147651d3c430a16c52b0d954b564e5b8ee3bee6bfd7e528113f
MD5 37cde91fd3e90f0c9b759d533341fb0a
BLAKE2b-256 0b916ca8ed83d6d5bb9e5685a3793154f197498c48356a23a6db64a6fe176d87

See more details on using hashes here.

File details

Details for the file bseflow-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: bseflow-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 42.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bseflow-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c38f6f5afdf0e3f71707369caed303c859a72035bcfd212855c208c460581d40
MD5 929a42fd2837267ba3d98d4a830aa752
BLAKE2b-256 5f62bdf2d51a577ce055afb2871e06d215c5c940f79127714e8edf93bcadb890

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