Skip to content

Commit

Permalink
simplify mie_cdf and fix notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
scottprahl committed May 7, 2024
1 parent bb60c9e commit 43cefb5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
18 changes: 9 additions & 9 deletions docs/06_random_deviates.ipynb

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions miepython/miepython.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,8 @@ def mie_cdf(m, x, num):
cdf: array of cumulative distribution function values
"""
mu = np.linspace(-1, 1, num)
s1, s2 = mie_S1_S2(m, x, mu, norm='one')

s = (np.abs(s1)**2 + np.abs(s2)**2) / 2

cdf = np.zeros(num)
total = 0
for i in range(num):
# need the extra 2pi because scattering normalized over 4π steradians
total += s[i] * (2 / num)
cdf[i] = total

intensity_per_mu = i_unpolarized(m, x, mu, norm='4pi') / num
cdf = np.cumsum(intensity_per_mu)
return mu, cdf


Expand Down
13 changes: 2 additions & 11 deletions miepython/miepython_nojit.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,8 @@ def mie_cdf(m, x, num):
cdf: array of cumulative distribution function values
"""
mu = np.linspace(-1, 1, num)
s1, s2 = mie_S1_S2(m, x, mu, norm='one')

s = (np.abs(s1)**2 + np.abs(s2)**2) / 2

cdf = np.zeros(num)
total = 0
for i in range(num):
# need the extra 2pi because scattering normalized over 4π steradians
total += s[i] * 2 * np.pi * (2 / num)
cdf[i] = total

intensity_per_mu = i_unpolarized(m, x, mu, norm='4pi') / num
cdf = np.cumsum(intensity_per_mu)
return mu, cdf


Expand Down

0 comments on commit 43cefb5

Please sign in to comment.