miepython 3.0.2__tar.gz → 3.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. miepython-3.0.3/CITATION.cff +42 -0
  2. miepython-3.0.3/MANIFEST.in +8 -0
  3. miepython-3.0.3/PKG-INFO +225 -0
  4. miepython-3.0.3/README.rst +196 -0
  5. {miepython-3.0.2 → miepython-3.0.3}/miepython/__init__.py +11 -2
  6. {miepython-3.0.2 → miepython-3.0.3}/miepython/core.py +7 -8
  7. {miepython-3.0.2 → miepython-3.0.3}/miepython/mie_jit.py +6 -6
  8. {miepython-3.0.2 → miepython-3.0.3}/miepython/mie_nojit.py +4 -4
  9. {miepython-3.0.2 → miepython-3.0.3}/miepython/rayleigh.py +1 -2
  10. miepython-3.0.3/miepython.egg-info/PKG-INFO +225 -0
  11. {miepython-3.0.2 → miepython-3.0.3}/miepython.egg-info/SOURCES.txt +3 -9
  12. miepython-3.0.3/pyproject.toml +105 -0
  13. miepython-3.0.3/setup.cfg +4 -0
  14. miepython-3.0.3/tests/test_all_examples.py +19 -0
  15. miepython-3.0.3/tests/test_all_notebooks.py +61 -0
  16. {miepython-3.0.2 → miepython-3.0.3}/tests/test_nojit_D.py +1 -1
  17. miepython-3.0.3/tests/test_unpolarized_intensity.py +24 -0
  18. miepython-3.0.2/CITATION.cff +0 -11
  19. miepython-3.0.2/MANIFEST.in +0 -22
  20. miepython-3.0.2/PKG-INFO +0 -330
  21. miepython-3.0.2/README.rst +0 -299
  22. miepython-3.0.2/miepython/data/ag-Johnson.txt +0 -101
  23. miepython-3.0.2/miepython/examples/01_dielectric.py +0 -28
  24. miepython-3.0.2/miepython/examples/02_glass.py +0 -31
  25. miepython-3.0.2/miepython/examples/03_droplets.py +0 -35
  26. miepython-3.0.2/miepython/examples/04_gold.py +0 -207
  27. miepython-3.0.2/miepython.egg-info/PKG-INFO +0 -330
  28. miepython-3.0.2/pyproject.toml +0 -78
  29. miepython-3.0.2/requirements-dev.txt +0 -29
  30. miepython-3.0.2/requirements.txt +0 -6
  31. miepython-3.0.2/setup.cfg +0 -17
  32. miepython-3.0.2/setup.py +0 -38
  33. {miepython-3.0.2 → miepython-3.0.3}/CHANGELOG.rst +0 -0
  34. {miepython-3.0.2 → miepython-3.0.3}/LICENSE.txt +0 -0
  35. {miepython-3.0.2 → miepython-3.0.3}/miepython/bessel.py +0 -0
  36. {miepython-3.0.2 → miepython-3.0.3}/miepython/data/Johnson.txt +0 -0
  37. {miepython-3.0.2 → miepython-3.0.3}/miepython/data/segelstein81_index.txt +0 -0
  38. {miepython-3.0.2 → miepython-3.0.3}/miepython/field.py +0 -0
  39. {miepython-3.0.2 → miepython-3.0.3}/miepython/monte_carlo.py +0 -0
  40. {miepython-3.0.2 → miepython-3.0.3}/miepython/util.py +0 -0
  41. {miepython-3.0.2 → miepython-3.0.3}/miepython/vsh.py +0 -0
  42. {miepython-3.0.2 → miepython-3.0.3}/miepython.egg-info/dependency_links.txt +0 -0
  43. {miepython-3.0.2 → miepython-3.0.3}/miepython.egg-info/requires.txt +0 -0
  44. {miepython-3.0.2 → miepython-3.0.3}/miepython.egg-info/top_level.txt +0 -0
  45. {miepython-3.0.2 → miepython-3.0.3}/tests/test_bessel.py +0 -0
  46. {miepython-3.0.2 → miepython-3.0.3}/tests/test_field.py +0 -0
  47. {miepython-3.0.2 → miepython-3.0.3}/tests/test_jit.py +0 -0
  48. {miepython-3.0.2 → miepython-3.0.3}/tests/test_jit_D.py +0 -0
  49. {miepython-3.0.2 → miepython-3.0.3}/tests/test_jit_abcd.py +0 -0
  50. {miepython-3.0.2 → miepython-3.0.3}/tests/test_jit_speed.py +0 -0
  51. {miepython-3.0.2 → miepython-3.0.3}/tests/test_nojit.py +0 -0
  52. {miepython-3.0.2 → miepython-3.0.3}/tests/test_nojit_abcd.py +0 -0
  53. {miepython-3.0.2 → miepython-3.0.3}/tests/test_nojit_speed.py +0 -0
  54. {miepython-3.0.2 → miepython-3.0.3}/tests/test_rayleigh.py +0 -0
  55. {miepython-3.0.2 → miepython-3.0.3}/tests/test_vsh.py +0 -0
@@ -0,0 +1,42 @@
1
+ cff-version: 1.2.0
2
+ type: software
3
+ message: If you use this software, please cite it as below.
4
+ title: 'miepython: Pure python calculation of Mie scattering'
5
+ version: 3.0.3
6
+ doi: 10.5281/zenodo.7949264
7
+ date-released: '2026-01-02'
8
+ url: https://doi.org/10.5281/zenodo.7949264
9
+ repository-code: https://github.com/scottprahl/miepython
10
+ license: MIT
11
+ authors:
12
+ - family-names: Prahl
13
+ given-names: Scott
14
+ orcid: https://orcid.org/0000-0003-1468-6851
15
+ abstract: miepython provides a validated and efficient pure python implementation
16
+ of Mie scattering for spherical particles. It reproduces established reference
17
+ results (including Wiscombe's MIEV0) and is designed for scientific, educational,
18
+ and computational research applications in optics.
19
+ keywords:
20
+ - mie
21
+ - scattering
22
+ - rainbow
23
+ - droplet
24
+ - backscatter
25
+ - sphere
26
+ - nanoparticle
27
+ - cloud
28
+ - phase function
29
+ - efficiency
30
+ - rayleigh
31
+ - backscattering
32
+ preferred-citation:
33
+ type: software
34
+ title: 'miepython: Pure python calculation of Mie scattering'
35
+ year: 2026
36
+ version: 3.0.3
37
+ doi: 10.5281/zenodo.7949264
38
+ url: https://doi.org/10.5281/zenodo.7949264
39
+ authors:
40
+ - family-names: Prahl
41
+ given-names: Scott
42
+ orcid: https://orcid.org/0000-0003-1468-6851
@@ -0,0 +1,8 @@
1
+ # Core package files
2
+ include LICENSE.txt
3
+ include README.rst
4
+ include CHANGELOG.rst
5
+ include CITATION.cff
6
+
7
+ # Package data needed at runtime
8
+ include miepython/data/*.txt
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: miepython
3
+ Version: 3.0.3
4
+ Summary: Mie scattering of a plane wave by a sphere
5
+ Author-email: Scott Prahl <scott.prahl@oit.edu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/scottprahl/miepython
8
+ Project-URL: Documentation, https://miepython.readthedocs.io
9
+ Project-URL: Source, https://github.com/scottprahl/miepython
10
+ Project-URL: Tracker, https://github.com/scottprahl/miepython/issues
11
+ Project-URL: Changelog, https://github.com/scottprahl/miepython/blob/main/docs/CHANGELOG.rst
12
+ Keywords: mie,scattering,rainbow,droplet,backscatter,sphere,nanoparticle,cloud,phase function,efficiency,rayleigh,backscattering
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE.txt
24
+ Requires-Dist: numpy
25
+ Requires-Dist: matplotlib
26
+ Requires-Dist: numba
27
+ Requires-Dist: scipy
28
+ Dynamic: license-file
29
+
30
+ .. |pypi| image:: https://img.shields.io/pypi/v/miepython?color=68CA66
31
+ :target: https://pypi.org/project/miepython/
32
+ :alt: PyPI
33
+
34
+ .. |github| image:: https://img.shields.io/github/v/tag/scottprahl/miepython?label=github&color=68CA66
35
+ :target: https://github.com/scottprahl/miepython
36
+ :alt: GitHub
37
+
38
+ .. |conda| image:: https://img.shields.io/conda/vn/conda-forge/miepython?label=conda&color=68CA66
39
+ :target: https://github.com/conda-forge/miepython-feedstock
40
+ :alt: Conda
41
+
42
+ .. |doi| image:: https://zenodo.org/badge/99259684.svg
43
+ :target: https://zenodo.org/badge/latestdoi/99259684
44
+ :alt: DOI
45
+
46
+ .. |license| image:: https://img.shields.io/github/license/scottprahl/miepython?color=68CA66
47
+ :target: https://github.com/scottprahl/miepython/blob/master/LICENSE.txt
48
+ :alt: License
49
+
50
+ .. |test| image:: https://github.com/scottprahl/miepython/actions/workflows/test.yml/badge.svg
51
+ :target: https://github.com/scottprahl/miepython/actions/workflows/test.yml
52
+ :alt: Testing
53
+
54
+ .. |docs| image:: https://readthedocs.org/projects/miepython/badge?color=68CA66
55
+ :target: https://miepython.readthedocs.io
56
+ :alt: Docs
57
+
58
+ .. |downloads| image:: https://img.shields.io/pypi/dm/miepython?color=68CA66
59
+ :target: https://pypi.org/project/miepython/
60
+ :alt: Downloads
61
+
62
+ .. |lite| image:: https://img.shields.io/badge/try-JupyterLite-68CA66.svg
63
+ :target: https://scottprahl.github.io/miepython/
64
+ :alt: Try JupyterLite
65
+
66
+
67
+ miepython
68
+ =========
69
+
70
+ |pypi| |github| |conda| |doi|
71
+
72
+ |license| |test| |docs| |downloads|
73
+
74
+ |lite|
75
+
76
+ Mie scattering calculations in pure Python
77
+ ------------------------------------------
78
+
79
+ ``miepython`` provides a validated and efficient implementation of Mie scattering for spherical particles.
80
+ It reproduces established reference results (including Wiscombe's MIEV0) and is designed for scientific, educational, and computational research applications in optics.
81
+
82
+ The library implements the full Mie solution, including:
83
+
84
+ - extinction, scattering, and absorption efficiencies
85
+ - asymmetry parameter (scattering anisotropy)
86
+ - angle-resolved scattering intensities
87
+ - Mie expansion coefficients
88
+ - complex amplitude functions and Mueller matrices
89
+
90
+ The implementation is numerically stable for a wide range of size parameters and refractive indices, including lossy materials and high-index contrasts.
91
+
92
+ Immediate Use in the Browser
93
+ ----------------------------
94
+
95
+ The entire package can be used **immediately** in a browser — without installation — using the JupyterLite interface:
96
+
97
+ |lite|
98
+
99
+ This environment runs entirely client-side (Pyodide), and supports:
100
+
101
+ - interactive notebooks
102
+ - real-time plotting
103
+ - full access to ``miepython`` functions
104
+ - reproducible experiments (downloadable notebooks)
105
+
106
+ This makes it ideal for teaching, demonstrations, or quick exploratory calculations.
107
+
108
+ Installation
109
+ ------------
110
+
111
+ Install with pip:
112
+
113
+ .. code-block:: bash
114
+
115
+ pip install miepython
116
+
117
+ Or via conda:
118
+
119
+ .. code-block:: bash
120
+
121
+ conda install -c conda-forge miepython
122
+
123
+ Quick Start
124
+ -----------
125
+
126
+ A typical calculation is straightforward:
127
+
128
+ .. code-block:: python
129
+
130
+ import miepython as mie
131
+
132
+ m = 1.5 - 0.1j # refractive index
133
+ d = 100 # diameter (nm)
134
+ lambda0 = 314.15 # wavelength (nm)
135
+
136
+ qext, qsca, qback, g = mie.efficiencies(m, d, lambda0)
137
+
138
+ Documentation and Examples
139
+ --------------------------
140
+
141
+ The full documentation is available as:
142
+
143
+ Interactive documentation (JupyterLite):
144
+ |lite|
145
+
146
+ Static Jupyter notebooks on ReadTheDocs:
147
+ |docs|
148
+
149
+ Among other things the documentation discusses:
150
+
151
+ - **Mathematical formulation of Mie theory**
152
+ https://miepython.readthedocs.io/en/latest/01_theory.html
153
+
154
+ - **Normalization conventions and units**
155
+ https://miepython.readthedocs.io/en/latest/02_normalization.html
156
+
157
+ - **Numerical stability considerations**
158
+ https://miepython.readthedocs.io/en/latest/03_stability.html
159
+
160
+ - **Validation against MIEV0 and other reference implementations**
161
+ https://miepython.readthedocs.io/en/latest/04_validation.html
162
+
163
+ - **Guidelines for parameter choices and truncation order**
164
+ https://miepython.readthedocs.io/en/latest/05_truncation.html
165
+
166
+ - **Physical interpretation, resonances, and comparison plots**
167
+ https://miepython.readthedocs.io/en/latest/06_examples.html
168
+
169
+ Representative results simple examples:
170
+
171
+ https://github.com/scottprahl/miepython/tree/main/miepython/examples
172
+
173
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/01.svg
174
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/02.svg
175
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/03.svg
176
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/04.svg
177
+
178
+ Performance and Acceleration
179
+ ----------------------------
180
+
181
+ ``miepython`` supports optional Numba JIT compilation:
182
+
183
+ .. code-block:: python
184
+
185
+ import os
186
+ os.environ["MIEPYTHON_USE_JIT"] = "1" # must be set before import
187
+ import miepython
188
+
189
+ This can provide 10–50× speedups for large parameter sweeps or ensemble calculations.
190
+
191
+ Benchmark example (100,000 particles):
192
+
193
+ ============ ============ ==========
194
+ Version Time Speedup
195
+ ============ ============ ==========
196
+ Pure Python 4.00 s 1×
197
+ JIT Enabled 0.15 s 27×
198
+ ============ ============ ==========
199
+
200
+ Citation
201
+ --------
202
+
203
+ If you use ``laserbeamsize`` in academic, instructional, or applied technical work, please cite:
204
+
205
+ Prahl, S. (2026). *miepython: Pure python calculation of Mie scattering* (Version 3.0.3) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
206
+
207
+ BibTeX:
208
+
209
+ .. code-block:: bibtex
210
+
211
+ @software{prahl_miepython_2025,
212
+ author = {Scott Prahl},
213
+ title = {{miepython}: A Python library for Mie scattering calculations},
214
+ url = {https://github.com/scottprahl/miepython},
215
+ doi = {10.5281/zenodo.7949263},
216
+ year = {2026},
217
+ version = {3.0.3},
218
+ publisher = {Zenodo}
219
+ }
220
+
221
+ License
222
+ -------
223
+
224
+ ``miepython`` is released under the MIT License.
225
+
@@ -0,0 +1,196 @@
1
+ .. |pypi| image:: https://img.shields.io/pypi/v/miepython?color=68CA66
2
+ :target: https://pypi.org/project/miepython/
3
+ :alt: PyPI
4
+
5
+ .. |github| image:: https://img.shields.io/github/v/tag/scottprahl/miepython?label=github&color=68CA66
6
+ :target: https://github.com/scottprahl/miepython
7
+ :alt: GitHub
8
+
9
+ .. |conda| image:: https://img.shields.io/conda/vn/conda-forge/miepython?label=conda&color=68CA66
10
+ :target: https://github.com/conda-forge/miepython-feedstock
11
+ :alt: Conda
12
+
13
+ .. |doi| image:: https://zenodo.org/badge/99259684.svg
14
+ :target: https://zenodo.org/badge/latestdoi/99259684
15
+ :alt: DOI
16
+
17
+ .. |license| image:: https://img.shields.io/github/license/scottprahl/miepython?color=68CA66
18
+ :target: https://github.com/scottprahl/miepython/blob/master/LICENSE.txt
19
+ :alt: License
20
+
21
+ .. |test| image:: https://github.com/scottprahl/miepython/actions/workflows/test.yml/badge.svg
22
+ :target: https://github.com/scottprahl/miepython/actions/workflows/test.yml
23
+ :alt: Testing
24
+
25
+ .. |docs| image:: https://readthedocs.org/projects/miepython/badge?color=68CA66
26
+ :target: https://miepython.readthedocs.io
27
+ :alt: Docs
28
+
29
+ .. |downloads| image:: https://img.shields.io/pypi/dm/miepython?color=68CA66
30
+ :target: https://pypi.org/project/miepython/
31
+ :alt: Downloads
32
+
33
+ .. |lite| image:: https://img.shields.io/badge/try-JupyterLite-68CA66.svg
34
+ :target: https://scottprahl.github.io/miepython/
35
+ :alt: Try JupyterLite
36
+
37
+
38
+ miepython
39
+ =========
40
+
41
+ |pypi| |github| |conda| |doi|
42
+
43
+ |license| |test| |docs| |downloads|
44
+
45
+ |lite|
46
+
47
+ Mie scattering calculations in pure Python
48
+ ------------------------------------------
49
+
50
+ ``miepython`` provides a validated and efficient implementation of Mie scattering for spherical particles.
51
+ It reproduces established reference results (including Wiscombe's MIEV0) and is designed for scientific, educational, and computational research applications in optics.
52
+
53
+ The library implements the full Mie solution, including:
54
+
55
+ - extinction, scattering, and absorption efficiencies
56
+ - asymmetry parameter (scattering anisotropy)
57
+ - angle-resolved scattering intensities
58
+ - Mie expansion coefficients
59
+ - complex amplitude functions and Mueller matrices
60
+
61
+ The implementation is numerically stable for a wide range of size parameters and refractive indices, including lossy materials and high-index contrasts.
62
+
63
+ Immediate Use in the Browser
64
+ ----------------------------
65
+
66
+ The entire package can be used **immediately** in a browser — without installation — using the JupyterLite interface:
67
+
68
+ |lite|
69
+
70
+ This environment runs entirely client-side (Pyodide), and supports:
71
+
72
+ - interactive notebooks
73
+ - real-time plotting
74
+ - full access to ``miepython`` functions
75
+ - reproducible experiments (downloadable notebooks)
76
+
77
+ This makes it ideal for teaching, demonstrations, or quick exploratory calculations.
78
+
79
+ Installation
80
+ ------------
81
+
82
+ Install with pip:
83
+
84
+ .. code-block:: bash
85
+
86
+ pip install miepython
87
+
88
+ Or via conda:
89
+
90
+ .. code-block:: bash
91
+
92
+ conda install -c conda-forge miepython
93
+
94
+ Quick Start
95
+ -----------
96
+
97
+ A typical calculation is straightforward:
98
+
99
+ .. code-block:: python
100
+
101
+ import miepython as mie
102
+
103
+ m = 1.5 - 0.1j # refractive index
104
+ d = 100 # diameter (nm)
105
+ lambda0 = 314.15 # wavelength (nm)
106
+
107
+ qext, qsca, qback, g = mie.efficiencies(m, d, lambda0)
108
+
109
+ Documentation and Examples
110
+ --------------------------
111
+
112
+ The full documentation is available as:
113
+
114
+ Interactive documentation (JupyterLite):
115
+ |lite|
116
+
117
+ Static Jupyter notebooks on ReadTheDocs:
118
+ |docs|
119
+
120
+ Among other things the documentation discusses:
121
+
122
+ - **Mathematical formulation of Mie theory**
123
+ https://miepython.readthedocs.io/en/latest/01_theory.html
124
+
125
+ - **Normalization conventions and units**
126
+ https://miepython.readthedocs.io/en/latest/02_normalization.html
127
+
128
+ - **Numerical stability considerations**
129
+ https://miepython.readthedocs.io/en/latest/03_stability.html
130
+
131
+ - **Validation against MIEV0 and other reference implementations**
132
+ https://miepython.readthedocs.io/en/latest/04_validation.html
133
+
134
+ - **Guidelines for parameter choices and truncation order**
135
+ https://miepython.readthedocs.io/en/latest/05_truncation.html
136
+
137
+ - **Physical interpretation, resonances, and comparison plots**
138
+ https://miepython.readthedocs.io/en/latest/06_examples.html
139
+
140
+ Representative results simple examples:
141
+
142
+ https://github.com/scottprahl/miepython/tree/main/miepython/examples
143
+
144
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/01.svg
145
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/02.svg
146
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/03.svg
147
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/04.svg
148
+
149
+ Performance and Acceleration
150
+ ----------------------------
151
+
152
+ ``miepython`` supports optional Numba JIT compilation:
153
+
154
+ .. code-block:: python
155
+
156
+ import os
157
+ os.environ["MIEPYTHON_USE_JIT"] = "1" # must be set before import
158
+ import miepython
159
+
160
+ This can provide 10–50× speedups for large parameter sweeps or ensemble calculations.
161
+
162
+ Benchmark example (100,000 particles):
163
+
164
+ ============ ============ ==========
165
+ Version Time Speedup
166
+ ============ ============ ==========
167
+ Pure Python 4.00 s 1×
168
+ JIT Enabled 0.15 s 27×
169
+ ============ ============ ==========
170
+
171
+ Citation
172
+ --------
173
+
174
+ If you use ``laserbeamsize`` in academic, instructional, or applied technical work, please cite:
175
+
176
+ Prahl, S. (2026). *miepython: Pure python calculation of Mie scattering* (Version 3.0.3) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
177
+
178
+ BibTeX:
179
+
180
+ .. code-block:: bibtex
181
+
182
+ @software{prahl_miepython_2025,
183
+ author = {Scott Prahl},
184
+ title = {{miepython}: A Python library for Mie scattering calculations},
185
+ url = {https://github.com/scottprahl/miepython},
186
+ doi = {10.5281/zenodo.7949263},
187
+ year = {2026},
188
+ version = {3.0.3},
189
+ publisher = {Zenodo}
190
+ }
191
+
192
+ License
193
+ -------
194
+
195
+ ``miepython`` is released under the MIT License.
196
+
@@ -58,6 +58,9 @@ if USE_JIT:
58
58
  from .mie_jit import _pi_tau_nb as _pi_tau
59
59
  from .mie_jit import _D_calc_nb as _D_calc
60
60
  from .mie_jit import _S1_S2_nb as _S1_S2
61
+ from .mie_jit import _Lentz_Dn
62
+ from .mie_jit import _D_upwards
63
+ from .mie_jit import _D_downwards
61
64
  else:
62
65
  from .mie_nojit import _an_bn_py as an_bn
63
66
  from .mie_nojit import _cn_dn_py as cn_dn
@@ -67,6 +70,9 @@ else:
67
70
  from .mie_nojit import _pi_tau_py as _pi_tau
68
71
  from .mie_nojit import _D_calc_py as _D_calc
69
72
  from .mie_nojit import _S1_S2_py as _S1_S2
73
+ from .mie_nojit import _Lentz_Dn
74
+ from .mie_nojit import _D_upwards
75
+ from .mie_nojit import _D_downwards
70
76
 
71
77
  from .core import efficiencies, intensities, i_par, i_per, i_unpolarized
72
78
  from .core import efficiencies_mx, S1_S2, phase_matrix, coefficients
@@ -90,11 +96,14 @@ __all__ = (
90
96
  "_S1_S2",
91
97
  "_D_calc",
92
98
  "_pi_tau",
99
+ "_Lentz_Dn",
100
+ "_D_upwards",
101
+ "_D_downwards",
93
102
  )
94
103
 
95
- __version__ = "3.0.2"
104
+ __version__ = "3.0.3"
96
105
  __author__ = "Scott Prahl"
97
106
  __email__ = "scott.prahl@oit.edu"
98
- __copyright__ = "2017-25, Scott Prahl"
107
+ __copyright__ = "2017-26, Scott Prahl"
99
108
  __license__ = "MIT"
100
109
  __url__ = "https://github.com/scottprahl/miepython.git"
@@ -135,7 +135,7 @@ def coefficients(m, x, n_pole=0, internal=False):
135
135
  return np.array([a, b])
136
136
 
137
137
 
138
- def efficiencies_mx(m, x, n_pole=0, field="Electric"):
138
+ def efficiencies_mx(m, x, n_pole=0, e_field=True):
139
139
  """
140
140
  Computes scattering and extinction efficiencies for a spherical particle using Mie theory.
141
141
 
@@ -155,8 +155,8 @@ def efficiencies_mx(m, x, n_pole=0, field="Electric"):
155
155
  Multipole order to compute:
156
156
  - If 0 (default), computes contributions from all multipoles.
157
157
  - If non-zero, computes contributions from the specified multipole order.
158
- field (str):
159
- If "Electric" (default) If n_pole>0, then True value returns the electric
158
+ e_field (boolean):
159
+ If n_pole>0, then True value returns the electric
160
160
  multipole contribution otherwise the Magnetic field contribution
161
161
  Returns:
162
162
  tuple:
@@ -210,7 +210,7 @@ def efficiencies_mx(m, x, n_pole=0, field="Electric"):
210
210
  xlen = len(x)
211
211
 
212
212
  if mlen == 0 and xlen == 0:
213
- return single_sphere(m, x, n_pole)
213
+ return single_sphere(m, x, n_pole, e_field)
214
214
 
215
215
  if xlen > 0 and mlen > 0 and xlen != mlen:
216
216
  raise RuntimeError("m and x arrays to mie must be same length")
@@ -230,7 +230,7 @@ def efficiencies_mx(m, x, n_pole=0, field="Electric"):
230
230
  if xlen > 0:
231
231
  xx = x[i]
232
232
 
233
- qext[i], qsca[i], qback[i], g[i] = single_sphere(mm, xx, n_pole)
233
+ qext[i], qsca[i], qback[i], g[i] = single_sphere(mm, xx, n_pole, e_field)
234
234
 
235
235
  return qext, qsca, qback, g
236
236
 
@@ -260,7 +260,7 @@ def normalization_factor(m, x, norm_str):
260
260
  factor = x * np.sqrt(np.pi)
261
261
 
262
262
  else:
263
- qext, qsca, _, _ = single_sphere(m, x, 0)
263
+ qext, qsca, _, _ = single_sphere(m, x, 0, True)
264
264
 
265
265
  if norm in ["a", "albedo"]:
266
266
  factor = x * np.sqrt(np.pi * qext)
@@ -276,8 +276,7 @@ def normalization_factor(m, x, norm_str):
276
276
 
277
277
  if factor is None:
278
278
  raise ValueError(
279
- "normalization must be one of 'albedo' (default), 'one'"
280
- "'4pi', 'qext', 'qsca', 'bohren', or 'wiscombe'"
279
+ "normalization must be one of 'albedo' (default), 'one', '4pi', 'qext', 'qsca', 'bohren', or 'wiscombe'"
281
280
  )
282
281
  return factor
283
282
 
@@ -3,7 +3,7 @@ Low-level Mie calculations that use numba.
3
3
  """
4
4
 
5
5
  import numpy as np
6
- from numba import njit, complex128, float64, int64
6
+ from numba import njit, complex128, float64, int64, boolean
7
7
 
8
8
  __all__ = (
9
9
  "_D_calc_nb",
@@ -366,9 +366,7 @@ def _small_conducting_sphere_nb(_m, x):
366
366
  ahat2 = complex(0.0, x**2 / 30.0)
367
367
  bhat2 = complex(0.0, -(x**2) / 45.0)
368
368
 
369
- qsca = x**4 * (
370
- 6 * np.abs(ahat1) ** 2 + 6 * np.abs(bhat1) ** 2 + 10 * np.abs(ahat2) ** 2 + 10 * np.abs(bhat2) ** 2
371
- )
369
+ qsca = x**4 * (6 * np.abs(ahat1) ** 2 + 6 * np.abs(bhat1) ** 2 + 10 * np.abs(ahat2) ** 2 + 10 * np.abs(bhat2) ** 2)
372
370
  qext = qsca
373
371
  g = ahat1.imag * (ahat2.imag + bhat1.imag)
374
372
  g += bhat2.imag * (5.0 / 9.0 * ahat2.imag + bhat1.imag)
@@ -428,8 +426,8 @@ def _small_sphere_nb(m, x):
428
426
  return qext, qsca, qback, g
429
427
 
430
428
 
431
- @njit((complex128, float64, int64), cache=True, fastmath=True)
432
- def _single_sphere_nb(m, x, n_pole):
429
+ @njit((complex128, float64, int64, boolean), cache=True, fastmath=True)
430
+ def _single_sphere_nb(m, x, n_pole, e_field):
433
431
  """
434
432
  Calculate the efficiencies for a single sphere (both m and x are scalars).
435
433
 
@@ -445,6 +443,8 @@ def _single_sphere_nb(m, x, n_pole):
445
443
  qback: the backscatter efficiency
446
444
  g: the average cosine of the scattering phase function
447
445
  """
446
+ e_field = not e_field # unused
447
+
448
448
  # case when sphere matches its environment
449
449
  if abs(m.real - 1) <= 1e-8 and abs(m.imag) < 1e-8:
450
450
  return 0, 0, 0, 0
@@ -354,9 +354,7 @@ def _small_conducting_sphere_py(_m, x):
354
354
  ahat2 = complex(0.0, x**2 / 30.0)
355
355
  bhat2 = complex(0.0, -(x**2) / 45.0)
356
356
 
357
- qsca = x**4 * (
358
- 6 * np.abs(ahat1) ** 2 + 6 * np.abs(bhat1) ** 2 + 10 * np.abs(ahat2) ** 2 + 10 * np.abs(bhat2) ** 2
359
- )
357
+ qsca = x**4 * (6 * np.abs(ahat1) ** 2 + 6 * np.abs(bhat1) ** 2 + 10 * np.abs(ahat2) ** 2 + 10 * np.abs(bhat2) ** 2)
360
358
  qext = qsca
361
359
  g = ahat1.imag * (ahat2.imag + bhat1.imag)
362
360
  g += bhat2.imag * (5.0 / 9.0 * ahat2.imag + bhat1.imag)
@@ -415,7 +413,7 @@ def _small_sphere_py(m, x):
415
413
  return qext, qsca, qback, g
416
414
 
417
415
 
418
- def _single_sphere_py(m, x, n_pole):
416
+ def _single_sphere_py(m, x, n_pole, e_field):
419
417
  """
420
418
  Calculate the efficiencies for a sphere when both m and x are scalars.
421
419
 
@@ -431,6 +429,8 @@ def _single_sphere_py(m, x, n_pole):
431
429
  qback: the backscatter efficiency
432
430
  g: the average cosine of the scattering phase function
433
431
  """
432
+ e_field = not e_field # unused
433
+
434
434
  # case when sphere matches its environment
435
435
  if abs(m.real - 1) <= 1e-8 and abs(m.imag) < 1e-8:
436
436
  return 0, 0, 0, 0
@@ -101,8 +101,7 @@ def normalization_factor(m, x, norm_str):
101
101
 
102
102
  if factor is None:
103
103
  raise ValueError(
104
- "normalization must be one of 'albedo' (default), 'one'"
105
- "'4pi', 'qext', 'qsca', 'bohren', or 'wiscombe'"
104
+ "normalization must be one of 'albedo' (default), 'one', '4pi', 'qext', 'qsca', 'bohren', or 'wiscombe'"
106
105
  )
107
106
  return factor
108
107