Skip to main content

A python package for simulating populations of gravitational-wave sources.

Project description

gwmock-pop

Python CI pre-commit.ci status Documentation Status codecov PyPI Version Python Versions License Ruff DOI SPEC 0 — Minimum Supported Dependencies

gwmock-pop is a Python package for simulating populations of gravitational-wave sources.

Current package surface

  • Protocols: GWPopSimulator (population simulators), ExternalPopulationLoader (catalogue loaders).
  • Graph-driven sampling: GraphSimulator from a YAML/TOML parameters graph (packaged presets via list_presets() / GraphSimulator.from_preset).
  • Lightweight CBC priors: CBCPriorSimulator, BNSPriorSimulator, NSBHPriorSimulator, and BBHSimulator for tests and baselines.
  • Composition: MixtureSimulator, PoissonEventSampler (event-count helper used in mixture workflows).
  • Catalogues: FilePopulationLoader and read_population_catalogue / write_population_catalogue for CSV and HDF5 (structured or group-of-datasets layouts), including remote URL loading with local caching and CBC canonicalization in the loader.
  • Quality checks: validate_sample for arrays returned by simulators.

Public re-exports live in gwmock_pop.__all__; full module reference is in the API docs.

Requirements

  • Python >=3.12 (tested on 3.12–3.14)
  • Linux, macOS, or Windows

Installation

Install from PyPI:

uv venv --python 3.12
source .venv/bin/activate  # Windows: .venv\Scripts\activate
uv pip install gwmock-pop

Install from source:

git clone git@github.com:Leuven-Gravity-Institute/gwmock-pop.git
cd gwmock-pop
uv venv --python 3.12
source .venv/bin/activate  # Windows: .venv\Scripts\activate
uv sync --no-dev

Developer setup:

uv sync --group dev
uv run pre-commit install

Docs setup:

uv sync --group docs
uv run zensical serve

Getting started (CLI)

The gwmock-pop CLI uses Typer. Typical flow: pick a packaged preset or a graph config file, set the sample count, and write a CSV or HDF5 catalogue.

# Packaged preset (see `gwmock-pop list` for names)
gwmock-pop simulate --config gwtc4 --n 1000 --output population.csv --seed 42

# Or a graph YAML/TOML (top-level `parameters:` as in `examples/gwtc4/bbh_population.yaml`)
gwmock-pop simulate --config examples/gwtc4/bbh_population.yaml --n 500 --output out.h5

Other commands:

Command Purpose
gwmock-pop convert Convert population files between CSV and HDF5; optional --column-map JSON/YAML
gwmock-pop validate Check a graph config without sampling
gwmock-pop inspect Summary statistics for a population file
gwmock-pop list List presets and public simulator classes
gwmock-pop --help
gwmock-pop simulate --help

Getting started (library)

from gwmock_pop import CBCPriorSimulator

sim = CBCPriorSimulator(seed=42)
population = sim.simulate(100)
assert population["detector_frame_mass_1"].shape == (100,)

Use GraphSimulator.from_config_file(...) or GraphSimulator.from_preset(...) for full graph configs (see examples/ and gwmock_pop.simulators.graph).

FilePopulationLoader also accepts http://, https://, s3://, and zenodo://<record>/<file> sources. Remote catalogues are cached under ${GWMOCK_POP_CACHE_DIR} or ${XDG_CACHE_HOME:-~/.cache}/gwmock-pop, and CBC catalogues are validated and rewritten to canonical gwmock-pop parameter names before sampling.

Verification

gwmock-pop --help
python -c "import gwmock_pop; print(gwmock_pop.__version__)"

Testing

Default test run excludes integration-marked tests:

uv run pytest

Run integration tests explicitly:

uv run pytest -m integration

Documentation

License

BSD 3-Clause, 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

gwmock_pop-0.8.0.tar.gz (235.9 kB view details)

Uploaded Source

Built Distribution

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

gwmock_pop-0.8.0-py3-none-any.whl (99.5 kB view details)

Uploaded Python 3

File details

Details for the file gwmock_pop-0.8.0.tar.gz.

File metadata

  • Download URL: gwmock_pop-0.8.0.tar.gz
  • Upload date:
  • Size: 235.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gwmock_pop-0.8.0.tar.gz
Algorithm Hash digest
SHA256 37e941fb07be75632c81ec7ee1dd12392406be55dce3b6d2ec2f232487044347
MD5 84c2e3d9074734d23902499bc4d28665
BLAKE2b-256 69e99d86ca6eb8bf7d84d57620b072fffaf7a3fa4c0909dec6ce8af844a9ec60

See more details on using hashes here.

File details

Details for the file gwmock_pop-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: gwmock_pop-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 99.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gwmock_pop-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d261696c9838947e7dae19670f2353359696f8cfc262c14cfa21619f8e8fe90
MD5 0e1d863f143bf497ba861a1d9a0fce02
BLAKE2b-256 df26502a25e2f36a303a6ef23548852893c232fbb0fe05020aa5f5b54b468e26

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