miepython 2.5.3__tar.gz → 2.5.4__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 (38) hide show
  1. {miepython-2.5.3 → miepython-2.5.4}/CHANGELOG.rst +16 -0
  2. miepython-2.5.4/CITATION.cff +11 -0
  3. miepython-2.5.4/PKG-INFO +197 -0
  4. miepython-2.5.4/README.rst +169 -0
  5. {miepython-2.5.3 → miepython-2.5.4}/miepython/__init__.py +3 -3
  6. miepython-2.5.4/miepython/examples/01_dielectric.py +23 -0
  7. miepython-2.5.4/miepython/examples/02_glass.py +40 -0
  8. miepython-2.5.4/miepython/examples/03_droplets.py +44 -0
  9. {miepython-2.5.3 → miepython-2.5.4}/miepython/examples/04_gold.py +10 -15
  10. {miepython-2.5.3 → miepython-2.5.4}/miepython/miepython.py +106 -174
  11. {miepython-2.5.3 → miepython-2.5.4}/miepython/miepython_nojit.py +79 -142
  12. miepython-2.5.4/miepython.egg-info/PKG-INFO +197 -0
  13. {miepython-2.5.3 → miepython-2.5.4}/miepython.egg-info/SOURCES.txt +1 -4
  14. miepython-2.5.4/pyproject.toml +34 -0
  15. {miepython-2.5.3 → miepython-2.5.4}/requirements-dev.txt +2 -0
  16. {miepython-2.5.3 → miepython-2.5.4}/requirements.txt +2 -1
  17. {miepython-2.5.3 → miepython-2.5.4}/setup.cfg +4 -3
  18. {miepython-2.5.3 → miepython-2.5.4}/setup.py +2 -0
  19. miepython-2.5.3/tests/test_jit.py → miepython-2.5.4/tests/test_mie.py +208 -186
  20. miepython-2.5.3/.github/workflows/test.yml +0 -33
  21. miepython-2.5.3/.gitignore +0 -13
  22. miepython-2.5.3/CITATION.cff +0 -10
  23. miepython-2.5.3/PKG-INFO +0 -111
  24. miepython-2.5.3/README.rst +0 -89
  25. miepython-2.5.3/miepython/examples/01_dielectric.py +0 -28
  26. miepython-2.5.3/miepython/examples/02_glass.py +0 -29
  27. miepython-2.5.3/miepython/examples/03_droplets.py +0 -32
  28. miepython-2.5.3/miepython.egg-info/PKG-INFO +0 -111
  29. miepython-2.5.3/pyproject.toml +0 -9
  30. miepython-2.5.3/tests/test_nojit.py +0 -633
  31. {miepython-2.5.3 → miepython-2.5.4}/LICENSE.txt +0 -0
  32. {miepython-2.5.3 → miepython-2.5.4}/MANIFEST.in +0 -0
  33. {miepython-2.5.3 → miepython-2.5.4}/miepython/data/Johnson.txt +0 -0
  34. {miepython-2.5.3 → miepython-2.5.4}/miepython/data/ag-Johnson.txt +0 -0
  35. {miepython-2.5.3 → miepython-2.5.4}/miepython/data/segelstein81_index.txt +0 -0
  36. {miepython-2.5.3 → miepython-2.5.4}/miepython.egg-info/dependency_links.txt +0 -0
  37. {miepython-2.5.3 → miepython-2.5.4}/miepython.egg-info/requires.txt +0 -0
  38. {miepython-2.5.3 → miepython-2.5.4}/miepython.egg-info/top_level.txt +0 -0
@@ -1,6 +1,22 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 2.5.4 (5/7/2024)
5
+ --------------------
6
+ * document normalization in docstrings
7
+ * add version and year to CITATION.cff
8
+ * remove 'v' from version numbers
9
+ * add github script and workflow to auto-update CITATION.cff
10
+ * add conda badge to readme
11
+ * clean up README.rst
12
+ * use svg images
13
+ * use a single tests/test_mie for jit and non-jit tests
14
+ * support ruff
15
+ * test python versions 3.7 to 3.12
16
+ * fix badges
17
+ * remove unused functions
18
+ * fix zenodo link
19
+
4
20
  v2.5.3 (8/5/2023)
5
21
  -------------------
6
22
  * conda-forge fails because test files are not included
@@ -0,0 +1,11 @@
1
+ authors:
2
+ - family-names: Prahl
3
+ given-names: Scott
4
+ orcid: https://orcid.org/0000-0003-1468-6851
5
+ cff-version: 1.2.0
6
+ date-released: '2023-08-05'
7
+ doi: 10.5281/zenodo.7949263
8
+ message: If you use this software, please cite it as below.
9
+ title: 'miepython: Pure python calculation of Mie scattering'
10
+ url: https://doi.org/10.5281/zenodo.7949263
11
+ version: v2.5.3
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.1
2
+ Name: miepython
3
+ Version: 2.5.4
4
+ Summary: Mie scattering of a plane wave by a sphere
5
+ Home-page: https://github.com/scottprahl/miepython
6
+ Author: Scott Prahl
7
+ Author-email: scott.prahl@oit.edu
8
+ License: MIT
9
+ Keywords: mie,scattering,rainbow,droplet,backscatter,sphere,nanoparticle,sphere,cloud,phase function,efficiency,rayleigh,backscattering
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Topic :: Scientific/Engineering :: Physics
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.7
23
+ Description-Content-Type: text/x-rst
24
+ License-File: LICENSE.txt
25
+ Requires-Dist: numpy
26
+ Requires-Dist: matplotlib
27
+ Requires-Dist: numba
28
+
29
+ .. |pypi-badge| image:: https://img.shields.io/pypi/v/miepython?color=68CA66
30
+ :target: https://pypi.org/project/miepython/
31
+ :alt: pypi
32
+
33
+ .. |github-badge| image:: https://img.shields.io/github/v/tag/scottprahl/miepython?label=github&color=68CA66
34
+ :target: https://github.com/scottprahl/miepython
35
+ :alt: github
36
+
37
+ .. |conda-badge| image:: https://img.shields.io/conda/vn/conda-forge/miepython?label=conda&color=68CA66
38
+ :target: https://github.com/conda-forge/miepython-feedstock
39
+ :alt: conda
40
+
41
+ .. |doi-badge| image:: https://zenodo.org/badge/99259684.svg
42
+ :target: https://zenodo.org/badge/latestdoi/99259684
43
+ :alt: doi
44
+
45
+ .. |license-badge| image:: https://img.shields.io/github/license/scottprahl/miepython?color=68CA66
46
+ :target: https://github.com/scottprahl/miepython/blob/master/LICENSE.txt
47
+ :alt: License
48
+
49
+ .. |testing-badge| image:: https://github.com/scottprahl/miepython/actions/workflows/test.yml/badge.svg
50
+ :target: https://github.com/scottprahl/miepython/actions/workflows/test.yml
51
+ :alt: Testing
52
+
53
+ .. |docs-badge| image:: https://readthedocs.org/projects/miepython/badge?color=68CA66
54
+ :target: https://miepython.readthedocs.io
55
+ :alt: Docs
56
+
57
+ .. |downloads-badge| image:: https://img.shields.io/pypi/dm/miepython?color=68CA66
58
+ :target: https://pypi.org/project/miepython/
59
+ :alt: Downloads
60
+
61
+ miepython
62
+ =========
63
+
64
+ by Scott Prahl
65
+
66
+ |pypi-badge| |github-badge| |conda-badge| |doi-badge|
67
+
68
+ |license-badge| |testing-badge| |docs-badge| |downloads-badge|
69
+
70
+
71
+ ``miepython`` is a pure Python module to calculate light scattering for
72
+ non-absorbing, partially-absorbing, or perfectly-conducting spheres. Mie
73
+ theory is used, following `the procedure described by Wiscombe
74
+ <http://opensky.ucar.edu/islandora/object/technotes:232>`_. This code has
75
+ been validated against his work.
76
+
77
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/mie-diagram2.svg
78
+ :width: 700px
79
+ :alt: scattering diagram
80
+
81
+ This code provides functions for calculating the extinction efficiency,
82
+ scattering efficiency, backscattering, and scattering asymmetry.
83
+ Moreover, a set of angles can be given to calculate the scattering at various
84
+ angles for a sphere.
85
+
86
+ When comparing different Mie scattering codes, make sure that you're
87
+ aware of the conventions used by each code. ``miepython`` makes the
88
+ following assumptions
89
+
90
+ * the imaginary part of the complex index of refraction for absorbing spheres is *negative*.
91
+
92
+ * the scattering phase function is normalized so it equals the *single scattering albedo* when integrated over 4π steradians by default. This normalization can be changed (see the normalization notebook for details).
93
+
94
+ This code provides functions for calculating the extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry. Moreover, a set of angles can be given to calculate the scattering for a sphere at each of those
95
+ angles.
96
+
97
+ Full documentation at <https://miepython.readthedocs.io>
98
+
99
+ Pay Attention!
100
+ --------------
101
+
102
+ When comparing different Mie scattering codes, make sure that you're aware of the conventions used by each code. ``miepython`` makes the following assumptions
103
+
104
+ #. the imaginary part of the complex index of refraction for absorbing spheres is *negative*.
105
+
106
+ #. the scattering phase function is normalized so it equals the *single scattering albedo* when integrated over 4π steradians. As of version 2.3, this can be changed.
107
+
108
+
109
+ Installation
110
+ ---------------
111
+
112
+ Use ``pip``::
113
+
114
+ pip install miepython
115
+
116
+ or ``conda``::
117
+
118
+ conda install -c conda-forge miepython
119
+
120
+ Or `run this code in the cloud using Google Collaboratory <https://colab.research.google.com/github/scottprahl/miepython/blob/master>`_ by selecting the Jupyter notebook that interests you.
121
+
122
+ Usage for those that don't do Jupyter
123
+ --------------------------------------
124
+
125
+ Basic Mie Calculations
126
+ ^^^^^^^^^^^^^^^^^^^^^^^
127
+
128
+ from miepython import mie
129
+
130
+ complex_refractive_index = 1.5-1j # convention is negative imaginary part
131
+ size_parameter = 1 # 2𝜋(radius)/λ
132
+ qext, qsca, qback, g = mie(complex_refractive_index, size_parameter)
133
+
134
+ print("The extinction efficiency is %.3f" % qext)
135
+ print("The scattering efficiency is %.3f" % qsca)
136
+ print("The backscatter efficiency is %.3f" % qback)
137
+ print("The scattering anisotropy is %.3f" % g)
138
+
139
+ should produce::
140
+
141
+ The extinction efficiency is 2.336
142
+ The scattering efficiency is 0.663
143
+ The backscatter efficiency is 0.573
144
+ The scattering anisotropy is 0.192
145
+
146
+
147
+ Simple Dielectric
148
+ ^^^^^^^^^^^^^^^^^^
149
+
150
+ The script `01_dielectric.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/01_dielectric.py>`_
151
+
152
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/01_plot.svg
153
+
154
+ Glass Spheres
155
+ ^^^^^^^^^^^^^^
156
+
157
+ The script `02_glass.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/02_glass.py>`_
158
+
159
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/02_plot.svg
160
+
161
+ Water Droplets
162
+ ^^^^^^^^^^^^^^^
163
+
164
+ The script `03_droplets.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/03_droplets.py>`_
165
+
166
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/03_plot.svg
167
+
168
+ Small Gold Spheres
169
+ ^^^^^^^^^^^^^^^^^^^
170
+
171
+ The script `04_gold.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/04_gold.py>`_
172
+
173
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/04_plot.svg
174
+
175
+
176
+ Usage for those that use Jupyter
177
+ ---------------------------------
178
+
179
+ All the Jupyter notebooks are available in the docs directory and they are all viewable at <https://miepython.readthedocs.io>
180
+
181
+
182
+ Script Examples for those that don't do Jupyter
183
+ -----------------------------------------------
184
+
185
+ All the Jupyter notebooks are in the docs directory and shown at <https://miepython.readthedocs.io>
186
+
187
+ You can also use a Jupyter notebook immediately (well, you do have wait a bit for everything to get uploaded) by clicking the Google Colaboratory button below
188
+
189
+ .. image:: https://colab.research.google.com/assets/colab-badge.svg
190
+ :target: https://colab.research.google.com/github/scottprahl/miepython/blob/master
191
+ :alt: Colab
192
+
193
+
194
+ License
195
+ -------
196
+
197
+ ``miepython`` is licensed under the terms of the MIT license.
@@ -0,0 +1,169 @@
1
+ .. |pypi-badge| image:: https://img.shields.io/pypi/v/miepython?color=68CA66
2
+ :target: https://pypi.org/project/miepython/
3
+ :alt: pypi
4
+
5
+ .. |github-badge| 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-badge| 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-badge| image:: https://zenodo.org/badge/99259684.svg
14
+ :target: https://zenodo.org/badge/latestdoi/99259684
15
+ :alt: doi
16
+
17
+ .. |license-badge| 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
+ .. |testing-badge| 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-badge| image:: https://readthedocs.org/projects/miepython/badge?color=68CA66
26
+ :target: https://miepython.readthedocs.io
27
+ :alt: Docs
28
+
29
+ .. |downloads-badge| image:: https://img.shields.io/pypi/dm/miepython?color=68CA66
30
+ :target: https://pypi.org/project/miepython/
31
+ :alt: Downloads
32
+
33
+ miepython
34
+ =========
35
+
36
+ by Scott Prahl
37
+
38
+ |pypi-badge| |github-badge| |conda-badge| |doi-badge|
39
+
40
+ |license-badge| |testing-badge| |docs-badge| |downloads-badge|
41
+
42
+
43
+ ``miepython`` is a pure Python module to calculate light scattering for
44
+ non-absorbing, partially-absorbing, or perfectly-conducting spheres. Mie
45
+ theory is used, following `the procedure described by Wiscombe
46
+ <http://opensky.ucar.edu/islandora/object/technotes:232>`_. This code has
47
+ been validated against his work.
48
+
49
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/mie-diagram2.svg
50
+ :width: 700px
51
+ :alt: scattering diagram
52
+
53
+ This code provides functions for calculating the extinction efficiency,
54
+ scattering efficiency, backscattering, and scattering asymmetry.
55
+ Moreover, a set of angles can be given to calculate the scattering at various
56
+ angles for a sphere.
57
+
58
+ When comparing different Mie scattering codes, make sure that you're
59
+ aware of the conventions used by each code. ``miepython`` makes the
60
+ following assumptions
61
+
62
+ * the imaginary part of the complex index of refraction for absorbing spheres is *negative*.
63
+
64
+ * the scattering phase function is normalized so it equals the *single scattering albedo* when integrated over 4π steradians by default. This normalization can be changed (see the normalization notebook for details).
65
+
66
+ This code provides functions for calculating the extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry. Moreover, a set of angles can be given to calculate the scattering for a sphere at each of those
67
+ angles.
68
+
69
+ Full documentation at <https://miepython.readthedocs.io>
70
+
71
+ Pay Attention!
72
+ --------------
73
+
74
+ When comparing different Mie scattering codes, make sure that you're aware of the conventions used by each code. ``miepython`` makes the following assumptions
75
+
76
+ #. the imaginary part of the complex index of refraction for absorbing spheres is *negative*.
77
+
78
+ #. the scattering phase function is normalized so it equals the *single scattering albedo* when integrated over 4π steradians. As of version 2.3, this can be changed.
79
+
80
+
81
+ Installation
82
+ ---------------
83
+
84
+ Use ``pip``::
85
+
86
+ pip install miepython
87
+
88
+ or ``conda``::
89
+
90
+ conda install -c conda-forge miepython
91
+
92
+ Or `run this code in the cloud using Google Collaboratory <https://colab.research.google.com/github/scottprahl/miepython/blob/master>`_ by selecting the Jupyter notebook that interests you.
93
+
94
+ Usage for those that don't do Jupyter
95
+ --------------------------------------
96
+
97
+ Basic Mie Calculations
98
+ ^^^^^^^^^^^^^^^^^^^^^^^
99
+
100
+ from miepython import mie
101
+
102
+ complex_refractive_index = 1.5-1j # convention is negative imaginary part
103
+ size_parameter = 1 # 2𝜋(radius)/λ
104
+ qext, qsca, qback, g = mie(complex_refractive_index, size_parameter)
105
+
106
+ print("The extinction efficiency is %.3f" % qext)
107
+ print("The scattering efficiency is %.3f" % qsca)
108
+ print("The backscatter efficiency is %.3f" % qback)
109
+ print("The scattering anisotropy is %.3f" % g)
110
+
111
+ should produce::
112
+
113
+ The extinction efficiency is 2.336
114
+ The scattering efficiency is 0.663
115
+ The backscatter efficiency is 0.573
116
+ The scattering anisotropy is 0.192
117
+
118
+
119
+ Simple Dielectric
120
+ ^^^^^^^^^^^^^^^^^^
121
+
122
+ The script `01_dielectric.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/01_dielectric.py>`_
123
+
124
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/01_plot.svg
125
+
126
+ Glass Spheres
127
+ ^^^^^^^^^^^^^^
128
+
129
+ The script `02_glass.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/02_glass.py>`_
130
+
131
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/02_plot.svg
132
+
133
+ Water Droplets
134
+ ^^^^^^^^^^^^^^^
135
+
136
+ The script `03_droplets.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/03_droplets.py>`_
137
+
138
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/03_plot.svg
139
+
140
+ Small Gold Spheres
141
+ ^^^^^^^^^^^^^^^^^^^
142
+
143
+ The script `04_gold.py <https://raw.githubusercontent.com/scottprahl/miepython/master/miepython/examples/04_gold.py>`_
144
+
145
+ .. image:: https://raw.githubusercontent.com/scottprahl/miepython/master/docs/04_plot.svg
146
+
147
+
148
+ Usage for those that use Jupyter
149
+ ---------------------------------
150
+
151
+ All the Jupyter notebooks are available in the docs directory and they are all viewable at <https://miepython.readthedocs.io>
152
+
153
+
154
+ Script Examples for those that don't do Jupyter
155
+ -----------------------------------------------
156
+
157
+ All the Jupyter notebooks are in the docs directory and shown at <https://miepython.readthedocs.io>
158
+
159
+ You can also use a Jupyter notebook immediately (well, you do have wait a bit for everything to get uploaded) by clicking the Google Colaboratory button below
160
+
161
+ .. image:: https://colab.research.google.com/assets/colab-badge.svg
162
+ :target: https://colab.research.google.com/github/scottprahl/miepython/blob/master
163
+ :alt: Colab
164
+
165
+
166
+ License
167
+ -------
168
+
169
+ ``miepython`` is licensed under the terms of the MIT license.
@@ -42,11 +42,11 @@ The scattering matrix
42
42
  miepython.mie_phase_matrix(m, x, mu)
