Mie scattering of a plane wave by a sphere
Project description
Mie scattering calculations in pure Python
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
E-field and H-field calculations in the near-field around a sphere
The implementation is numerically stable for a wide range of size parameters and refractive indices, including lossy materials and high-index contrasts.
JupyterLite Implementation
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 miepython functions
reproducible experiments (downloadable notebooks)
This makes it ideal for teaching, demonstrations, or quick exploratory calculations.
Installation
Install with pip:
pip install miepython
Or via conda:
conda install -c conda-forge miepython
Quick Start
A 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)
Documentation and Examples
The full documentation is available on ReadTheDocs:
Representative results simple examples:
https://github.com/scottprahl/miepython/tree/main/miepython/examples
Performance and Acceleration
miepython supports optional Numba JIT compilation:
import os
os.environ["MIEPYTHON_USE_JIT"] = "1" # must be set before import
import miepython
This 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× |
Citation
If you use laserbeamsize in academic, instructional, or applied technical work, please cite:
Prahl, S. (2026). miepython: Pure python calculation of Mie scattering (Version 3.0.5) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
BibTeX:
@software{prahl_miepython_2025,
author = {Scott Prahl},
title = {{miepython}: A Python library for Mie scattering calculations},
url = {https://github.com/scottprahl/miepython},
doi = {10.5281/zenodo.7949263},
year = {2026},
version = {3.0.5},
publisher = {Zenodo}
}
License
miepython is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 miepython-3.1.0.tar.gz.
File metadata
- Download URL: miepython-3.1.0.tar.gz
- Upload date:
- Size: 76.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef875861b36ede2a3fe3e4b85bdfeb4363c87ee2f1fe046313962572cdfebc13
|
|
| MD5 |
6d2e4bfdf24618078ca6e5558b52a0bf
|
|
| BLAKE2b-256 |
95efc7cd4376843d35620616bab69816891bcf02d7e890a97f5c914a5a4e756a
|
Provenance
The following attestation bundles were made for miepython-3.1.0.tar.gz:
Publisher:
pypi.yaml on scottprahl/miepython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miepython-3.1.0.tar.gz -
Subject digest:
ef875861b36ede2a3fe3e4b85bdfeb4363c87ee2f1fe046313962572cdfebc13 - Sigstore transparency entry: 927249277
- Sigstore integration time:
-
Permalink:
scottprahl/miepython@3dcba6401a524f77115c9b41c4a963468ce26649 -
Branch / Tag:
refs/tags/3.1.0 - Owner: https://github.com/scottprahl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@3dcba6401a524f77115c9b41c4a963468ce26649 -
Trigger Event:
release
-
Statement type:
File details
Details for the file miepython-3.1.0-py3-none-any.whl.
File metadata
- Download URL: miepython-3.1.0-py3-none-any.whl
- Upload date:
- Size: 47.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44d6039396e93345c22928d7a472c57f271e77d9076d8b2ad20610edef08456e
|
|
| MD5 |
972b74539395d8ab55636dcef9a5833c
|
|
| BLAKE2b-256 |
ecd1ed0dc316b94cf57438e5fdf13f999352f16c2520abbf913ab0b194665fab
|
Provenance
The following attestation bundles were made for miepython-3.1.0-py3-none-any.whl:
Publisher:
pypi.yaml on scottprahl/miepython
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miepython-3.1.0-py3-none-any.whl -
Subject digest:
44d6039396e93345c22928d7a472c57f271e77d9076d8b2ad20610edef08456e - Sigstore transparency entry: 927249280
- Sigstore integration time:
-
Permalink:
scottprahl/miepython@3dcba6401a524f77115c9b41c4a963468ce26649 -
Branch / Tag:
refs/tags/3.1.0 - Owner: https://github.com/scottprahl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@3dcba6401a524f77115c9b41c4a963468ce26649 -
Trigger Event:
release
-
Statement type: