API for miepython packageΒΆ

Mie scattering calculations for perfect spheres JITTED!.

Extensive documentation is at <https://miepython.readthedocs.io>

miepython is a pure Python module to calculate light scattering of a plane wave by non-np.absorbing, partially-np.absorbing, or perfectly conducting spheres.

The extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry for a sphere with complex index of refraction m, diameter d, and wavelength lambda can be found by:

qext, qsca, qback, g = miepython.ez_mie(m, d, lambda0)

The normalized scattering values for angles mu=cos(theta) are:

Ipar, Iper = miepython.ez_intensities(m, d, lambda0, mu)

If the size parameter is known, then use:

miepython.mie(m, x)

Mie scattering amplitudes S1 and S2 (complex numbers):

miepython.mie_S1_S2(m, x, mu)

Normalized Mie scattering intensities for angles mu=cos(theta):

miepython.i_per(m, x, mu)
miepython.i_par(m, x, mu)
miepython.i_unpolarized(m, x, mu)
miepython.miepython.ez_intensities(m, d, lambda0, mu, n_env=1.0)[source]ΒΆ

Return the scattered intensities from a sphere.

These are the scattered intensities in a plane that is parallel (ipar) and perpendicular (iper) to the field of the incident plane wave.

The scattered intensity is normalized such that the integral of the unpolarized intensity over 4πœ‹ steradians is equal to the single scattering albedo. The scattered intensity has units of inverse steradians [1/sr].

The unpolarized scattering is the average of the two scattered intensities.

Parameters
  • m – the complex index of refraction of the sphere [-]

  • d – the diameter of the sphere [same units as lambda0]

  • lambda0 – wavelength in a vacuum [same units as d]

  • mu – the cos(theta) of each direction desired [-]

  • n_env – real index of medium around sphere [-]

Returns

ipar, iper – scattered intensity in parallel and perpendicular planes [1/sr]

miepython.miepython.ez_mie(m, d, lambda0, n_env=1.0)[source]ΒΆ

Calculate the efficiencies of a sphere.

Parameters
  • m – the complex index of refraction of the sphere [-]

  • d – the diameter of the sphere [same units as lambda0]

  • lambda0 – wavelength in a vacuum [same units as d]

  • n_env – real index of medium around sphere [-]

Returns

qext – the total extinction efficiency [-] qsca: the scattering efficiency [-] qback: the backscatter efficiency [-] g: the average cosine of the scattering phase function [-]

miepython.miepython.generate_mie_costheta(mu_cdf)[source]ΒΆ

Generate a new scattering angle using a cdf.

A uniformly spaced cumulative distribution function (CDF) is needed. New random angles are generated by selecting a random interval mu[i] to mu[i+1] and choosing an angle uniformly distributed over the interval.

Parameters

mu_cdf – a cumulative distribution function

Returns

The cosine of the scattering angle

miepython.miepython.i_par(m, x, mu)[source]ΒΆ

Return the scattered intensity in a plane parallel to the incident light.

This is the scattered intensity in a plane that is parallel to the field of the incident plane wave. The intensity is normalized such that the integral of the unpolarized intensity over 4Ο€ steradians is equal to the single scattering albedo.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter

  • mu – the cos(theta) of each direction desired

Returns

The intensity at each angle in the array mu. Units [1/sr]

miepython.miepython.i_per(m, x, mu)[source]ΒΆ

Return the scattered intensity in a plane normal to the incident light.

This is the scattered intensity in a plane that is perpendicular to the field of the incident plane wave. The intensity is normalized such that the integral of the unpolarized intensity over 4Ο€ steradians is equal to the single scattering albedo.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • mu – the angles, cos(theta), to calculate intensities

Returns

The intensity at each angle in the array mu. Units [1/sr]

miepython.miepython.i_unpolarized(m, x, mu)[source]ΒΆ

Return the unpolarized scattered intensity at specified angles.

This is the average value for randomly polarized incident light. The intensity is normalized such that the integral of the unpolarized intensity over 4Ο€ steradians is equal to the single scattering albedo.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter

  • mu – the cos(theta) of each direction desired

Returns

The intensity at each angle in the array mu. Units [1/sr]

miepython.miepython.mie(m, x)[source]ΒΆ

Calculate the efficiencies for a sphere where m or x may be arrays.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

Returns

qext – the total extinction efficiency qsca: the scattering efficiency qback: the backscatter efficiency g: the average cosine of the scattering phase function

miepython.miepython.mie_S1_S2(m, x, mu)[source]ΒΆ

Calculate the scattering amplitude functions for spheres.

The amplitude functions have been normalized so that when integrated over all 4*pi solid angles, the integral will be qext*pi*x**2.

The units are weird, sr**(-0.5)

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • mu – cos(theta) or array of angles [cos(theta_i)]

Returns

S1, S2 – the scattering amplitudes at each angle mu [sr**(-0.5)]

miepython.miepython.mie_cdf(m, x, num)[source]ΒΆ

Create a CDF for unpolarized scattering uniformly spaced in cos(theta).

The CDF covers scattered (exit) angles ranging from 180 to 0 degrees. (The cosines are uniformly distributed over -1 to 1.) Because the angles are uniformly distributed in cos(theta), the scattering function is not sampled uniformly and therefore huge array sizes are needed to adequately sample highly anisotropic phase functions.

Since this is a cumulative distribution function, the maximum value should be 1.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • num – length of desired CDF array

Returns

mu – array of cosines of angles cdf: array of cumulative distribution function values

miepython.miepython.mie_mu_with_uniform_cdf(m, x, num)[source]ΒΆ

Create a CDF for unpolarized scattering for uniform CDF.

The CDF covers scattered (exit) angles ranging from 180 to 0 degrees. (The cosines are uniformly distributed over -1 to 1.) These angles mu correspond to uniform spacing of the cumulative distribution function for unpolarized Mie scattering where cdf[i] = i/(num-1).

This is a brute force implementation that solves the problem by calculating the CDF at many points and then scanning to find the specific angles that correspond to uniform interval of the CDF.

Since this is a cumulative distribution function, the maximum value should be 1.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • num – length of desired CDF array

Returns

mu – array of cosines of angles (irregularly spaced) cdf: array of cumulative distribution function values

Mie scattering calculations for perfect spheres.

Extensive documentation is at <https://miepython.readthedocs.io>

miepython is a pure Python module to calculate light scattering of a plane wave by non-np.absorbing, partially-np.absorbing, or perfectly conducting spheres.

The extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry for a sphere with complex index of refraction m, diameter d, and wavelength lambda can be found by:

qext, qsca, qback, g = miepython.ez_mie(m, d, lambda0)

The normalized scattering values for angles mu=cos(theta) are:

Ipar, Iper = miepython.ez_intensities(m, d, lambda0, mu)

If the size parameter is known, then use:

miepython.mie(m, x)

Mie scattering amplitudes S1 and S2 (complex numbers):

miepython.mie_S1_S2(m, x, mu)

Normalized Mie scattering intensities for angles mu=cos(theta):

miepython.i_per(m, x, mu)
miepython.i_par(m, x, mu)
miepython.i_unpolarized(m, x, mu)
miepython.miepython_nojit.ez_intensities(m, d, lambda0, mu, n_env=1.0)[source]ΒΆ

Return the scattered intensities from a sphere.

These are the scattered intensities in a plane that is parallel (ipar) and perpendicular (iper) to the field of the incident plane wave.

The scattered intensity is normalized such that the integral of the unpolarized intensity over 4πœ‹ steradians is equal to the single scattering albedo. The scattered intensity has units of inverse steradians [1/sr].

The unpolarized scattering is the average of the two scattered intensities.

Parameters
  • m – the complex index of refraction of the sphere [-]

  • d – the diameter of the sphere [same units as lambda0]

  • lambda0 – wavelength in a vacuum [same units as d]

  • mu – the cos(theta) of each direction desired [-]

  • n_env – real index of medium around sphere [-]

Returns

ipar, iper – scattered intensity in parallel and perpendicular planes [1/sr]

miepython.miepython_nojit.ez_mie(m, d, lambda0, n_env=1.0)[source]ΒΆ

Calculate the efficiencies of a sphere.

Parameters
  • m – the complex index of refraction of the sphere [-]

  • d – the diameter of the sphere [same units as lambda0]

  • lambda0 – wavelength in a vacuum [same units as d]

  • n_env – real index of medium around sphere [-]

Returns

qext – the total extinction efficiency [-] qsca: the scattering efficiency [-] qback: the backscatter efficiency [-] g: the average cosine of the scattering phase function [-]

miepython.miepython_nojit.generate_mie_costheta(mu_cdf)[source]ΒΆ

Generate a new scattering angle using a cdf.

A uniformly spaced cumulative distribution function (CDF) is needed. New random angles are generated by selecting a random interval mu[i] to mu[i+1] and choosing an angle uniformly distributed over the interval.

Parameters

mu_cdf – a cumulative distribution function

Returns

The cosine of the scattering angle

miepython.miepython_nojit.i_par(m, x, mu)[source]ΒΆ

Return the scattered intensity in a plane parallel to the incident light.

This is the scattered intensity in a plane that is parallel to the field of the incident plane wave. The intensity is normalized such that the integral of the unpolarized intensity over 4Ο€ steradians is equal to the single scattering albedo.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter

  • mu – the cos(theta) of each direction desired

Returns

The intensity at each angle in the array mu. Units [1/sr]

miepython.miepython_nojit.i_per(m, x, mu)[source]ΒΆ

Return the scattered intensity in a plane normal to the incident light.

This is the scattered intensity in a plane that is perpendicular to the field of the incident plane wave. The intensity is normalized such that the integral of the unpolarized intensity over 4Ο€ steradians is equal to the single scattering albedo.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • mu – the angles, cos(theta), to calculate intensities

Returns

The intensity at each angle in the array mu. Units [1/sr]

miepython.miepython_nojit.i_unpolarized(m, x, mu)[source]ΒΆ

Return the unpolarized scattered intensity at specified angles.

This is the average value for randomly polarized incident light. The intensity is normalized such that the integral of the unpolarized intensity over 4Ο€ steradians is equal to the single scattering albedo.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter

  • mu – the cos(theta) of each direction desired

Returns

The intensity at each angle in the array mu. Units [1/sr]

miepython.miepython_nojit.mie(m, x)[source]ΒΆ

Calculate the efficiencies for a sphere where m or x may be arrays.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

Returns

qext – the total extinction efficiency qsca: the scattering efficiency qback: the backscatter efficiency g: the average cosine of the scattering phase function

miepython.miepython_nojit.mie_S1_S2(m, x, mu)[source]ΒΆ

Calculate the scattering amplitude functions for spheres.

The amplitude functions have been normalized so that when integrated over all 4*pi solid angles, the integral will be qext*pi*x**2.

The units are weird, sr**(-0.5)

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • mu – the angles, cos(theta), to calculate scattering amplitudes

Returns

S1, S2 – the scattering amplitudes at each angle mu [sr**(-0.5)]

miepython.miepython_nojit.mie_cdf(m, x, num)[source]ΒΆ

Create a CDF for unpolarized scattering uniformly spaced in cos(theta).

The CDF covers scattered (exit) angles ranging from 180 to 0 degrees. (The cosines are uniformly distributed over -1 to 1.) Because the angles are uniformly distributed in cos(theta), the scattering function is not sampled uniformly and therefore huge array sizes are needed to adequately sample highly anisotropic phase functions.

Since this is a cumulative distribution function, the maximum value should be 1.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • num – length of desired CDF array

Returns

mu – array of cosines of angles cdf: array of cumulative distribution function values

miepython.miepython_nojit.mie_mu_with_uniform_cdf(m, x, num)[source]ΒΆ

Create a CDF for unpolarized scattering for uniform CDF.

The CDF covers scattered (exit) angles ranging from 180 to 0 degrees. (The cosines are uniformly distributed over -1 to 1.) These angles mu correspond to uniform spacing of the cumulative distribution function for unpolarized Mie scattering where cdf[i] = i/(num-1).

This is a brute force implementation that solves the problem by calculating the CDF at many points and then scanning to find the specific angles that correspond to uniform interval of the CDF.

Since this is a cumulative distribution function, the maximum value should be 1.

Parameters
  • m – the complex index of refraction of the sphere

  • x – the size parameter of the sphere

  • num – length of desired CDF array

Returns

mu – array of cosines of angles (irregularly spaced) cdf: array of cumulative distribution function values