43
43
 
44
44
  """
45
- __version__ = '2.5.3'
45
+ __version__ = '2.5.4'
46
46
  __author__ = 'Scott Prahl'
47
47
  __email__ = 'scott.prahl@oit.edu'
48
- __copyright__ = 'Copyright 2017-23, Scott Prahl'
48
+ __copyright__ = '2017-24, Scott Prahl'
49
49
  __license__ = 'MIT'
50
- __url__ = 'https://github.com/scottprahl/miepython.git'
50
+ __url__ = 'https://github.com/scottprahl/miepython'
51
51
 
52
52
  from .miepython import *
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Plot the extinction efficiency as a function of particle size."""
4
+
5
+ import numpy as np
6
+ import matplotlib.pyplot as plt
7
+ import miepython
8
+
9
+ x = np.linspace(0.1, 100, 1000)
10
+
11
+ plt.figure(figsize=(8, 4.5))
12
+ qext, qsca, qback, g = miepython.mie(1.5, x)
13
+ plt.plot(x, qext, color='red', label="$n=1.5$")
14
+
15
+ qext, qsca, qback, g = miepython.mie(1.5 - 0.1j, x)
16
+ plt.plot(x, qext, color='blue', label="$n=1.5-0.1j$")
17
+
18
+ plt.title("Absorbing and Non-absorbing Spheres")
19
+ plt.xlabel("Size Parameter [–]")
20
+ plt.ylabel("Extinction Efficiency $Q_{ext}$ [–]")
21
+ plt.legend()
22
+ # plt.savefig('../../docs/01_plot.svg')
23
+ plt.show()
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Plot the scattering efficiency for 4 micron glass spheres."""
4
+ import numpy as np
5
+ import matplotlib.pyplot as plt
6
+ import miepython
7
+
8
+
9
+ def n_bk7(wavelength):
10
+ """
11
+ Refractive index of BK7 glass at a wavelength.
12
+
13
+ Equation is from https://refractiveindex.info/?shelf=glass&book=BK7&page=SCHOTT
14
+
15
+ Args:
16
+ wavelength: wavelength in microns
17
+ Returns:
18
+ index of refraction
19
+ """
20
+ m_squared = 1 + 1.03961212 / (1 - 0.00600069867 / lambda0**2)
21
+ m_squared += 0.231792344 / (1 - 0.0200179144 / lambda0**2)
22
+ m_squared += 1.01046945 / (1 - 103.560653 / lambda0**2)
23
+ refractive_index = np.sqrt(m_squared)
24
+ return refractive_index
25
+
26
+
27
+ radius = 2 # in microns
28
+ lambda0 = np.linspace(0.2, 1.2, 1000) # also in microns
29
+ x = 2 * np.pi * radius / lambda0
30
+ m = n_bk7(lambda0)
31
+
32
+ plt.figure(figsize=(8, 4.5))
33
+ qext, qsca, qback, g = miepython.mie(m, x)
34
+ plt.plot(lambda0 * 1000, qsca)
35
+
36
+ plt.title("4µm diameter BK7 glass spheres")
37
+ plt.xlabel("Wavelength [nm]")
38
+ plt.ylabel("Scattering Efficiency [–]")
39
+ # plt.savefig('../../docs/02_plot.svg')
40
+ plt.show()
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Plot the scattering cross section for 1 micron water droplets."""
4
+ import numpy as np
5
+ import matplotlib.pyplot as plt
6
+ import miepython
7
+
8
+
9
+ def n_water(wavelength):
10
+ """
11
+ Refractive index of water at wavelength.
12
+
13
+ Equation is from https://refractiveindex.info/?shelf=main&book=H2O&page=Daimon - 24.0C
14
+
15
+ Args:
16
+ wavelength: wavelength in microns
17
+ Returns:
18
+ index of refraction
19
+ """
20
+ m_squared = 1.0
21
+ m_squared += 5.666959820E-1 / (1.0 - 5.084151894E-3 / wavelength**2)
22
+ m_squared += 1.731900098E-1 / (1.0 - 1.818488474E-2 / wavelength**2)
23
+ m_squared += 2.095951857E-2 / (1.0 - 2.625439472E-2 / wavelength**2)
24
+ m_squared += 1.125228406E-1 / (1.0 - 1.073842352E1 / wavelength**2)
25
+ refractive_index = np.sqrt(m_squared)
26
+ return refractive_index
27
+
28
+
29
+ diameter = 1 # microns
30
+ radius = diameter / 2 # microns
31
+ num = 200 # points to plot
32
+ lambda_range = np.linspace(0.2, 1.2, num)
33
+ ref_index = n_water(lambda_range)
34
+ x = 2 * np.pi * radius / lambda_range
35
+
36
+ qext, qsca, qback, g = miepython.mie(ref_index, x)
37
+
38
+ plt.figure(figsize=(8, 4.5))
39
+ plt.plot(lambda_range * 1000, qsca)
40
+ plt.title("%.2f µm Diameter Water Droplets" % diameter)
41
+ plt.xlabel("Wavelength [nm]")
42
+ plt.ylabel("Scattering Cross Section [µm²]")
43
+ # plt.savefig('../../docs/03_plot.svg')
44
+ plt.show()
@@ -1,10 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
- """
4
- Plot the scattering cross section for 100nm gold spheres.
5
-
6
- The resulting graph is as a function of wavelength.
7
- """
3
+ """Plot the scattering cross section for 100nm gold spheres."""
8
4
 
