miepython provides a validated and efficient implementation of Mie scattering for spherical particles.
It reproduces established reference results (including Wiscombe's MIEV0) and is designed for scientific, educational, and computational research applications in optics.
The library implements the full Mie solution, including:
- extinction, scattering, and absorption efficiencies
- asymmetry parameter (scattering anisotropy)
- angle-resolved scattering intensities
- Mie expansion coefficients
- complex amplitude functions and Mueller matrices
The implementation is numerically stable for a wide range of size parameters and refractive indices, including lossy materials and high-index contrasts.
The entire package can be used immediately in a browser — without installation — using the JupyterLite interface:
This environment runs entirely client-side (Pyodide), and supports:
- interactive notebooks
- real-time plotting
- full access to
miepythonfunctions - reproducible experiments (downloadable notebooks)
This makes it ideal for teaching, demonstrations, or quick exploratory calculations.
Install with pip:
pip install miepythonOr via conda:
conda install -c conda-forge miepythonA typical calculation is straightforward:
import miepython as mie
m = 1.5 - 0.1j # refractive index
d = 100 # diameter (nm)
lambda0 = 314.15 # wavelength (nm)
qext, qsca, qback, g = mie.efficiencies(m, d, lambda0)The full documentation is available as:
Among other things the documentation discusses:
- Mathematical formulation of Mie theory https://miepython.readthedocs.io/en/latest/01_theory.html
- Normalization conventions and units https://miepython.readthedocs.io/en/latest/02_normalization.html
- Numerical stability considerations https://miepython.readthedocs.io/en/latest/03_stability.html
- Validation against MIEV0 and other reference implementations https://miepython.readthedocs.io/en/latest/04_validation.html
- Guidelines for parameter choices and truncation order https://miepython.readthedocs.io/en/latest/05_truncation.html
- Physical interpretation, resonances, and comparison plots https://miepython.readthedocs.io/en/latest/06_examples.html
Representative results simple examples:
https://github.com/scottprahl/miepython/tree/main/miepython/examples
miepython supports optional Numba JIT compilation:
import os
os.environ["MIEPYTHON_USE_JIT"] = "1" # must be set before import
import miepythonThis can provide 10–50× speedups for large parameter sweeps or ensemble calculations.
Benchmark example (100,000 particles):
| Version | Time | Speedup |
|---|---|---|
| Pure Python | 4.00 s | 1× |
| JIT Enabled | 0.15 s | 27× |
If miepython contributes to your research, please cite the Zenodo archive:
DOI: 10.5281/zenodo.7949263
BibTeX:
@software{prahl_miepython_2025,
author = {Prahl, Scott},
title = {{miepython}: A Python library for Mie scattering calculations},
url = {https://github.com/scottprahl/miepython},
doi = {10.5281/zenodo.7949263},
year = {2025}
}miepython is released under the MIT License.