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.
Metadata
Release files for bseflow 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bseflow-0.2.3.tar.gz | 39.8 kB | Without provenance | Details for bseflow-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bseflow-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for bseflow-0.2.3-py3-none-any.whl |
Total release size: 82.3 kB
Release files / bseflow-0.2.3.tar.gz
| Download URL | bseflow-0.2.3.tar.gz |
|---|---|
| Size | 39.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f74e7adfa0481b90f35aae340fc52ce7ec58cf4b82015c1b037c1c0df17ec9b
|
|
BLAKE2b-256 checksum How to use checksums |
74e5afc6256da409d023cfe95e8632bf43534131c99b10254a5ac218eb3e3bcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / bseflow-0.2.3-py3-none-any.whl
| Download URL | bseflow-0.2.3-py3-none-any.whl |
|---|---|
| Size | 42.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b8bf46279bd38308651925e117a8eab9476407cd9867cc7f5efd933d43f6e40
|
|
BLAKE2b-256 checksum How to use checksums |
0657d9ce0165d938ae2f3f135b2c36226b46974aa5b744ecba4bf33026c0509c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for bseflow 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.