Skip to content

Latest commit

 

History

History
169 lines (107 loc) · 6.17 KB

README.rst

File metadata and controls

169 lines (107 loc) · 6.17 KB

miepython

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

image

Glass Spheres

The script 02_glass.py

image

Water Droplets

The script 03_droplets.py

image

Small Gold Spheres

The script 04_gold.py

image

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.