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.1.tar.gz (39.0 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.1-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bseflow-0.2.1.tar.gz
  • Upload date:
  • Size: 39.0 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.1.tar.gz
Algorithm Hash digest
SHA256 054958af691716c8b04ca87ee3da04b031dc33152085dff8dfd778514b108a62
MD5 807938ebdd5781e86eed5c82a1a2b4bf
BLAKE2b-256 45f09619af0e86710c4ca138c07eb42a0c85ef9cb3adf031f9049f54bf590578

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bseflow-0.2.1-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

Hashes for bseflow-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b83488a42fb8ef993c537dc21cad58f562d8b434da6e20f0a6be921198bf49c6
MD5 6b8b7247134acf21472dcd39194ade53
BLAKE2b-256 5078eb1da29a5a8a9e69ba3e185a733691676f03e42524010317a29c47cf32ca

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