Fitting of quasinormal modes to ringdown waveforms.
Project description
Welcome to qnmfits
qnmfits is an open-source Python code for least-squares fitting of quasinormal modes to ringdown waveforms.
The code is designed to interface with the sxs and scri packages, which allows for easy loading and transformations of SXS waveforms (including CCE waveforms) - but any waveform data can be used.
Quasinormal-mode frequencies and spherical-spheroidal mixing coefficients are loaded via the qnm package, and multimode fitting across multiple spherical-harmonic modes with mode mixing is handled automatically.
Installation
qnmfits is available on conda-forge:
conda install conda-forge::qnmfits
and PyPI:
pip install qnmfits
From source
Clone and install this code locally:
git clone git@github.com:sxs-collaboration/qnmfits.git
cd qnmfits
pip install .
A note on QNM labeling
In this package QNMs are specified with four numbers: (ell, m, n, sign). The first three numbers refer to the usual angular (ell), azimuthal (m), and overtone (n) indices. The fourth number is either +1 or -1, and refers to the sign of the real part of the QNM frequency. In other words, sign=1 refers to the "regular" QNMs to the right of the imaginary axis, and sign=-1 refers to "mirror" QNMs to the left of the imaginary axis. Note that this is different to the prograde (co-rotating) and retrograde (counter-rotating) classification you sometimes see.
For data which the qnm package can't compute (for example, the special $(2,2,8)$ "multiplet"), additional data can be downloaded with the code
import qnmfits
qnmfits.download_cook_data()
which downloads the Cook & Zalutskiy data from here. Note that there are different labelling conventions for these multiplets. For example, the Schwarzschild $(2,2,8)$ QNM has the behaviour of "splitting" into two branches when the spin is increased:
This has led to these two branches being labelled as $(2,2,8_0)$ and $(2,2,8_1)$ by Cook & Zalutskiy (arxiv:1607.07406). However, from a practical perspective we will be mostly working with Kerr black holes, and these two branches behave as a $n=8$ and $n=9$ overtone. So, as indicated by the figure above, we label them as such (this follows the convention of Forteza & Mourier (arXiv:2107.11829)).
Usage
Perform a seven-overtone fit to the (2,2) mode of SXS:BBH_ExtCCE:0001:
import numpy as np
import qnmfits
# Download SXS:BBH_ExtCCE:0001
abd = qnmfits.cce.load(1)
# Transform to the superrest frame. First, shift the times for convenience:
h22 = abd.h.data[:, abd.h.index(2, 2)]
abd.t -= abd.t[np.argmax(np.abs(h22))]
# Map to the superrest frame
abd_prime = qnmfits.utils.to_superrest_frame(abd, t0=300)
# Get the strain and remnant mass and spin
h = abd_prime.h
Mf = abd_prime.bondi_rest_mass()[-1]
chif = np.linalg.norm(abd_prime.bondi_dimensionless_spin()[-1])
# QNMs we want to fit for. The format is (ell, m, n, sign), where sign is +1
# for "regular" (positive real part) modes, and -1 is for "mirror" (negative
# real part) modes.
qnms = [(2, 2, n, 1) for n in range(7+1)]
# Spherical modes we want to fit to. The format is (ell, m).
spherical_modes = [(2, 2)]
# Ringdown start time
t0 = 0.
# Perform the fit
best_fit = qnmfits.fit(
data=h,
chif=chif,
Mf=Mf,
qnms=qnms,
spherical_modes=spherical_modes,
t0=t0
)
print(f"Mismatch = {best_fit['mismatch']}")
The mismatch should be of order 1E-7.
Please see the notebooks in examples for additional code usage.
Contributing
Contributions are welcome! There are at least two ways to contribute to this codebase:
- If you find a bug or want to suggest an enhancement, use the issue tracker on GitHub. It's a good idea to look through past issues, too, to see if anybody has run into the same problem or made the same suggestion before.
- If you will write or edit the python code, we use the fork and pull request model.
You are also allowed to make use of this code for other purposes, as detailed in the MIT license. For any type of contribution, please follow the code of conduct.
Credits
The code is developed and maintained by Lorena Magaña Zertuche and Eliot Finch.
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 qnmfits-2025.3.1.tar.gz.
File metadata
- Download URL: qnmfits-2025.3.1.tar.gz
- Upload date:
- Size: 872.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d384e57915e7776c3f2e093c14039a8d3a457d22e7174f28ee8ac15404b5a4e
|
|
| MD5 |
0931976d0e683450e4d649b0586c5d59
|
|
| BLAKE2b-256 |
46e9123f1e9c5ac29834b1201526ed2fd71f3728257213f19a06dc8adf327ef2
|
Provenance
The following attestation bundles were made for qnmfits-2025.3.1.tar.gz:
Publisher:
release.yml on sxs-collaboration/qnmfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qnmfits-2025.3.1.tar.gz -
Subject digest:
7d384e57915e7776c3f2e093c14039a8d3a457d22e7174f28ee8ac15404b5a4e - Sigstore transparency entry: 270010355
- Sigstore integration time:
-
Permalink:
sxs-collaboration/qnmfits@88947d37b871bc947cfee4fff340c82d69e7f6f9 -
Branch / Tag:
refs/tags/v2025.3.1 - Owner: https://github.com/sxs-collaboration
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@88947d37b871bc947cfee4fff340c82d69e7f6f9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qnmfits-2025.3.1-py2.py3-none-any.whl.
File metadata
- Download URL: qnmfits-2025.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f89f1d17142bc5133e128ca045a8597fa957a29f9aa7afb239c6e771674327f
|
|
| MD5 |
c7b8ab8b7ce71aa8cc9726fc5665f4c6
|
|
| BLAKE2b-256 |
19842f04fda761d42bfb5251979a399071a595e665175e728f4c3d47537832b2
|
Provenance
The following attestation bundles were made for qnmfits-2025.3.1-py2.py3-none-any.whl:
Publisher:
release.yml on sxs-collaboration/qnmfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qnmfits-2025.3.1-py2.py3-none-any.whl -
Subject digest:
3f89f1d17142bc5133e128ca045a8597fa957a29f9aa7afb239c6e771674327f - Sigstore transparency entry: 270010357
- Sigstore integration time:
-
Permalink:
sxs-collaboration/qnmfits@88947d37b871bc947cfee4fff340c82d69e7f6f9 -
Branch / Tag:
refs/tags/v2025.3.1 - Owner: https://github.com/sxs-collaboration
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@88947d37b871bc947cfee4fff340c82d69e7f6f9 -
Trigger Event:
release
-
Statement type: