Skip to main content

Mie scattering of a plane wave by a sphere

Project description

by Scott Prahl

pypi github conda doi

License Testing Docs Downloads

miepython is a pure Python module to calculate light scattering for non-absorbing, partially-absorbing, or perfectly-conducting spheres. Mie theory is used, following the procedure described by Wiscombe. This code has been validated against his work.

scattering diagram

This code provides functions for calculating the extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry. Moreover, a set of angles can be given to calculate the scattering at various angles for a sphere.

When comparing different Mie scattering codes, make sure that you’re aware of the conventions used by each code. miepython makes the following assumptions

  • the imaginary part of the complex index of refraction for absorbing spheres is negative.

  • the scattering phase function is normalized so it equals the single scattering albedo when integrated over 4π steradians by default. This normalization can be changed (see the normalization notebook for details).

This code provides functions for calculating the extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry. Moreover, a set of angles can be given to calculate the scattering for a sphere at each of those angles.

Full documentation at <https://miepython.readthedocs.io>

Pay Attention!

When comparing different Mie scattering codes, make sure that you’re aware of the conventions used by each code. miepython makes the following assumptions

  1. the imaginary part of the complex index of refraction for absorbing spheres is negative.

  2. the scattering phase function is normalized so it equals the single scattering albedo when integrated over 4π steradians. As of version 2.3, this can be changed.

Installation

Use pip:

pip install miepython

or conda:

conda install -c conda-forge miepython

Or run this code in the cloud using Google Collaboratory by selecting the Jupyter notebook that interests you.

Usage for those that don’t do Jupyter

Basic Mie Calculations

from miepython import mie

complex_refractive_index = 1.5-1j # convention is negative imaginary part size_parameter = 1 # 2𝜋(radius)/λ qext, qsca, qback, g = mie(complex_refractive_index, size_parameter)

print(“The extinction efficiency is %.3f” % qext) print(“The scattering efficiency is %.3f” % qsca) print(“The backscatter efficiency is %.3f” % qback) print(“The scattering anisotropy is %.3f” % g)

should produce:

The extinction efficiency  is 2.336
The scattering efficiency  is 0.663
The backscatter efficiency is 0.573
The scattering anisotropy  is 0.192

Simple Dielectric

The script 01_dielectric.py

https://raw.githubusercontent.com/scottprahl/miepython/master/docs/01_plot.svg

Glass Spheres

The script 02_glass.py

https://raw.githubusercontent.com/scottprahl/miepython/master/docs/02_plot.svg

Water Droplets

The script 03_droplets.py

https://raw.githubusercontent.com/scottprahl/miepython/master/docs/03_plot.svg

Small Gold Spheres

The script 04_gold.py

https://raw.githubusercontent.com/scottprahl/miepython/master/docs/04_plot.svg

Usage for those that use Jupyter

All the Jupyter notebooks are available in the docs directory and they are all viewable at <https://miepython.readthedocs.io>

Script Examples for those that don’t do Jupyter

All the Jupyter notebooks are in the docs directory and shown at <https://miepython.readthedocs.io>

You can also use a Jupyter notebook immediately (well, you do have wait a bit for everything to get uploaded) by clicking the Google Colaboratory button below

Colab

License

miepython is licensed under the terms of the MIT 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

miepython-2.5.4.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

miepython-2.5.4-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

Details for the file miepython-2.5.4.tar.gz.

File metadata

  • Download URL: miepython-2.5.4.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for miepython-2.5.4.tar.gz
Algorithm Hash digest
SHA256 1f948529fe4f65eca39758bf7c5c2453a83c77094979a2ccdaf4b0e3e6d298d8
MD5 6e26c51f964256435e1a7c4fa90e46e5
BLAKE2b-256 35453996a34c1e642f17f31abc05291cd8e8fc893014a8daf6ec2acf4c2b1a25

See more details on using hashes here.

File details

Details for the file miepython-2.5.4-py3-none-any.whl.

File metadata

  • Download URL: miepython-2.5.4-py3-none-any.whl
  • Upload date:
  • Size: 30.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for miepython-2.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f40b52404ec42bc0d31c0e3f07d9e836893f2acc2ad909314407e613881ee0cc
MD5 2f73afa29fdeeeef51477450128ae7bc
BLAKE2b-256 a965c5b91da544c1c4b0dd0caf23ff5c58d552089f7f4e890348f848f75f3373

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page