Metadata-Version: 2.4
Name: miepython
Version: 3.2.0
Summary: Mie scattering of a plane wave by a sphere
Author-email: Scott Prahl <scott.prahl@oit.edu>
License-Expression: MIT
Project-URL: Homepage, https://github.com/scottprahl/miepython
Project-URL: Documentation, https://miepython.readthedocs.io
Project-URL: Source, https://github.com/scottprahl/miepython
Project-URL: Tracker, https://github.com/scottprahl/miepython/issues
Project-URL: Changelog, https://github.com/scottprahl/miepython/blob/main/docs/CHANGELOG.rst
Keywords: mie,scattering,rainbow,droplet,backscatter,sphere,nanoparticle,cloud,phase function,efficiency,rayleigh,backscattering
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE.txt
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: scipy
Requires-Dist: numba; sys_platform != "emscripten"
Provides-Extra: docs
Requires-Dist: Sphinx>=8.1.3; extra == "docs"
Requires-Dist: nbsphinx>=0.9.7; extra == "docs"
Requires-Dist: ipython; extra == "docs"
Requires-Dist: sphinx_automodapi; extra == "docs"
Requires-Dist: sphinx_rtd_theme; extra == "docs"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: imageio; extra == "dev"
Requires-Dist: requests; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: yamllint; extra == "dev"
Requires-Dist: rstcheck[sphinx,toml]; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Requires-Dist: pyroma; extra == "dev"
Requires-Dist: black[jupyter]; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: check-manifest; extra == "dev"
Requires-Dist: libarchive-c; extra == "dev"
Requires-Dist: pyyaml; extra == "dev"
Requires-Dist: setuptools; extra == "dev"
Requires-Dist: jupyterlab; extra == "dev"
Requires-Dist: nbconvert; extra == "dev"
Requires-Dist: nbformat; extra == "dev"
Provides-Extra: lite
Requires-Dist: jupyterlite-core<0.8,>=0.7; extra == "lite"
Requires-Dist: jupyterlite-pyodide-kernel<0.8,>=0.7; extra == "lite"
Dynamic: license-file

.. |pypi| image:: https://img.shields.io/pypi/v/miepython?color=68CA66
   :target: https://pypi.org/project/miepython/
   :alt: PyPI

.. |github| image:: https://img.shields.io/github/v/tag/scottprahl/miepython?label=github&color=68CA66
   :target: https://github.com/scottprahl/miepython
   :alt: GitHub

.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/miepython?label=conda&color=68CA66
   :target: https://github.com/conda-forge/miepython-feedstock
   :alt: Conda

.. |doi| image:: https://zenodo.org/badge/99259684.svg
   :target: https://zenodo.org/badge/latestdoi/99259684
   :alt: DOI

.. |license| image:: https://img.shields.io/github/license/scottprahl/miepython?color=68CA66
   :target: https://github.com/scottprahl/miepython/blob/master/LICENSE.txt
   :alt: License

.. |test| image:: https://github.com/scottprahl/miepython/actions/workflows/test.yaml/badge.svg
   :target: https://github.com/scottprahl/miepython/actions/workflows/test.yaml
   :alt: Testing

.. |docs| image:: https://readthedocs.org/projects/miepython/badge?color=68CA66
   :target: https://miepython.readthedocs.io
   :alt: Docs

.. |downloads| image:: https://img.shields.io/pypi/dm/miepython?color=68CA66
   :target: https://pypi.org/project/miepython/
   :alt: Downloads

.. |lite| image:: https://img.shields.io/badge/try-JupyterLite-68CA66.svg
   :target: https://scottprahl.github.io/miepython/
   :alt: Try JupyterLite


miepython
=========

|pypi| |github| |conda| |doi|  

|license| |test| |docs| |downloads|  

|lite|

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:

|lite|

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:

.. code-block:: bash

    pip install miepython

Or via conda:

.. code-block:: bash

    conda install -c conda-forge miepython

Quick Start
-----------

A typical calculation is straightforward:

.. code-block:: python

    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:

    |docs|


Representative results simple examples:

    https://github.com/scottprahl/miepython/tree/main/miepython/examples

.. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/01.svg
.. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/02.svg
.. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/03.svg
.. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/04.svg
.. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/05.svg

Performance and Acceleration
----------------------------

``miepython`` supports optional Numba JIT compilation:

.. code-block:: python

    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.1.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263

BibTeX:

.. code-block:: bibtex

    @software{prahl_miepython_2026,
      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.1.0},
      publisher = {Zenodo}
    }

License
-------

``miepython`` is released under the MIT License.

