Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revised import statement for scipy.integrate.trapz #26

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion PyMieScatt/Inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from matplotlib.contour import QuadContourSet
from matplotlib.collections import LineCollection
from scipy.ndimage import zoom
from scipy.integrate import trapz
try:
from scipy.integrate import trapz
except ImportError:
from scipy.integrate import trapezoid as trapz
from shapely import geometry

def coerceDType(d):
Expand Down
5 changes: 4 additions & 1 deletion PyMieScatt/Mie.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# http://pymiescatt.readthedocs.io/en/latest/forward.html
import numpy as np
from scipy.special import jv, yv
from scipy.integrate import trapz
try:
from scipy.integrate import trapz
except ImportError:
from scipy.integrate import trapezoid as trapz
import warnings

def coerceDType(d):
Expand Down
5 changes: 4 additions & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ Recently, a colleague needed to know how much light a distribution of salt aeros
import PyMieScatt as ps # import PyMieScatt and abbreviate as ps
import matplotlib.pyplot as plt # import standard plotting library and abbreviate as plt
import numpy as np # import numpy and abbreviate as np
from scipy.integrate import trapz # import a single function for integration using trapezoidal rule
try:
from scipy.integrate import trapz # import a single function for integration using trapezoidal rule
except ImportError:
from scipy.integrate import trapezoid as trapz # for scipy>=1.14.0

m = 1.536 # refractive index of NaCl
wavelength = 405 # replace with the laser wavelength (nm)
Expand Down
4 changes: 2 additions & 2 deletions docs/forward.rst
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ There is an important distinction in how the size distribution is reported from

.. py:Function:: Mie_SD(m, wavelength, sizeDistributionDiameterBins, sizeDistribution[, nMedium=1.0, SMPS=True, asDict=False])

Returns Mie coefficients β\ :sub:`ext`, β\ :sub:`sca`, β\ :sub:`abs`, G, β\ :sub:`pr`, β\ :sub:`back`, β\ :sub:`ratio`. Uses `scipy.integrate.trapz <https://docs.scipy.org/doc/scipy-0.10.1/reference/generated/scipy.integrate.trapz.html>`_ to compute the integral, which can introduce errors if your distribution is too sparse. Best used with a continuous, compactly-supported distribution.
Returns Mie coefficients β\ :sub:`ext`, β\ :sub:`sca`, β\ :sub:`abs`, G, β\ :sub:`pr`, β\ :sub:`back`, β\ :sub:`ratio`. Uses `scipy.integrate.trapz <https://docs.scipy.org/doc/scipy-0.10.1/reference/generated/scipy.integrate.trapz.html>`_ (or `scipy.integrate.trapezoid <https://docs.scipy.org/doc/scipy-1.14.0/reference/generated/scipy.integrate.trapezoid.html>`_ )to compute the integral, which can introduce errors if your distribution is too sparse. Best used with a continuous, compactly-supported distribution.

**Parameters**

Expand Down Expand Up @@ -398,7 +398,7 @@ There is an important distinction in how the size distribution is reported from

.. py:Function:: Mie_Lognormal(m, wavelength, geoStdDev, geoMean, numberOfParticles[, nMedium=1.0, numberOfBins=1000, lower=1, upper=1000, gamma=[1], returnDistribution=False, decomposeMultimodal=False, asDict=False])

Returns Mie coefficients :math:`\beta_{ext}`, :math:`\beta_{sca}`, :math:`\beta_{abs}`, :math:`G`, :math:`\beta_{pr}`, :math:`\beta_{back}`, and :math:`\beta_{ratio}`, integrated over a mathematically-generated k-modal lognormal particle number distribution. Uses `scipy.integrate.trapz <https://docs.scipy.org/doc/scipy-0.10.1/reference/generated/scipy.integrate.trapz.html>`_ to compute the integral.
Returns Mie coefficients :math:`\beta_{ext}`, :math:`\beta_{sca}`, :math:`\beta_{abs}`, :math:`G`, :math:`\beta_{pr}`, :math:`\beta_{back}`, and :math:`\beta_{ratio}`, integrated over a mathematically-generated k-modal lognormal particle number distribution. Uses `scipy.integrate.trapz <https://docs.scipy.org/doc/scipy-0.10.1/reference/generated/scipy.integrate.trapz.html>`_ (or `scipy.integrate.trapezoid <https://docs.scipy.org/doc/scipy-1.14.0/reference/generated/scipy.integrate.trapezoid.html>`_) to compute the integral.

The general form of a k-modal lognormal distribution is given by:

Expand Down