Skip to content

Commit

Permalink
1.3.0 revision
Browse files Browse the repository at this point in the history
Significantly improved graphical inversion routines to correctly handle matplotlib objects as both inputs and outputs - can now manipulate graphs outside of PyMieScatt. Also added AutoMie functions and rolled some other functions to use it. Docs forthcoming.
  • Loading branch information
bsumlin committed Oct 6, 2017
1 parent cf0b010 commit 35d6e43
Show file tree
Hide file tree
Showing 13 changed files with 406 additions and 250 deletions.
4 changes: 2 additions & 2 deletions PyMieScatt.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: PyMieScatt
Version: 1.2.6
Version: 1.3.0
Summary: A collection of forward and inverse Mie solving routines based on Bohren and Huffman's Mie Theory derivations.
Home-page: http://air.eece.wustl.edu/people/ben-sumlin/
Author: Benjamin Sumlin
Author-email: bsumlin@wustl.edu
License: GPL
Description: 1.2.6 - Added error bounds as an option for the graphical inversion method. Added new automatic inversion methods Inversion() and Inversion_SD(). Significantly improved the iterative methods.
Description: 1.3.0 - Added error bounds as an option for the graphical inversion method. Added new automatic inversion methods Inversion() and Inversion_SD(). Significantly improved the iterative methods.
Docs are hosted at `ReadTheDocs <http://pymiescatt.readthedocs.io/>`_.
Keywords: Mie Rayleigh scattering absorption extinction light refraction
Platform: UNKNOWN
Expand Down
295 changes: 179 additions & 116 deletions PyMieScatt/Inverse.py

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions PyMieScatt/Mie.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ def RayleighMieQ(m, wavelength, diameter, asDict=False):
else:
return qext, qsca, qabs, g, qpr, qback, qratio

def AutoMieQ(m, wavelength, diameter, asDict=False):
def AutoMieQ(m, wavelength, diameter, crossover=0.5, asDict=False):
# http://pymiescatt.readthedocs.io/en/latest/forward.html#AutoMieQ
x = np.pi*diameter/wavelength
if x==0:
return 0, 0, 0, 1.5, 0, 0, 0
elif x<0.5:
elif x<crossover:
return RayleighMieQ(m, wavelength, diameter, asDict=asDict)
else:
return MieQ(m, wavelength, diameter, asDict=asDict)
Expand Down Expand Up @@ -332,7 +333,7 @@ def MieQ_withDiameterRange(m, wavelength, diameterRange=(10,1000), nd=1000, logD
diameters = np.logspace(np.log10(diameterRange[0]),np.log10(diameterRange[1]),nd)
else:
diameters = np.linspace(diameterRange[0],diameterRange[1],nd)
_qD = [MieQ(m,wavelength,diameter) for diameter in diameters]
_qD = [AutoMieQ(m,wavelength,diameter) for diameter in diameters]
qext = np.array([q[0] for q in _qD])
qsca = np.array([q[1] for q in _qD])
qabs = np.array([q[2] for q in _qD])
Expand All @@ -349,7 +350,7 @@ def MieQ_withWavelengthRange(m, diameter, wavelengthRange=(100,1600), nw=1000, l
wavelengths = np.logspace(np.log10(wavelengthRange[0]),np.log10(wavelengthRange[1]),nw)
else:
wavelengths = np.linspace(wavelengthRange[0],wavelengthRange[1],nw)
_qD = [MieQ(m,wavelength,diameter) for wavelength in wavelengths]
_qD = [AutoMieQ(m,wavelength,diameter) for wavelength in wavelengths]
elif type(m) in [np.ndarray,list,tuple] and len(wavelengthRange)==len(m):
wavelengths=wavelengthRange
_qD = [MieQ(emm,wavelength,diameter) for emm,wavelength in zip(m,wavelengths)]
Expand All @@ -373,7 +374,7 @@ def MieQ_withSizeParameterRange(m, xRange=(1,10), nx=1000, logX=False):
else:
xValues = list(np.linspace(xRange[0],xRange[1], nx))
dValues = [1000*x/np.pi for x in xValues]
_qD = [MieQ(m,1000,d) for d in dValues]
_qD = [AutoMieQ(m,1000,d) for d in dValues]
qext = np.array([q[0] for q in _qD])
qsca = np.array([q[1] for q in _qD])
qabs = np.array([q[2] for q in _qD])
Expand Down
2 changes: 1 addition & 1 deletion PyMieScatt/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.6"
__version__ = "1.3.0"
295 changes: 179 additions & 116 deletions build/lib/PyMieScatt/Inverse.py

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions build/lib/PyMieScatt/Mie.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ def RayleighMieQ(m, wavelength, diameter, asDict=False):
else:
return qext, qsca, qabs, g, qpr, qback, qratio

def AutoMieQ(m, wavelength, diameter, asDict=False):
def AutoMieQ(m, wavelength, diameter, crossover=0.5, asDict=False):
# http://pymiescatt.readthedocs.io/en/latest/forward.html#AutoMieQ
x = np.pi*diameter/wavelength
if x==0:
return 0, 0, 0, 1.5, 0, 0, 0
elif x<0.5:
elif x<crossover:
return RayleighMieQ(m, wavelength, diameter, asDict=asDict)
else:
return MieQ(m, wavelength, diameter, asDict=asDict)
Expand Down Expand Up @@ -332,7 +333,7 @@ def MieQ_withDiameterRange(m, wavelength, diameterRange=(10,1000), nd=1000, logD
diameters = np.logspace(np.log10(diameterRange[0]),np.log10(diameterRange[1]),nd)
else:
diameters = np.linspace(diameterRange[0],diameterRange[1],nd)
_qD = [MieQ(m,wavelength,diameter) for diameter in diameters]
_qD = [AutoMieQ(m,wavelength,diameter) for diameter in diameters]
qext = np.array([q[0] for q in _qD])
qsca = np.array([q[1] for q in _qD])
qabs = np.array([q[2] for q in _qD])
Expand All @@ -349,7 +350,7 @@ def MieQ_withWavelengthRange(m, diameter, wavelengthRange=(100,1600), nw=1000, l
wavelengths = np.logspace(np.log10(wavelengthRange[0]),np.log10(wavelengthRange[1]),nw)
else:
wavelengths = np.linspace(wavelengthRange[0],wavelengthRange[1],nw)
_qD = [MieQ(m,wavelength,diameter) for wavelength in wavelengths]
_qD = [AutoMieQ(m,wavelength,diameter) for wavelength in wavelengths]
elif type(m) in [np.ndarray,list,tuple] and len(wavelengthRange)==len(m):
wavelengths=wavelengthRange
_qD = [MieQ(emm,wavelength,diameter) for emm,wavelength in zip(m,wavelengths)]
Expand All @@ -373,7 +374,7 @@ def MieQ_withSizeParameterRange(m, xRange=(1,10), nx=1000, logX=False):
else:
xValues = list(np.linspace(xRange[0],xRange[1], nx))
dValues = [1000*x/np.pi for x in xValues]
_qD = [MieQ(m,1000,d) for d in dValues]
_qD = [AutoMieQ(m,1000,d) for d in dValues]
qext = np.array([q[0] for q in _qD])
qsca = np.array([q[1] for q in _qD])
qabs = np.array([q[2] for q in _qD])
Expand Down
2 changes: 1 addition & 1 deletion build/lib/PyMieScatt/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.6"
__version__ = "1.3.0"
Binary file removed dist/PyMieScatt-1.2.6-py3-none-any.whl
Binary file not shown.
Binary file removed dist/PyMieScatt-1.2.6.tar.gz
Binary file not shown.
Binary file added dist/PyMieScatt-1.3.0-py3-none-any.whl
Binary file not shown.
Binary file added dist/PyMieScatt-1.3.0.tar.gz
Binary file not shown.
33 changes: 30 additions & 3 deletions docs/forward.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,33 @@ Functions for single particles
'Qsca': 0.00011805645915412197,
'g': 0}


.. py:Function:: AutoMieQ(m, wavelength, diameter[, crossover=0.5, asDict=False])
Returns Mie efficencies of a spherical particle according to either :py:func`MieQ` or :py:func`RayleighMieQ` depending on the magnitude of the size parameter. Good for studying parameter ranges or size distributions.

**Parameters**

m : complex
The complex refractive index, with the convention *m = n+ik*.
wavelength : float
The wavelength of incident light, in nanometers.
diameter : float
The diameter of the particle, in nanometers.
crossover : float, optional
The size parameter that dictates where calculations switch from Rayleigh approximation to actual Mie.
asDict : bool, optional
If specified and set to True, returns the results as a dict.

**Returns**


qext, qsca, qabs, g, qpr, qback, qratio : float
The Mie efficencies described above.
q : dict
If asDict==True, :py:func:`RayleighMieQ` returns a dict of the above values with appropriate keys.


.. py:Function:: LowFrequencyMieQ(m, wavelength, diameter[, asDict=False])
Returns Mie efficencies of a spherical particle in the low-frequency regime (:math:`x=\pi\,d_p/\lambda \ll 1`) given refractive index **m**, **wavelength**, and **diameter**. Optionally returns the parameters as a dict when **asDict** is specified and set to True. Uses :py:func:`LowFrequencyMie_ab` to calculate a\ :sub:`n` and b\ :sub:`n`, and follows the same math as :py:func:`MieQ`.
Expand Down Expand Up @@ -211,7 +238,7 @@ Functions for single particles across various ranges

.. py:Function:: MieQ_withDiameterRange(m, wavelength[, diameterRange=(10,1000), nd=1000, logD=False])
Computes the Mie efficencies of particles across a diameter range using :py:func:`MieQ`.
Computes the Mie efficencies of particles across a diameter range using :py:func:`MieQ` or :py:func:`AutoMieQ`, depending on the size parameters.

**Parameters**

Expand All @@ -237,7 +264,7 @@ Functions for single particles across various ranges

.. py:Function:: MieQ_withWavelengthRange(m, diameter[, wavelengthRange=(100,1600), nw=1000, logW=False])
Computes the Mie efficencies of particles across a wavelength range using :py:func:`MieQ`. This function can optionally take a list, tuple, or numpy.ndarray for **m**. If your particles have a wavelength-dependent refractive index, you can study it by specifying **m** as list-like. When doing so, **m** must be the same size as **wavelengthRange**, which is also specified as list-like in this situation. Otherwise, the function will construct a range from **wavelengthRange[0]** to **wavelengthRange[1]** with **nw** entries.
Computes the Mie efficencies of particles across a wavelength range using :py:func:`MieQ` or :py:func:`AutoMieQ`, depending on the size parameters. This function can optionally take a list, tuple, or numpy.ndarray for **m**. If your particles have a wavelength-dependent refractive index, you can study it by specifying **m** as list-like. When doing so, **m** must be the same size as **wavelengthRange**, which is also specified as list-like in this situation. Otherwise, the function will construct a range from **wavelengthRange[0]** to **wavelengthRange[1]** with **nw** entries.

**Parameters**

Expand All @@ -263,7 +290,7 @@ Functions for single particles across various ranges

.. py:Function:: MieQ_withSizeParameterRange(m[, xRange=(1,10), nx=1000, logX=False])
Computes the Mie efficencies of particles across a size parameter range (\ :math:`x=\pi\,d_p/\lambda`\ ) using :py:func:`MieQ`.
Computes the Mie efficencies of particles across a size parameter range (\ :math:`x=\pi\,d_p/\lambda`\ ) using :py:func:`MieQ` or :py:func:`AutoMieQ`.

**Parameters**

Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can install PyMieScatt from `The Python Package Index (PyPI) <https://pypi.p
$ pip install PyMieScatt


or from `GitHub <https://github.com/bsumlin/PyMieScatt>`_. The current version is 1.2.6.
or from `GitHub <https://github.com/bsumlin/PyMieScatt>`_. The current version is 1.3.0.


.. toctree::
Expand All @@ -38,6 +38,7 @@ Documentation To-Do List

- Inverse Mie Theory functions
- More example scripts
- Revision history and update notes

PyMieScatt To-Do List
---------------------
Expand Down

0 comments on commit 35d6e43

Please sign in to comment.