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 mapping —
bseflowwas developed against a specific COMPAS output schema. Because field and group names differ between COMPAS versions, thecompas_fieldsblock mapsbseflow's internal names to the names in your HDF5 file. If your run uses different headers (e.g. anUnboundflag vs. an olderSurvivedflag, or integerSN_Typecodes vs. boolean PISN/PPISN flags), edit this block rather than your data.
What the diagram shows
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bseflow-0.2.0.tar.gz.
File metadata
- Download URL: bseflow-0.2.0.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0738f7aa38b05e52776afff36038766f4d05dcdd3337d0fe9c469ec11cf8f93
|
|
| MD5 |
f7fdc875970768824d612496f7f7f8aa
|
|
| BLAKE2b-256 |
4ee1a6238184047d65478fda4af90b713ca9cc7b00bc279ee373b1897e370862
|
File details
Details for the file bseflow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bseflow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04d2e252a95313bc1a388095205d073699657fe6a8143f090b32692290bfc4bc
|
|
| MD5 |
20bdc497cfbcd464c45956912eaeafda
|
|
| BLAKE2b-256 |
3cc38a07a3c72690df853c7d3d07a65f48c71d99ebb6677a7631ef0f9c782d39
|