Skip to main content

Rust-backed T-matrix scattering for nonspherical particles (port of pytmatrix)

Project description

rustmatrix

crates.io docs.rs docs

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 maturin
maturin develop --release      # from a checkout; builds the Rust extension

Requires a Rust toolchain (rustup default stable, 1.75+) and Python 3.9+. Pre-built wheels are planned for a future release; see the install guide for per-OS instructions.

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

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

rustmatrix-2.1.1.tar.gz (2.3 MB view details)

Uploaded Source

Built Distributions

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

rustmatrix-2.1.1-cp38-abi3-win_amd64.whl (327.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

rustmatrix-2.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (413.1 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

rustmatrix-2.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (396.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

rustmatrix-2.1.1-cp38-abi3-macosx_11_0_arm64.whl (370.0 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

rustmatrix-2.1.1-cp38-abi3-macosx_10_12_x86_64.whl (380.1 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file rustmatrix-2.1.1.tar.gz.

File metadata

  • Download URL: rustmatrix-2.1.1.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for rustmatrix-2.1.1.tar.gz
Algorithm Hash digest
SHA256 daaf4feceb9b4a9ed90c459241aeed56fd1455c026a4d0ea534e3b92fba758a4
MD5 c8551a103c1ec8ec90feafceaab843d3
BLAKE2b-256 5ebbc870bb54eee0fba6a40b668bd930dcc77f84d2423c815fa41a07be115b40

See more details on using hashes here.

File details

Details for the file rustmatrix-2.1.1-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for rustmatrix-2.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9ee91ef521dccd6de5be8227d2787b1f391e489baa1554791609ae270368c317
MD5 a505dbac674ba4816395a894753a9432
BLAKE2b-256 326fc5ac69d791d9ebc2147a9264653f39030836cc1e3ce3fb0e62da0b21fcf1

See more details on using hashes here.

File details

Details for the file rustmatrix-2.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustmatrix-2.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8723ece21717e698a8cdcc9ef24f25539fe277fa629f5164ec8a4c528190784e
MD5 ff7b49e6048d0bff8ba1ad4241ce75de
BLAKE2b-256 3b3d17ddea515d5199371b477f2060d1afc32342b15cffbe46561eb881bcbfad

See more details on using hashes here.

File details

Details for the file rustmatrix-2.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rustmatrix-2.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20e97d8edce4a0b7fe6834eae704231e08da7590bbf9cd7576d26cb6d9d32aa5
MD5 5f7ebfd90a81c960b3aa5a88aaae32a1
BLAKE2b-256 f83aaefddd641f94ea6e3d843bb9809b61fe746c196e20cbfcda1021914770a8

See more details on using hashes here.

File details

Details for the file rustmatrix-2.1.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustmatrix-2.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21303c06d71d4180d94fac2c40d2bde5aabed8c71d689bbafd8b2e82aa421aa7
MD5 ede7f1783debbeb0ff7fbd25ff19b438
BLAKE2b-256 2063fbfcad056216931275e6f3f676937d155d9460db62415b8470a76647e244

See more details on using hashes here.

File details

Details for the file rustmatrix-2.1.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustmatrix-2.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 889e60a171f0e4c8cbb39e8017415745e1177043cd97b9b062df75e28366d39c
MD5 01b1bbcdcc3441da9f9f0b3c04b62669
BLAKE2b-256 1682b52036857a0991123e7c77bd0f14e7254815af2fff5b5b5bd1a682b8fdba

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