rustmatrix
Rust-backed T-matrix scattering for nonspherical particles. A
drop-in replacement for the numerical core of
pytmatrix, with
substantially faster orientation averaging, parallel PSD integration,
hydrometeor mixtures (HydroMix), and a full Doppler + polarimetric
spectra engine (rustmatrix.spectra). Targets Python 3.9–3.13
via ABI3 wheels.
Existing code that uses pytmatrix.tmatrix.Scatterer, pytmatrix.psd,
pytmatrix.radar, pytmatrix.refractive, or pytmatrix.tmatrix_aux
ports over by changing imports — the APIs are identical where the
physics matches.
Documentation
📖 Full docs: https://rustmatrix.readthedocs.io — install guide, 5-minute quickstart, 14 narrated tutorial notebooks, background theory, every public symbol.
🦀 Rust crate API: https://docs.rs/rustmatrix — for using the crate directly from Rust without the Python wrapper.
Install
pip install rustmatrix
Pre-built ABI3 wheels for CPython 3.8+ ship for macOS (arm64, x86_64), Linux (manylinux x86_64, aarch64), and Windows x64. For source builds or dev installs, see the install guide.
Quickstart
from rustmatrix import Scatterer, radar
from rustmatrix.tmatrix_aux import wl_X, K_w_sqr, geom_horiz_back, dsr_thurai_2007
from rustmatrix.refractive import m_w_10C
s = Scatterer(radius=1.0, wavelength=wl_X, m=m_w_10C[wl_X],
axis_ratio=1.0 / dsr_thurai_2007(2.0), Kw_sqr=K_w_sqr[wl_X])
s.set_geometry(geom_horiz_back)
print(f"Z_h = {radar.refl(s):.3f} mm⁶/m³")
Full walkthrough in the quickstart — sphere → raindrop → PSD in five minutes.
What's here
- Core T-matrix solver — Mishchenko's Fortran kernel, ported to
Rust with the GIL released and
rayon-parallel orientation averaging. - HydroMix — combine multiple species (rain + ice + graupel) into a single Scatterer-shaped object.
- Doppler + polarimetric spectra —
SpectralIntegratorwith fall-speed presets, turbulence kernels (including Zhu 2023 particle-inertia), beam broadening, optional system noise. - Pattern × scene integration —
spectra.beamfor non-uniform beams where the closed-form σ_beam breaks down. - 14 reproducible tutorials covering published results from Kollias 2002 through Lakshmi 2024.
Performance
~6× on orientation averaging, ~10× on PSD tabulation, ~430× on
orient_averaged_adaptive versus the Fortran pytmatrix backend.
Since v2.2, every entrypoint releases the GIL for its heavy
compute — including single-particle calctmat / calcampl, not just
the batch tabulators. Building scatterers from a
concurrent.futures.ThreadPoolExecutor (or dask's threaded scheduler)
scales near-linearly with cores, and TMatrixHandle is immutable, so
one handle can be evaluated from many threads at once. Free-threaded
CPython (3.14t+) is supported natively: the module declares
gil_used = false and ships dedicated cp314t wheels. See
the profiling how-to
for how to measure on your own workload, and
benches/bench_vs_pytmatrix.py for the head-to-head script.
Development
See the contributing guide for dev install, tests, style, and release flow.
pytest tests/ # Python (97 tests)
cargo test --lib --release # Rust crate
cargo fmt --all && cargo clippy --all-targets -- -D warnings
About
rustmatrix is developed by Steve Nesbitt, Professor in the Department of Climate, Meteorology & Atmospheric Sciences at the University of Illinois Urbana-Champaign. It grows out of instruction material for ATMS 410 — Radar Meteorology and accompanies the textbook Radar Meteorology: A First Course (Rauber & Nesbitt, 2018, Wiley).
See also
myPSD — an interactive
web frontend for radar simulation that drives rustmatrix under
the hood.
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 rustmatrix-2.2.0.tar.gz.
File metadata
- Download URL: rustmatrix-2.2.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb352014f33863cefe407e71bef6907d53f5931b2a7fcd2af661c87800e3018
|
|
| MD5 |
59c18427b2c378b4e8d1ed7208ee5964
|
|
| BLAKE2b-256 |
0fb1de573ba08848436d5b1fe22fed89e4ddcaf676b1e9de06c3c84d2b95aaa2
|
File details
Details for the file rustmatrix-2.2.0-cp314-cp314t-win_amd64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp314-cp314t-win_amd64.whl
- Upload date:
- Size: 329.3 kB
- Tags: CPython 3.14t, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5202e91448c8701a257a8adda8002177479b7b9a3fbe1d1c0600aac6dc0a6f7c
|
|
| MD5 |
005b22e6f372eea842d47680ab1c4766
|
|
| BLAKE2b-256 |
7bdfc8500b2a8a566ef2190d27e83d78688a9ebf496137648d21a12c25ad14ed
|
File details
Details for the file rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 420.6 kB
- Tags: CPython 3.14t, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7545977b6289c4880c95cbd518ff5e550564a6334265dcb33fd51c4e5e0e79b
|
|
| MD5 |
f51d120a21046d6ab5c90e0168fee8ad
|
|
| BLAKE2b-256 |
78d828eafc440b87c3be8138fe03d816da1f28c7f30b37686336f102cd79fde6
|
File details
Details for the file rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 402.1 kB
- Tags: CPython 3.14t, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f59b5d3fec9fb91b84863e6d2c1faca4009cf67d67d2a454adb88278dcf51f8
|
|
| MD5 |
596ee5551e3d84609a4174f9fbad3dea
|
|
| BLAKE2b-256 |
42478e62ef5b6facf0df3f159a625e1aea4bb7284229fc3213dbb50d3ab25389
|
File details
Details for the file rustmatrix-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 375.1 kB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bead0921c2a99dc20d9535270ee3faa44096365eeec9630e515c092338c5d06f
|
|
| MD5 |
91e0a5f940e89fa8226b659423bda750
|
|
| BLAKE2b-256 |
fd64f4c0fe2040ec63932b69fcd332a3bf758bda23d64960f25bf337f0910af3
|
File details
Details for the file rustmatrix-2.2.0-cp314-cp314t-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp314-cp314t-macosx_10_12_x86_64.whl
- Upload date:
- Size: 386.8 kB
- Tags: CPython 3.14t, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a78f5ebf84f55c9f808c483260463da675dab7478dd1e8e7955148fc6ac099
|
|
| MD5 |
d3d91004af6c8144479606e91e97f91d
|
|
| BLAKE2b-256 |
be3672832357c80d6591ec823623dd144a2c896d68b95b2c06b15d9af61b6558
|
File details
Details for the file rustmatrix-2.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 336.2 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaf745ee99c8dfc822119eb8aad76c8981cf4b3fbaf317b6c3603cee21813086
|
|
| MD5 |
dc52c5cd4cd70ff56d3db7d8e65a2d7e
|
|
| BLAKE2b-256 |
a303c95ccc4d434d60e7e64163b2f64ecb26ee07dde4588032df08cba5794155
|
File details
Details for the file rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 426.3 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c228267cd4ac4fd9ddacc34d8aa21c89b9dbc5fb88d35792000ba49ae81c7d1
|
|
| MD5 |
2d50d75ec3b552d5987383cb35dbe7bd
|
|
| BLAKE2b-256 |
d088413616a7aa2c5c8f7a96e934bd8800bae128a2e3c3e27b312367c76614f4
|
File details
Details for the file rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 407.8 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e6e4de830cd03e02b82536909c55255fee67ac32d3f2fce4b80739b45ae04a6
|
|
| MD5 |
a0ecc3692895aa141c48f7beb10db4cf
|
|
| BLAKE2b-256 |
4ac9f012405b322431fc6426dcd99bb63585ea76ecd979916a7d50481f6cc1fa
|
File details
Details for the file rustmatrix-2.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 379.6 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe4ccda0a01a4da5fa3a152de3c4f36387ad11cb82f041ef01471fcbff472f6e
|
|
| MD5 |
c0ff730393af4c84bcedc5747ec3e751
|
|
| BLAKE2b-256 |
0a3ffae4668b5040814b655273dbc562f5a6b5f18a89331fcfdc33e971939391
|
File details
Details for the file rustmatrix-2.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rustmatrix-2.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 394.2 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17644a43def3bb54442e228f6f1db6ef46ef4cffcb3a51feddc57874b521a140
|
|
| MD5 |
eb18ad2282004082d2067938100ee4bb
|
|
| BLAKE2b-256 |
f9d9cf48d37c7e8c64e03c02ed4bdd6915e4cb04b8871e2d6e4a2a861188defb
|