rustmatrix.scatterer#
Python-side Scatterer class.
Mirrors the API of pytmatrix.tmatrix.Scatterer so downstream code
can use this module as a drop-in replacement. Orientation averaging is
provided by rustmatrix.orientation (pure Python; calls into the
Rust single-orientation evaluator in a loop). PSD integration is routed
through rustmatrix.psd, whose fast paths run inside Rust with the
GIL released and parallelise across diameters via rayon.
Notes
The Rust extension caches the built T-matrix on the _handle attribute
and reuses it whenever the signature (radius, radius_type, wavelength,
m, axis_ratio, shape, ddelt, ndgs) is unchanged. Switching orientation
or scattering geometry costs only an amplitude-matrix rotation.
- class rustmatrix.scatterer.Scatterer(**kwargs)[source]#
Bases:
objectT-Matrix scattering from nonspherical particles (Rust backend).
API-compatible with
pytmatrix.tmatrix.Scatterer. Construct one with the size / material / geometry attributes below, then callget_SZ()(orget_S(),get_Z()) to obtain the amplitude and phase matrices.- radius#
Particle “equivalent” radius in mm. Interpreted according to
radius_type. Default: 1.0.- Type:
- radius_type#
One of
RADIUS_EQUAL_VOLUME(default),RADIUS_EQUAL_AREA, orRADIUS_MAXIMUM. Controls howradiusis converted to the Mishchenko-code equal-volume radius the solver expects.- Type:
- wavelength#
Incident-radiation wavelength in mm. Use the
wl_*presets inrustmatrix.tmatrix_auxfor standard radar bands.- Type:
- m#
Refractive index of the particle material. Use
rustmatrix.refractivefor tabulated water/ice values.- Type:
- axis_ratio#
Horizontal over vertical axis ratio.
axis_ratio > 1is oblate (flattened raindrop);< 1is prolate (columnar ice);= 1is a sphere.- Type:
- shape#
Particle shape code.
SHAPE_SPHEROID(-1, default),SHAPE_CYLINDER(-2), orSHAPE_CHEBYSHEV(1).- Type:
- ddelt#
Convergence tolerance for the T-matrix solver.
1e-3is usually fine; tighten to1e-4for high-accuracy work. Default: 1e-3.- Type:
- ndgs#
Quadrature density factor. Increase for elongated particles or large size parameters if the solver fails to converge. Default: 2.
- Type:
- alpha, beta
Particle Euler angles in degrees. For a single-orientation evaluation both default to 0.
- Type:
- thet0, thet
Incident and scattering zenith angles in degrees (0 = north pole, 180 = south). Defaults: both 90 (horizontal propagation).
- Type:
- phi0, phi
Incident and scattering azimuth angles in degrees. Defaults:
phi0 = 0,phi = 180(backscatter).- Type:
- Kw_sqr#
|K_w|² dielectric factor used by
radar.refl(). Standard radar-band values are intmatrix_aux.K_w_sqr. Default: 0.93.- Type:
- orient#
Orientation-averaging strategy from
rustmatrix.orientation(orient_single,orient_averaged_fixed, ororient_averaged_adaptive). Default:orient_single.- Type:
callable
- or_pdf#
Orientation PDF returning weight given β in degrees. See
orientation.gaussian_pdf(),orientation.uniform_pdf().- Type:
callable
- n_alpha, n_beta
Number of α / β samples for
orient_averaged_fixed. Defaults: 5 and 10.- Type:
- psd_integrator#
When set,
get_SZ()integrates S and Z againstpsd. Seerustmatrix.psd.PSDIntegrator.- Type:
PSDIntegrator, optional
- psd#
Particle-size distribution instance (e.g.
rustmatrix.psd.GammaPSD).- Type:
PSD, optional
- suppress_warning#
Silence the
DeprecationWarningemitted when legacy pytmatrix kwargs (axi,lam,eps,rat,np,scatter) are used.- Type:
Examples
>>> from rustmatrix import Scatterer >>> s = Scatterer(radius=1.0, wavelength=33.3, m=complex(7.99, 2.21), ... axis_ratio=1.5, ddelt=1e-4, ndgs=2) >>> s.set_geometry((90, 90, 0, 180, 0, 0)) # horizontal backscatter >>> S, Z = s.get_SZ()
- set_geometry(geom)[source]#
Assign
(thet0, thet, phi0, phi, alpha, beta)in one call.geomis a 6-tuple of degrees — use thegeom_*presets fromrustmatrix.tmatrix_auxfor the common radar cases.
- equal_volume_from_maximum()[source]#
Equal-volume-sphere radius given
self.radiusas a maximum radius.Only defined for
SHAPE_SPHEROIDandSHAPE_CYLINDER. Used internally whenradius_typeisRADIUS_MAXIMUM.
- get_SZ_single(alpha=None, beta=None)[source]#
Amplitude and phase matrices at a single Euler orientation.
- Parameters:
- Returns:
S (ndarray (2, 2) complex) – Amplitude scattering matrix.
Z (ndarray (4, 4) float) – Phase (Stokes) matrix.
Notes
Cached on the handle; re-building the T-matrix only happens when the size/material signature changes. Advancing only
(alpha, beta)or the scattering geometry reuses the existing T-matrix.
- get_SZ_orient()[source]#
S and Z using
self.orient(orientation-averaging dispatcher).Dispatches to the callable in
orient—orientation.orient_single()by default.
- get_SZ()[source]#
Amplitude + phase matrices, PSD-integrated if configured.
- Returns:
S (ndarray (2, 2) complex)
Z (ndarray (4, 4) float)
Notes
If
psd_integratorisNonethis is equivalent toget_SZ_orient(). Otherwise it returns the N(D)-weighted average over the scatter table built byPSDIntegrator.init_scatter_table().