9
5
  import numpy as np
10
6
  import matplotlib.pyplot as plt
@@ -42,25 +38,24 @@ qext, qsca, qback, g = miepython.mie(m, x)
42
38
  sca_cross_section = qsca * cross_section_area
43
39
  abs_cross_section = (qext - qsca) * cross_section_area
44
40
 
45
- plt.subplots(3, 1, figsize=(9, 9))
41
+ plt.subplots(3, 1, figsize=(8, 8))
46
42
  plt.subplot(311)
47
- plt.plot(ref_lam * 1000, ref_n, 'ob')
48
- plt.plot(ref_lam * 1000, -ref_k, 'sr')
43
+ plt.plot(ref_lam * 1000, ref_n, 'ob', markersize=2)
44
+ plt.plot(ref_lam * 1000, -ref_k, 'sr', markersize=2)
49
45
  plt.title("Gold Spheres 200nm diameter")
50
- plt.xticks([])
51
46
  plt.text(700, 1, "real refractive index", color='blue')
52
47
  plt.text(1100, -6, "imaginary refractive index", color='red')
53
48
 
54
49
  plt.subplot(312)
55
- plt.plot(ref_lam * 1000, 1000 / mu_a, 'ob')
50
+ plt.plot(ref_lam * 1000, 1000 / mu_a, 'ob', markersize=2)
56
51
  plt.ylabel("Absorption Depth [nm]")
57
52
 
58
53
  plt.subplot(313)
59
- plt.plot(ref_lam * 1000, abs_cross_section, 'ob')
60
- plt.plot(ref_lam * 1000, sca_cross_section, 'sr')
54
+ plt.plot(ref_lam * 1000, abs_cross_section, 'ob', markersize=2)
55
+ plt.plot(ref_lam * 1000, sca_cross_section, 'sr', markersize=2)
61
56
  plt.xlabel("Wavelength (nm)")
62
- plt.ylabel("Cross Section (µm²)")
57
+ plt.ylabel("Cross Section [µm²]")
63
58
  plt.text(700, 0.01, "absorption", color='blue')
64
59
  plt.text(750, 0.1, "scattering", color='red')
65
- plt.savefig("04_plot.png")
66
- # plt.show()
60
+ # plt.savefig("../../docs/04_plot.svg")
61
+ plt.show()