GWSurrogate
GWSurrogate: A Python package for gravitational wave surrogate models - Published in JOSS (2025)
Science Score: 100.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: arxiv.org, joss.theoj.org -
✓Committers with academic emails
9 of 14 committers (64.3%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
An easy to use interface to gravitational wave surrogate models
Basic Info
Statistics
- Stars: 33
- Watchers: 12
- Forks: 30
- Open Issues: 16
- Releases: 2
Topics
Metadata Files
README.md
Welcome to GWSurrogate!
GWSurrogate is an easy-to-use interface to gravitational wave surrogate models.
Surrogates provide a fast and accurate evaluation mechanism for gravitational waveforms, which would otherwise be found through solving differential equations. These equations must be solved in the ``building" phase, which was performed using other codes.
If this package contributes to a project that leads to a publication, please acknowledge this by citing the relevant paper(s). Please see the How to Cite section at the bottom of this README file.
gwsurrogate is available at https://pypi.python.org
Installation
Dependency
gwsurrogate requires:
1) gwtools. If you are installing gwsurrogate with pip you will automatically get gwtools. If you are installing gwsurrogate from source, please see https://bitbucket.org/chadgalley/gwtools/
2) gsl. For speed, the long (hybrid) surrogates use gsl's spline function. To build gwsurrogate you must have gsl installed. Fortunately, this is a common library and can be easily installed with a package manager.
Note that at runtime (ie when you do import gwsurrogate) you may need to let gsl know where your BLAS library is installed. This can be done by setting your LDPRELOAD or LDLIBRARY_PATH environment variables. A relevant example:
```
export LD_PRELOAD=~/anaconda3/envs/python27/lib/libgslcblas.so ```
From pip
The python package pip supports installing from PyPI (the Python Package Index). gwsurrogate can be installed to the standard location (e.g. /usr/local/lib/pythonX.X/dist-packages) with
```
pip install gwsurrogate ```
If there is no binary/wheel package already available for your operating system, the installer will
try to build the package from the sources. For that, you would need to have gsl installed already.
The installer will look for GSL inside /opt/local/. You may provide additional paths with the
CPPFLAGS and LDFLAGS environment variables.
In the case of an homebrew installation, you may install the package like this:
```
export HOMEBREW_HOME=
brew --prefixexport CPPFLAGS="-I$HOMEBREWHOME/include/" export LDFLAGS="-L$HOMEBREWHOME/lib/" pip install gwsurrogate ```
From conda
gwsurrogate is on conda-forge, and can be installed with
```
conda install -c conda-forge gwsurrogate ```
numpy 1.x and 2.x
Certain gwsurrogate modules are implemented as C-extensions and require NumPy’s C-API headers at build time. By default, pip install . uses the NumPy 2.x headers (as pinned in pyproject.toml) but produces binaries that remain compatible with NumPy >=1.7 at runtime. If you explicitly need to build against NumPy >=1.7 headers, update the NumPy requirement in pyproject.toml before installing.
To create a Conda environment with Python 3.11 and NumPy < 2.0:
bash
conda create -n myenv python=3.11 "numpy<2.0"
From source (pip)
First, please ensure you have the necessary dependencies installed (see above). Next, git clone this project, to any folder of your choosing. Then run
git submodule init
git submodule update
For a "proper" installation, run the following commands from the top-level gwsurrogate folder containing setup.py
```
python -m pip install . # option 1 python -m pip install --editable . # option 2 ```
where the "--editable" installs an editable (development) project with pip. This allows your local code edits to be automatically seen by the system-wide installation.
Documentation
Explore our Jupyter Notebooks for a comprehensive overview of individual models and the user-level API. For an introductory explanation of the surrogate modeling methodology used in GWSurrogate, check out these videos:
Usage
Available models
To get a list of all available surrogate models, do: ```python
import gwsurrogate gwsurrogate.catalog.list() gwsurrogate.catalog.list(verbose=True) # Use this for more details ```
Current NR models
The most up-to-date models trained on numerical relativity data are listed below, along with links to example notebooks. - NRSur7dq4: For generically precessing BBHs, trained on mass ratios q≤4. Paper: arxiv:1905.09300. - NRHybSur3dq8: For nonprecessing BBHs, trained on mass ratios q≤8. Paper: arxiv:1812.07865. - NRHybSur2dq15: For nonprecessing BBHs, trained on q≤15, chi1≤0.5, chi2=0. Paper: arxiv:2203.10109. - NRHybSur3dq8_CCE: For nonprecessing BBHs, trained on CCE (Cauchy-characteristic evolution) waveforms of mass ratios q≤8. Unlike all of the other models, NRHybSur3dq8_CCE includes memory effects. Paper: arxiv:2306.03148.
Current point-particle blackhole perturbation theory models
The most up-to-date models are trained on point-particle blackhole perturbation data and calibrated to numerical relativity (NR) in the comparable mass regime. - BHPTNRSur1dq1e4: Nonspinning BBHs, trained on mass ratios q≤10000 and harmonics up to ell=10. Paper: arxiv:2204.01972.
Current effective one body models
The most up-to-date effective one body surrogate models. - SEOBNRv4PHMSur: precessing binary black hole with 2<=ell<=5 modes in inertial frame. Trained on mass ratios q ≤20. Paper: arxiv:2204.01972.
Download surrogate data and load it
Pick a model, let's say NRSur7dq4 and download the data. Note this only
needs to be done once.
python
gwsurrogate.catalog.pull('NRSur7dq4') # This can take a few minutes
Load the surrogate, this only needs to be done once at the start of a script
python
sur = gwsurrogate.LoadSurrogate('NRSur7dq4')
Evaluate the surrogate
```python q = 4 # mass ratio, mA/mB >= 1. chiA = [-0.2, 0.4, 0.1] # Dimensionless spin of heavier BH chiB = [-0.5, 0.2, -0.4] # Dimensionless of lighter BH dt = 0.1 # timestep size, Units of total mass M flow = 0 # initial frequency, flow=0 returns the full surrogate
optional parameters for a precessing surrogate models
precessingopts = {'returndynamics': True}
h is dictionary of spin-weighted spherical harmonic modes
t is the corresponding time array in units of M
dyn stands for dynamics, do dyn.keys() to see contents
t, h, dyn = sur(q, chiA, chiB, dt=dt, flow=flow, precessingopts=precessingopts) ```
There are many more options, such as using MKS units, returning the
polarizations instead of the modes, etc. Read the documentation for more
details.
python
help(sur)
Jupyter notebooks located in tutorial/website give a more comprehensive overview of individual models.
PyCBC Integration
You can also evaluate any gwsurrogate model through PyCBC’s waveform API.
- Install
bash
pip install gwsurrogate pycbc
- Example Usage
```python from pycbc.waveform import gettdwaveform import gwsurrogate as gws import matplotlib.pyplot as plt
# PyCBC waveform hppcbc, hcpcbc = gettdwaveform(approximant="GWS-NRSur7dq4",mass1=30, mass2=30, deltat=1.0/2048,flower=20.0,f_ref=20.0)
# gwsurrogate waveform sur = gws.LoadSurrogate("NRSur7dq4") t, h, dynamics = sur(q=1.0, chiA0=[0, 0, 0], chiB0=[0, 0, 0], M=60.0, dt=1.0/2048, flow=20.0, distmpc=1.0, units="mks", inclination=0.0, phiref=0.0, fref=20.0)
# Plot comparison plt.plot(hcpcbc.sampletimes, hp_pcbc, 'b', label='h₊ via PyCBC') plt.plot(t, h.real, 'r--', label='h₊ via gwsurrogate') plt.xlabel("Time [s]") plt.ylabel("Strain") plt.legend() plt.show() ```
- Supported Approximants
See the full list of PyCBC entry-point names in
setup.py.
Tests
If you have git cloned this project and installed (and intalled it
using the --editable option), its a good idea to run some regression tests.
```
cd test # move into the folder test python downloadregressionmodels.py # download all surrogate models to test python testmodelregression.py # (optional - if developing a new test) generate regression data locally on your machine cd .. # move back to the top-level folder pytest # run all tests pytest -v -s # run all tests with high verbosity ```
Contributing
We welcome contributions! Here's how you can get involved:
Report Bugs or Suggest Enhancements:
Use the GitHub issue tracker to report bugs or suggest new features. Before submitting, consider browsing through existing issues to see if your concern has already been addressed. A developer will respond to issues that are opened on GitHub.Contribute Code:
We use the fork and pull request model for code contributions. Fork the repository, make your changes, and submit a pull request. We use Ruff for linting and auto-fixes. If you’re on VS Code, install the Ruff extension.
Please ensure you follow our Code of Conduct when contributing.
How to cite
If this package contributes to a project that leads to a publication, please acknowledge this by citing the GWSurrogate article in JOSS. The paper has the following bibtex entry
@article{Field:2025isp,
author = "Field, Scott E. and Varma, Vijay and Blackman, Jonathan and Gadre, Bhooshan and Galley, Chad R. and Islam, Tousif and Mitman, Keefe and Pürrer, Michael and Ravichandran, Adhrit and Scheel, Mark A. and Stein, Leo C. and Yoo, Jooheon",
title = "{GWSurrogate: A Python package for gravitational wave surrogate models}",
eprint = "2504.08839",
archivePrefix = "arXiv",
primaryClass = "astro-ph.IM",
doi = "10.21105/joss.07073",
journal = "J. Open Source Softw.",
volume = "10",
number = "107",
pages = "7073",
year = "2025"
}
`
Please also cite the relevant paper(s) describing your specific model. This information can be found by doing
```python
import gwsurrogate gwsurrogate.catalog.list(verbose=True) ```
NSF Support
This package is based upon work supported by the National Science Foundation under PHY-1316424, PHY-1208861, and PHY-1806665.
Any opinions, findings, and conclusions or recommendations expressed in gwsurrogate are those of the authors and do not necessarily reflect the views of the National Science Foundation.
Owner
- Name: Simulating eXtreme Spacetimes
- Login: sxs-collaboration
- Kind: organization
- Website: https://www.black-holes.org
- Repositories: 8
- Profile: https://github.com/sxs-collaboration
JOSS Publication
GWSurrogate: A Python package for gravitational wave surrogate models
Authors
Department of Mathematics and Center for Scientific Computing \& Data Science Research, University of Massachusetts, Dartmouth, MA 02747, USA, Department of Physics and Center for Computational Research, East Hall, University of Rhode Island, Kingston, RI 02881, USA
Department of Mathematics and Center for Scientific Computing \& Data Science Research, University of Massachusetts, Dartmouth, MA 02747, USA
Theoretical Astrophysics 350-17, California Institute of Technology, Pasadena, California 91125, USA
Institute for Gravitational and Subatomic Physics (GRASP), Utrecht University, 3584 CC Utrecht, The Netherlands
Theoretical Astrophysics 350-17, California Institute of Technology, Pasadena, California 91125, USA
Department of Mathematics and Center for Scientific Computing \& Data Science Research, University of Massachusetts, Dartmouth, MA 02747, USA, Kavli Institute for Theoretical Physics, University of California Santa Barbara, CA 93106, USA
Theoretical Astrophysics 350-17, California Institute of Technology, Pasadena, California 91125, USA
Department of Physics and Center for Computational Research, East Hall, University of Rhode Island, Kingston, RI 02881, USA
Department of Mathematics and Center for Scientific Computing \& Data Science Research, University of Massachusetts, Dartmouth, MA 02747, USA
Theoretical Astrophysics 350-17, California Institute of Technology, Pasadena, California 91125, USA
Tags
physics general relativity black holes gravitational wavesCitation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Field"
given-names: "Scott E."
orcid: "https://orcid.org/0000-0002-6037-3277"
equal-contrib: true
- family-names: "Varma"
given-names: "Vijay"
orcid: "https://orcid.org/0000-0002-9994-1761"
equal-contrib: true
- family-names: "Blackman"
given-names: "Jonathan"
- family-names: "Gadre"
given-names: "Bhooshan"
orcid: "https://orcid.org/0000-0002-1534-9761"
- family-names: "Galley"
given-names: "Chad R."
- family-names: "Islam"
given-names: "Tousif"
orcid: "https://orcid.org/0000-0002-3434-0084"
- family-names: "Mitman"
given-names: "Keefe"
orcid: "https://orcid.org/0000-0003-0276-3856"
- family-names: "Pürrer"
given-names: "Michael"
orcid: "https://orcid.org/0000-0002-3329-9788"
- family-names: "Ravichandran"
given-names: "Adhrit"
- family-names: "Scheel"
given-names: "Mark A."
orcid: "https://orcid.org/0000-0001-6656-9134"
- family-names: "Stein"
given-names: "Leo C."
orcid: "https://orcid.org/0000-0001-7559-9597"
- family-names: "Yoo"
given-names: "Jooheon"
orcid: "https://orcid.org/0000-0002-3251-0924"
title: "gwsurrogate"
version: 1.1.7
date-released: "2025-02-25"
license: MIT
repository-code: "https://github.com/sxs-collaboration/gwsurrogate"
GitHub Events
Total
- Create event: 7
- Release event: 3
- Issues event: 6
- Watch event: 8
- Delete event: 4
- Member event: 1
- Issue comment event: 11
- Push event: 48
- Pull request event: 18
- Pull request review event: 14
- Pull request review comment event: 11
- Fork event: 6
Last Year
- Create event: 7
- Release event: 3
- Issues event: 6
- Watch event: 8
- Delete event: 4
- Member event: 1
- Issue comment event: 11
- Push event: 48
- Pull request event: 18
- Pull request review event: 14
- Pull request review comment event: 11
- Fork event: 6
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Scott Field | s****d@u****u | 542 |
| Vijay Varma | v****a@c****u | 104 |
| Chad Galley | c****y@t****u | 47 |
| Jonathan Blackman | j****0@g****m | 21 |
| Jooheon | j****4@c****u | 14 |
| Kevin Barkett | k****t@c****u | 11 |
| Tousif Islam | t****4@g****m | 8 |
| Leo C. Stein | l****n@g****m | 8 |
| Jonathan Blackman | j****a@c****u | 5 |
| Duncan Macleod | d****d@l****g | 4 |
| Raffi Enficiaud | r****d@m****g | 3 |
| Alexander Harvey Nitz | a****z@g****m | 1 |
| Dwyer Deighan | d****n@u****u | 1 |
| tausigmaislam | t****m@u****u | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 27
- Total pull requests: 51
- Average time to close issues: almost 2 years
- Average time to close pull requests: about 1 month
- Total issue authors: 12
- Total pull request authors: 11
- Average comments per issue: 1.59
- Average comments per pull request: 1.69
- Merged pull requests: 40
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 19
- Average time to close issues: N/A
- Average time to close pull requests: 4 days
- Issue authors: 3
- Pull request authors: 6
- Average comments per issue: 0.0
- Average comments per pull request: 0.26
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- sfield17 (12)
- seth-olsen (3)
- OliverJennrich (2)
- GarethCabournDavies (2)
- Ceciliogq (1)
- ColmTalbot (1)
- avivajpeyi (1)
- duetosymmetry (1)
- ssingh-sgr (1)
- ahnitz (1)
- vijayvarma392 (1)
- moble (1)
Pull Request Authors
- sfield17 (20)
- vijayvarma392 (9)
- jyoo1042 (4)
- Abhishek-Ravishankar (4)
- duetosymmetry (4)
- raffienficiaud (2)
- warrickball (2)
- duncanmmacleod (2)
- plaplant (2)
- ssingh-sgr (1)
- ahnitz (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 390 last-month
-
Total dependent packages: 3
(may contain duplicates) -
Total dependent repositories: 6
(may contain duplicates) - Total versions: 60
- Total maintainers: 2
pypi.org: gwsurrogate
An easy to use interface to gravitational wave surrogate models
- Documentation: https://gwsurrogate.readthedocs.io/
- License: MIT
-
Latest release: 1.1.8
published 6 months ago
Rankings
Maintainers (2)
conda-forge.org: gwsurrogate
GWSurrogate is an easy to use interface to gravitational wave surrogate models. Surrogates provide a fast and accurate evaluation mechanism for gravitational waveforms which would otherwise be found through solving differential equations. These equations must be solved in the 'building' phase, which was performed using other codes.
- Homepage: https://github.com/sxs-collaboration/gwsurrogate
- License: MIT
-
Latest release: 1.1.3
published about 3 years ago
Rankings
Dependencies
- gwtools *
- h5py *
- numpy *
- scikit-learn *
- scipy *