Skip to main content

rustmatrix

PyPI crates.io docs.rs docs DOI

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 — SpectralIntegrator with fall-speed presets, turbulence kernels (including Zhu 2023 particle-inertia), beam broadening, optional system noise.
  • Pattern × scene integration — spectra.beam for 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.

Metadata

Release files for rustmatrix 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rustmatrix 2.2.0
File Size Uploaded Provenance Actions
rustmatrix-2.2.0.tar.gz 2.3 MB Without provenance Details for rustmatrix-2.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rustmatrix 2.2.0
File Actions
rustmatrix-2.2.0-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for rustmatrix-2.2.0-cp314-cp314t-win_amd64.whl
rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 Details for rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl
rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64 Details for rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl
rustmatrix-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for rustmatrix-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl
rustmatrix-2.2.0-cp314-cp314t-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 Details for rustmatrix-2.2.0-cp314-cp314t-macosx_10_12_x86_64.whl
rustmatrix-2.2.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for rustmatrix-2.2.0-cp39-abi3-win_amd64.whl
rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
rustmatrix-2.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for rustmatrix-2.2.0-cp39-abi3-macosx_11_0_arm64.whl
rustmatrix-2.2.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for rustmatrix-2.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 6.2 MB

Release files / rustmatrix-2.2.0.tar.gz

Download URL rustmatrix-2.2.0.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
1cb352014f33863cefe407e71bef6907d53f5931b2a7fcd2af661c87800e3018
BLAKE2b-256 checksum
How to use checksums
0fb1de573ba08848436d5b1fe22fed89e4ddcaf676b1e9de06c3c84d2b95aaa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp314-cp314t-win_amd64.whl

Download URL rustmatrix-2.2.0-cp314-cp314t-win_amd64.whl
Size 329.3 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
5202e91448c8701a257a8adda8002177479b7b9a3fbe1d1c0600aac6dc0a6f7c
BLAKE2b-256 checksum
How to use checksums
7bdfc8500b2a8a566ef2190d27e83d78688a9ebf496137648d21a12c25ad14ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl

Download URL rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl
Size 420.6 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c7545977b6289c4880c95cbd518ff5e550564a6334265dcb33fd51c4e5e0e79b
BLAKE2b-256 checksum
How to use checksums
78d828eafc440b87c3be8138fe03d816da1f28c7f30b37686336f102cd79fde6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl

Download URL rustmatrix-2.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl
Size 402.1 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
3f59b5d3fec9fb91b84863e6d2c1faca4009cf67d67d2a454adb88278dcf51f8
BLAKE2b-256 checksum
How to use checksums
42478e62ef5b6facf0df3f159a625e1aea4bb7284229fc3213dbb50d3ab25389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl

Download URL rustmatrix-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl
Size 375.1 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bead0921c2a99dc20d9535270ee3faa44096365eeec9630e515c092338c5d06f
BLAKE2b-256 checksum
How to use checksums
fd64f4c0fe2040ec63932b69fcd332a3bf758bda23d64960f25bf337f0910af3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL rustmatrix-2.2.0-cp314-cp314t-macosx_10_12_x86_64.whl
Size 386.8 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
32a78f5ebf84f55c9f808c483260463da675dab7478dd1e8e7955148fc6ac099
BLAKE2b-256 checksum
How to use checksums
be3672832357c80d6591ec823623dd144a2c896d68b95b2c06b15d9af61b6558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp39-abi3-win_amd64.whl

Download URL rustmatrix-2.2.0-cp39-abi3-win_amd64.whl
Size 336.2 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
aaf745ee99c8dfc822119eb8aad76c8981cf4b3fbaf317b6c3603cee21813086
BLAKE2b-256 checksum
How to use checksums
a303c95ccc4d434d60e7e64163b2f64ecb26ee07dde4588032df08cba5794155
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 426.3 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2c228267cd4ac4fd9ddacc34d8aa21c89b9dbc5fb88d35792000ba49ae81c7d1
BLAKE2b-256 checksum
How to use checksums
d088413616a7aa2c5c8f7a96e934bd8800bae128a2e3c3e27b312367c76614f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rustmatrix-2.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 407.8 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3e6e4de830cd03e02b82536909c55255fee67ac32d3f2fce4b80739b45ae04a6
BLAKE2b-256 checksum
How to use checksums
4ac9f012405b322431fc6426dcd99bb63585ea76ecd979916a7d50481f6cc1fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL rustmatrix-2.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 379.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fe4ccda0a01a4da5fa3a152de3c4f36387ad11cb82f041ef01471fcbff472f6e
BLAKE2b-256 checksum
How to use checksums
0a3ffae4668b5040814b655273dbc562f5a6b5f18a89331fcfdc33e971939391
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / rustmatrix-2.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL rustmatrix-2.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 394.2 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
17644a43def3bb54442e228f6f1db6ef46ef4cffcb3a51feddc57874b521a140
BLAKE2b-256 checksum
How to use checksums
f9d9cf48d37c7e8c64e03c02ed4bdd6915e4cb04b8871e2d6e4a2a861188defb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Security for rustmatrix 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.2.0 This release

11 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page