miepython 3.3.0__tar.gz → 3.4.0__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 (54) hide show
  1. {miepython-3.3.0 → miepython-3.4.0}/CHANGELOG.rst +197 -46
  2. {miepython-3.3.0 → miepython-3.4.0}/CITATION.cff +7 -7
  3. {miepython-3.3.0 → miepython-3.4.0}/PKG-INFO +7 -9
  4. {miepython-3.3.0 → miepython-3.4.0}/README.rst +2 -2
  5. {miepython-3.3.0 → miepython-3.4.0}/miepython/__init__.py +24 -4
  6. miepython-3.4.0/miepython/_convention.py +109 -0
  7. {miepython-3.3.0 → miepython-3.4.0}/miepython/core.py +122 -12
  8. {miepython-3.3.0 → miepython-3.4.0}/miepython/field.py +71 -31
  9. {miepython-3.3.0 → miepython-3.4.0}/miepython/mie_jit.py +31 -19
  10. {miepython-3.3.0 → miepython-3.4.0}/miepython/mie_nojit.py +29 -20
  11. miepython-3.4.0/miepython/monte_carlo.py +215 -0
  12. miepython-3.4.0/miepython/rayleigh.py +441 -0
  13. {miepython-3.3.0 → miepython-3.4.0}/miepython/vsh.py +21 -6
  14. {miepython-3.3.0 → miepython-3.4.0}/miepython.egg-info/PKG-INFO +7 -9
  15. {miepython-3.3.0 → miepython-3.4.0}/miepython.egg-info/SOURCES.txt +3 -0
  16. {miepython-3.3.0 → miepython-3.4.0}/miepython.egg-info/requires.txt +2 -4
  17. {miepython-3.3.0 → miepython-3.4.0}/pyproject.toml +10 -11
  18. {miepython-3.3.0 → miepython-3.4.0}/tests/conftest.py +21 -0
  19. {miepython-3.3.0 → miepython-3.4.0}/tests/test_abcd.py +3 -0
  20. {miepython-3.3.0 → miepython-3.4.0}/tests/test_field.py +101 -2
  21. miepython-3.4.0/tests/test_file_encodings.py +123 -0
  22. {miepython-3.3.0 → miepython-3.4.0}/tests/test_kernels.py +4 -7
  23. {miepython-3.3.0 → miepython-3.4.0}/tests/test_makefile.py +1 -1
  24. {miepython-3.3.0 → miepython-3.4.0}/tests/test_mie.py +118 -0
  25. {miepython-3.3.0 → miepython-3.4.0}/tests/test_monte_carlo.py +76 -21
  26. miepython-3.4.0/tests/test_rayleigh.py +414 -0
  27. {miepython-3.3.0 → miepython-3.4.0}/tests/test_scattnlay_reference.py +52 -1
  28. miepython-3.4.0/tests/test_time_convention.py +280 -0
  29. {miepython-3.3.0 → miepython-3.4.0}/tests/test_vsh.py +3 -0
  30. miepython-3.3.0/miepython/monte_carlo.py +0 -173
  31. miepython-3.3.0/miepython/rayleigh.py +0 -266
  32. miepython-3.3.0/tests/test_rayleigh.py +0 -231
  33. {miepython-3.3.0 → miepython-3.4.0}/LICENSE.txt +0 -0
  34. {miepython-3.3.0 → miepython-3.4.0}/MANIFEST.in +0 -0
  35. {miepython-3.3.0 → miepython-3.4.0}/miepython/_backend.py +0 -0
  36. {miepython-3.3.0 → miepython-3.4.0}/miepython/bessel.py +0 -0
  37. {miepython-3.3.0 → miepython-3.4.0}/miepython/data/Johnson.txt +0 -0
  38. {miepython-3.3.0 → miepython-3.4.0}/miepython/data/segelstein81_index.txt +0 -0
  39. {miepython-3.3.0 → miepython-3.4.0}/miepython/util.py +0 -0
  40. {miepython-3.3.0 → miepython-3.4.0}/miepython.egg-info/dependency_links.txt +0 -0
  41. {miepython-3.3.0 → miepython-3.4.0}/miepython.egg-info/top_level.txt +0 -0
  42. {miepython-3.3.0 → miepython-3.4.0}/setup.cfg +0 -0
  43. {miepython-3.3.0 → miepython-3.4.0}/tests/benchmark_efficiencies.py +0 -0
  44. {miepython-3.3.0 → miepython-3.4.0}/tests/reference.py +0 -0
  45. {miepython-3.3.0 → miepython-3.4.0}/tests/test_D.py +0 -0
  46. {miepython-3.3.0 → miepython-3.4.0}/tests/test_all_examples.py +0 -0
  47. {miepython-3.3.0 → miepython-3.4.0}/tests/test_all_notebooks.py +0 -0
  48. {miepython-3.3.0 → miepython-3.4.0}/tests/test_backend_parity.py +0 -0
  49. {miepython-3.3.0 → miepython-3.4.0}/tests/test_bessel.py +0 -0
  50. {miepython-3.3.0 → miepython-3.4.0}/tests/test_docstrings.py +0 -0
  51. {miepython-3.3.0 → miepython-3.4.0}/tests/test_optional_scipy.py +0 -0
  52. {miepython-3.3.0 → miepython-3.4.0}/tests/test_package_surface.py +0 -0
  53. {miepython-3.3.0 → miepython-3.4.0}/tests/test_unpolarized_intensity.py +0 -0
  54. {miepython-3.3.0 → miepython-3.4.0}/tests/test_util.py +0 -0
@@ -1,8 +1,159 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 3.4.0 (11/26/2026)
5
+ ------------------
6
+ * ``e_far`` now broadcasts ``r``, ``theta`` and ``phi`` as its docstring
7
+ promised, returning shape ``(3, ...)``. An array ``r`` or ``phi`` with a
8
+ scalar ``theta``, or a 2-D ``theta``, used to raise; all-scalar input now
9
+ returns shape ``(3,)`` like ``e_near`` instead of ``(3, 1)``
10
+ * ``m = 0`` is now an exact perfect conductor in ``efficiencies_mx``, as it
11
+ already was in ``coefficients``, the field functions, ``rayleigh`` and for
12
+ x < 0.1. It used to be replaced by ``1 - 10000j`` for x >= 0.1
13
+ * ``efficiencies_mx`` raises ``ValueError`` for an ``n_pole`` beyond
14
+ ``wiscombe_terms(x)``, as ``S1_S2`` does, instead of returning ~0
15
+ * ``single_sphere`` and ``core.normalization_factor`` conjugate an index with
16
+ a positive imaginary part themselves; the small-sphere branch used to give
17
+ a negative qext for one
18
+ * ``cn_dn`` defaults ``n_pole`` to 0 like ``an_bn``, on both backends
19
+ * ``norm='qsca'`` no longer returns NaN for a zero-size sphere
20
+ * ``rayleigh.efficiencies_mx`` accepts a list of ``x`` and raises the same
21
+ error as ``efficiencies_mx`` for mismatched lengths
22
+ * clarify that ``coefficients`` returns orders 1 through ``n_pole``
23
+ * treat zero-dimensional NumPy arrays for ``m`` and ``x`` as scalar inputs
24
+ throughout the public Mie API, including the JIT backend
25
+ * return length-one arrays from the Rayleigh angular functions when ``mu`` is
26
+ scalar, matching the full Mie API; correct the ``vsh.M_odd`` usage example
27
+ * normalize the sign of an absorbing sphere's index before evaluating its
28
+ interior near fields. Previously, a positive imaginary input produced the
29
+ same scattering coefficients as its conjugate but different interior E and H
30
+ fields, breaking boundary continuity. Both input signs now give the same
31
+ fields in either time convention
32
+ * make ``docs/13_resonance.ipynb`` construct silver indices as m = n - ik while
33
+ plotting the positive absorption magnitude k, and clarify that
34
+ ``m_im`` in ``docs/01_basics.ipynb`` is positive while Im(m) is negative
35
+ * **behaviour change:** one time convention for every complex result, chosen by
36
+ the new ``set_time_convention``, ``get_time_convention`` and the context
37
+ manager ``time_convention``. The default is exp(+jωt), which goes with
38
+ m = n - ik and with Wiscombe's MIEV0; ``"-"`` gives exp(-iωt), the convention
39
+ of Bohren & Huffman, Jackson and scattnlay. The two differ only by complex
40
+ conjugation, and efficiencies, g and intensities are the same in both.
41
+ Before, the package mixed them: ``S1_S2`` and ``phase_matrix`` were exp(+jωt)
42
+ while ``coefficients`` and every field function were exp(-iωt), which is
43
+ what let the ``e_far`` error below go unnoticed. Under the default,
44
+
45
+ - ``S1_S2``, ``rayleigh.S1_S2`` and ``phase_matrix`` are unchanged;
46
+ - ``coefficients`` returns the conjugates of its previous values;
47
+ - ``e_near``, ``h_near``, ``eh_near``, their Cartesian forms and ``e_far``
48
+ return the conjugates of their previous fields, and a caller's ``abcd``
49
+ must come from ``coefficients`` under the same convention;
50
+ - the ``miepython.vsh`` harmonics use h_n^(2) outside the sphere, and take
51
+ ``m_index`` in the form that matches the active convention.
52
+
53
+ Inside ``time_convention("-")`` the coefficients, fields and harmonics match
54
+ 3.3.1, while ``S1_S2`` returns Bohren & Huffman's amplitudes and
55
+ ``phase_matrix`` puts S34 where their eq. 3.16 does. The raw kernels
56
+ (``an_bn``, ``cn_dn``, ``_S1_S2``) ignore the setting and always return
57
+ exp(-iωt); ``_S1_S2`` no longer conjugates its sum a second time
58
+ * compare the scattnlay reference fields component by component, phase included,
59
+ rather than only as magnitudes, which could not see a conjugated field
60
+ * stop flipping the sign of S34 by hand in ``docs/07_algorithm.ipynb``: Bohren's
61
+ sample calculation now runs inside ``time_convention("-")`` and matches his
62
+ table directly. ``docs/01_basics.ipynb`` explains both conventions, and
63
+ ``docs/14_boundary_conditions.ipynb`` uses eps = n**2 for exp(+jωt)
64
+ * fix the phase of ``e_far`` (#36, thanks @rcgiri-physics and @antonsoo). It
65
+ conjugated the whole field, outgoing ``exp(ikr)`` included, so the radial phase
66
+ ran backwards for the exp(-iωt) convention, and ``E_phi`` had the wrong sign
67
+ relative to ``E_theta``. Only S1 and S2 are conjugated now, and ``E_phi``
68
+ carries the ``-S1 sin(phi)`` of Bohren & Huffman eq. 4.74. ``e_far`` now
69
+ agrees with ``e_near(..., include_incident=False)`` to O(1/kr) in every complex
70
+ component; before, it was off by O(1). The old test compared magnitudes at
71
+ theta = phi = 45 degrees, which could see neither error. Magnitudes, and so
72
+ intensities, are unchanged
73
+ * add PEP 723 inline metadata to ``docs/data/generate_scattnlay_reference_fields.py``
74
+ so ``uv run`` builds scattnlay 2.4 for it on demand. scattnlay stays out of
75
+ the project extras, because nothing else needs it
76
+
77
+ 3.3.1 (10/28/2026)
78
+ ------------------
79
+ * fix ``rayleigh.efficiencies_mx`` subtracting scattering from extinction. With
80
+ the m = n - ik convention the absorption term is negative, so
81
+ ``abs(absorption + qsca)`` gave absorption minus scattering, and qext for
82
+ m = 1.5 - 1e-6j at x = 0.01 came out 21% low (thanks @antonsoo). The x**4 term
83
+ now follows Bohren & Huffman's ``Re(ratio**2)`` rather than ``|ratio|**2``,
84
+ which agrees with Mie to 2e-5 instead of 6e-4 at m = 1.5 - 1j, x = 0.1. ``m``
85
+ is conjugated first, as ``core.py`` does. The Rayleigh ``qext`` also sets the
86
+ ``albedo`` and ``qext`` normalizations, so ``rayleigh.S1_S2`` and the
87
+ intensities change too
88
+ * handle perfectly conducting spheres in ``rayleigh``. As elsewhere in the
89
+ package, m.real == 0 now means a perfect conductor, which radiates a magnetic
90
+ dipole b1 = -a1/2 alongside its electric one: qext = qsca = 10/3 x**4,
91
+ qback = 9 x**4 and g = -2/5. The dielectric formulas were used before, so
92
+ m = -1j gave a qext about three times the Mie value; it now agrees to 2e-5 at
93
+ x = 0.01
94
+ * validate input to the ``rayleigh`` functions as ``core.py`` now does. A NaN or
95
+ infinite m or x, a negative x, or a negative real part of m raises
96
+ ``ValueError``; before, ``rayleigh.efficiencies_mx(nan, 0.05)`` returned NaN and
97
+ ``m = -1.5 - 0.1j`` or ``x = -0.05`` returned normal-looking efficiencies
98
+ * say why ``S1_S2`` and the functions built on it reject an array of spheres, in
99
+ both ``core`` and ``rayleigh``. They vectorize over mu and describe one sphere,
100
+ but an array m or x failed with numpy's "truth value of an array is ambiguous"
101
+ * return ``g`` from ``rayleigh.efficiencies_mx`` with the same shape and type as
102
+ the other efficiencies. It was the int 0 even for an array of spheres
103
+ * document the ``rayleigh`` module: what the approximation is, which expressions
104
+ go beyond the leading Rayleigh term, its accuracy against Mie, and tested
105
+ examples
106
+ * support Python 3.11 through 3.15. ``requires-python`` is now ``>=3.11``, 3.10 is
107
+ dropped from the classifiers, the black target versions and the CI matrix, and
108
+ 3.15 is added to all three
109
+ * raise ``ValueError`` for a refractive index or size parameter the kernels would
110
+ misread. The kernels treat any index that fails ``m.real > 0`` as a perfect
111
+ conductor, so ``m = nan`` or ``m = -1.5`` silently returned the answer for a metal
112
+ sphere, and an infinite m returned NaN. A NaN x raised "cannot convert float
113
+ NaN to integer" on the pure-Python backend while numba returned NaN, an infinite
114
+ x raised a different unhelpful error on each backend, and a negative x returned
115
+ zeros. ``coefficients``, ``efficiencies_mx``, ``S1_S2`` and the near fields, and
116
+ everything built on them, now reject a NaN or infinite m or x, a negative x, and
117
+ a negative real part of m, checking every entry of an array. ``m.real == 0``
118
+ still means a perfect conductor and x = 0 is still allowed
119
+ * fix ``monte_carlo.mu_with_uniform_cdf`` returning wrong angles for fine tables.
120
+ ``cdf`` began at I(-1)/num rather than zero, so a target below that value left
121
+ the inversion loop at index zero and interpolated against the last entry.
122
+ ``cdf`` now integrates the phase function with the trapezoidal rule, starting at
123
+ exactly 0 and ending at exactly 1 (it used to end slightly above 1), so tables
124
+ differ slightly from 3.3.0. ``cdf`` and ``mu_with_uniform_cdf`` also raise
125
+ ``ValueError`` when num is less than 2 (thanks @antonsoo)
126
+ * replace the inversion loop in ``monte_carlo.mu_with_uniform_cdf`` with
127
+ ``np.interp``
128
+ * warn when ``monte_carlo.cdf`` uses too few angles to resolve the phase function.
129
+ The raw integral should be one, so a ``RuntimeWarning`` is issued when it is off
130
+ by more than 1%; normalizing used to hide the error silently. A large sphere
131
+ needs roughly x**2 angles, because its forward peak is only about 8/x**2 wide in
132
+ cos(theta)
133
+ * size the table inside ``monte_carlo.mu_with_uniform_cdf`` from x, as
134
+ max(2000, 5*x**2) angles instead of a fixed 2000. At x = 100 the sampled mean
135
+ cosine was 0.930 against g = 0.868; it is now 0.869. Large spheres are slower
136
+ to tabulate: seconds at x = 100, about a minute at x = 300
137
+ * raise ``ValueError`` from ``monte_carlo.cdf`` and ``mu_with_uniform_cdf`` when the
138
+ phase function is not finite
139
+ * rewrite the ``monte_carlo`` docstrings, with tested examples of drawing random
140
+ scattering angles
141
+ * name the encoding on every text read and write. ``open(path)`` and
142
+ ``Path.read_text()`` decode with the locale's preferred encoding, which is UTF-8
143
+ on Linux and macOS but cp1252 on Windows, so ``tests/test_makefile.py`` passed
144
+ everywhere except the four Windows jobs, where it died on the emoji in the
145
+ Makefile's echo lines. Two more latent cases are fixed alongside it: the
146
+ scattnlay metadata read in ``tests/test_scattnlay_reference.py``, which survived
147
+ only because that JSON happens to be pure ASCII, and the ``write_text`` in
148
+ ``docs/data/generate_scattnlay_reference_fields.py``
149
+ * check for locale-dependent text I/O in the test suite, by walking the syntax trees
150
+ of every Python file in the repository and requiring an explicit ``encoding=``.
151
+ The failure is invisible on the platforms this package is developed on, so a
152
+ Windows-only break was waiting for whoever next added a non-ASCII character to a
153
+ file something reads
154
+
4
155
  3.3.0 (07/28/2026)
5
- -------------------
156
+ ------------------
6
157
  * fix the docstring examples in ``core.py``, which had rotted unnoticed. The
7
158
  ``coefficients`` examples called ``mie_coefficients``, a name that never
8
159
  existed, showed the imaginary parts with the wrong sign, and still included the
@@ -334,12 +485,12 @@ Changelog
334
485
  address the highest order, which the old bounds check rejected
335
486
 
336
487
  3.2.0 (03/06/2026)
337
- -------------------
488
+ ------------------
338
489
  * fix error in E & H calculations in the near field when y≠0 (thanks @dorianherle)
339
490
  * add regression test
340
491
 
341
492
  3.1.0 (02/07/2026)
342
- -------------------
493
+ ------------------
343
494
  * add near-field E and H field APIs, fix boundary continuity/medium handling, and expand validation tests
344
495
  * add field calculation utilities, field module cleanup/help text improvements, and precomputed E/H reference data (via scattnlay)
345
496
  * improve performance: ~20% speedups in Mie backends and faster near-field calculations; add speed benchmarks
@@ -349,12 +500,12 @@ Changelog
349
500
  * packaging/CI: pyproject and requirements cleanup, improved PyPI workflow, updated citation automation/config
350
501
  * misc cleanups: remove unused files/images, minor typos, Makefile and docs config tidy-ups, CITATION.cff refresh
351
502
 
352
- 3.0.5 (1/2/2026)
353
- -------------------
503
+ 3.0.5 (01/02/2026)
504
+ ------------------
354
505
  * fix versioning
355
506
 
356
- 3.0.4 (1/2/2026)
357
- -------------------
507
+ 3.0.4 (01/02/2026)
508
+ ------------------
358
509
  * Host jupyterlite instance of github
359
510
  * improve citation guidelines
360
511
  * add test for unpolarized intensity methods
@@ -364,15 +515,15 @@ Changelog
364
515
  * improve readme
365
516
 
366
517
  3.0.3
367
- -------------------
518
+ -----
368
519
  * skipped
369
520
 
370
- 3.0.2 (5/25/2025)
371
- -------------------
521
+ 3.0.2 (05/25/2025)
522
+ ------------------
372
523
  * fix version number
373
524
 
374
- 3.0.1 (5/25/2025)
375
- -------------------
525
+ 3.0.1 (05/25/2025)
526
+ ------------------
376
527
  * fix JIT regression (thanks @avgeiss)
377
528
  * clarify polarization in docstrings
378
529
  * improve README.rst
@@ -383,8 +534,8 @@ Changelog
383
534
  * rationalize importing of jit and non-jit code
384
535
  * add test_jit_speed.py and test_nojit_speed.py
385
536
 
386
- 3.0.0 (3/16/2025)
387
- -------------------
537
+ 3.0.0 (03/16/2025)
538
+ ------------------
388
539
  * breaking api changes
389
540
  * api is more sane: mie.efficiencies() instead of miepython.ez_mie()
390
541
  * use core.py to cleanly separate jit and non-jit code
@@ -400,35 +551,35 @@ Changelog
400
551
  * add more tests
401
552
 
402
553
 
403
- 2.5.5 (12/01/2025)
404
- -------------------
554
+ 2.5.5 (12/01/2024)
555
+ ------------------
405
556
  * add support for specific spherical modes
406
557
  * only branch is now 'main'
407
558
 
408
559
  2.5.4 (05/07/2024)
409
- -------------------
560
+ ------------------
410
561
  * add auto-dating in CITATION
411
562
  * add python 3.12
412
563
  * add ruff, pylint config
413
564
  * simplify mie_cdf and fix notebook
414
565
  * set 3.7 as earliest python version
415
566
 
416
- v2.5.3 (8/5/2023)
417
- -------------------
567
+ 2.5.3 (08/05/2023)
568
+ ------------------
418
569
  * conda-forge fails because test files are not included
419
570
 
420
- v2.5.1 (8/5/2023)
421
- -------------------
571
+ 2.5.1 (08/05/2023)
572
+ ------------------
422
573
  * change tests to accommodate conda-forge
423
574
  * require python>=3.9 to accommodate latest numba
424
575
  * get rid of tox
425
576
 
426
- v2.5.0 (8/4/2023)
427
- -------------------
577
+ 2.5.0 (08/04/2023)
578
+ ------------------
428
579
  * fix scattering function for very small spheres
429
580
 
430
- v2.4.0 (6/10/2023)
431
- -------------------
581
+ 2.4.0 (06/10/2023)
582
+ ------------------
432
583
  * add mie_phase_matrix() to calculate scattering (Mueller) matrix
433
584
 
434
585
  v2.3.2
@@ -449,7 +600,7 @@ v2.3.0
449
600
  * fix typo in header of gold sphere example script
450
601
  * remove workaround for older Sphinx version
451
602
 
452
- v2.2.3 (1/26/2022)
603
+ 2.2.3 (01/26/2022)
453
604
  ------------------
454
605
  * update _mie_An_Bn in miepython_nojit
455
606
  * store data in module so github testing passes
@@ -457,7 +608,7 @@ v2.2.3 (1/26/2022)
457
608
  * only test back to python 3.9 because importlib.resources
458
609
  * 3.9 is only needed for a few of the jupyter notebooks
459
610
 
460
- v2.2.2 (1/25/2022)
611
+ 2.2.2 (01/25/2022)
461
612
  ------------------
462
613
  * modify _mie_An_Bn to allocate and return An and Bn
463
614
  * fix minor packaging issue
@@ -467,14 +618,14 @@ v2.2.2 (1/25/2022)
467
618
  * add docs/requirements
468
619
  * restrict Jinja2 to 2.11.3 in docs/requirements
469
620
 
470
- v2.2.1 (9/5/2021)
471
- -----------------
621
+ 2.2.1 (09/05/2021)
622
+ ------------------
472
623
  * create pure python packages
473
624
  * include wheel file
474
625
  * package as python3 only
475
626
 
476
- 2.1.0 (05/22/21)
477
- ----------------
627
+ 2.1.0 (05/22/2021)
628
+ ------------------
478
629
  * fix case when scalar angle used with mie_S1_S2()
479
630
  * add pypi badge
480
631
  * fix notebook testing
@@ -486,28 +637,28 @@ v2.2.1 (9/5/2021)
486
637
  * fix examples that use refractiveindex.info
487
638
  * add testing badge
488
639
 
489
- 2.0.1 (04/25/21)
490
- ----------------
640
+ 2.0.1 (04/25/2021)
641
+ ------------------
491
642
  * fix packaging mistake
492
643
 
493
- 2.0.0 (04/25/21)
494
- ----------------
644
+ 2.0.0 (04/25/2021)
645
+ ------------------
495
646
  * use numba for 10-700X speed improvement
496
647
  * thanks to @jbecca and @pscicluna for their help
497
648
  * add performance notebook
498
649
  * add automated notebook checking
499
650
  * test more code
500
651
 
501
- 1.3.3 (03/21/21)
502
- ----------------
652
+ 1.3.3 (03/21/2021)
653
+ ------------------
503
654
  * colab badge and link
504
655
  * change theme for sphinx documentation
505
656
  * add requirements.txt to avoid installing sphinx
506
657
  * fix restructured text errors
507
658
  * advise everywhere to `pip install --user miepython` to avoid permission problems
508
659
 
509
- 1.3.2 (01/13/21)
510
- ----------------
660
+ 1.3.2 (01/13/2021)
661
+ ------------------
511
662
  * add ez_mie(m, d, lambda0)
512
663
  * add ez_intensities(m, d, lambda0, mu)
513
664
  * fix formatting
@@ -515,22 +666,22 @@ v2.2.1 (9/5/2021)
515
666
  * specify newer pythons
516
667
  * better install instructions
517
668
 
518
- 1.3.1 (03/30/20)
519
- ----------------
669
+ 1.3.1 (03/30/2020)
670
+ ------------------
520
671
  * improve docstrings
521
672
  * use Sphinx documentation
522
673
  * host docs on readthedocs.io
523
674
  * use tox
524
675
 
525
- 1.3.0 (02/19/19)
526
- ----------------
676
+ 1.3.0 (02/19/2019)
677
+ ------------------
527
678
  * fix calculations for small spheres (x<0.05)
528
679
  * added notebook doc/09_backscattering.ipynb
529
680
  * general tweaks to documentation throughout
530
681
  * improved README.md
531
682
 
532
- 1.2.0. (02/08/19)
533
- -----------------
683
+ 1.2.0 (02/08/2019)
684
+ ------------------
534
685
  * fix bug so that large sphere calculations work correctly
535
686
  * add tests for large spheres
536
687
  * add tests for backscattering efficiency
@@ -539,7 +690,7 @@ v2.2.1 (9/5/2021)
539
690
  * finish fixing fractions in notebooks
540
691
  * improve README.md
541
692
 
542
- 1.1.1. (06/25/18)
693
+ 1.1.1 (06/25/2018)
543
694
  ------------------
544
695
  * fix github rendering of fractions in equations
545
696
  * add developer instructions
@@ -2,10 +2,10 @@ cff-version: 1.2.0
2
2
  type: software
3
3
  message: If you use this software, please cite it as below.
4
4
  title: 'miepython: Pure python calculation of Mie scattering'
5
- version: 3.2.0
6
- doi: 10.5281/zenodo.7949264
7
- date-released: '2026-03-06'
8
- url: https://doi.org/10.5281/zenodo.7949264
5
+ version: 3.3.1
6
+ doi: 10.5281/zenodo.7949263
7
+ date-released: '2026-10-28'
8
+ url: https://doi.org/10.5281/zenodo.7949263
9
9
  repository-code: https://github.com/scottprahl/miepython
10
10
  license: MIT
11
11
  authors:
@@ -33,9 +33,9 @@ preferred-citation:
33
33
  type: software
34
34
  title: 'miepython: Pure python calculation of Mie scattering'
35
35
  year: 2026
36
- version: 3.2.0
37
- doi: 10.5281/zenodo.7949264
38
- url: https://doi.org/10.5281/zenodo.7949264
36
+ version: 3.3.1
37
+ doi: 10.5281/zenodo.7949263
38
+ url: https://doi.org/10.5281/zenodo.7949263
39
39
  authors:
40
40
  - family-names: Prahl
41
41
  given-names: Scott
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: miepython
3
- Version: 3.3.0
3
+ Version: 3.4.0
4
4
  Summary: Mie scattering of a plane wave by a sphere
5
5
  Author-email: Scott Prahl <scott.prahl@oit.edu>
6
6
  License-Expression: MIT
@@ -14,16 +14,15 @@ Classifier: Development Status :: 5 - Production/Stable
14
14
  Classifier: Intended Audience :: Science/Research
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
19
18
  Classifier: Programming Language :: Python :: 3.12
20
19
  Classifier: Programming Language :: Python :: 3.13
21
20
  Classifier: Programming Language :: Python :: 3.14
22
- Requires-Python: >=3.10
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Requires-Python: >=3.11
23
23
  Description-Content-Type: text/x-rst
24
24
  License-File: LICENSE.txt
25
25
  Requires-Dist: numpy
26
- Requires-Dist: matplotlib
27
26
  Requires-Dist: scipy
28
27
  Requires-Dist: numba; sys_platform != "emscripten"
29
28
  Provides-Extra: docs
@@ -35,8 +34,8 @@ Requires-Dist: sphinx_rtd_theme; extra == "docs"
35
34
  Provides-Extra: dev
36
35
  Requires-Dist: pytest; extra == "dev"
37
36
  Requires-Dist: pytest-cov; extra == "dev"
38
- Requires-Dist: imageio; extra == "dev"
39
37
  Requires-Dist: requests; extra == "dev"
38
+ Requires-Dist: matplotlib; extra == "dev"
40
39
  Requires-Dist: ruff; extra == "dev"
41
40
  Requires-Dist: yamllint; extra == "dev"
42
41
  Requires-Dist: rstcheck[sphinx,toml]; extra == "dev"
@@ -45,14 +44,13 @@ Requires-Dist: pyroma; extra == "dev"
45
44
  Requires-Dist: black[jupyter]; extra == "dev"
46
45
  Requires-Dist: build; extra == "dev"
47
46
  Requires-Dist: check-manifest; extra == "dev"
48
- Requires-Dist: libarchive-c; extra == "dev"
49
47
  Requires-Dist: pyyaml; extra == "dev"
50
- Requires-Dist: setuptools; extra == "dev"
51
48
  Requires-Dist: jupyterlab; extra == "dev"
52
49
  Requires-Dist: nbconvert; extra == "dev"
53
50
  Requires-Dist: nbformat; extra == "dev"
54
51
  Provides-Extra: lite
55
52
  Requires-Dist: jupyterlite-core<0.8,>=0.7; extra == "lite"
53
+ Requires-Dist: libarchive-c; extra == "lite"
56
54
  Requires-Dist: jupyterlite-pyodide-kernel<0.8,>=0.7; extra == "lite"
57
55
  Dynamic: license-file
58
56
 
@@ -211,7 +209,7 @@ Citation
211
209
 
212
210
  If you use ``miepython`` in academic, instructional, or applied technical work, please cite:
213
211
 
214
- Prahl, S. (2026). *miepython: Pure python calculation of Mie scattering* (Version 3.2.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
212
+ Prahl, S. (2026). *miepython: Pure python calculation of Mie scattering* (Version 3.3.1) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
215
213
 
216
214
  BibTeX:
217
215
 
@@ -223,7 +221,7 @@ BibTeX:
223
221
  url = {https://github.com/scottprahl/miepython},
224
222
  doi = {10.5281/zenodo.7949263},
225
223
  year = {2026},
226
- version = {3.2.0},
224
+ version = {3.3.1},
227
225
  publisher = {Zenodo}
228
226
  }
229
227
 
@@ -153,7 +153,7 @@ Citation
153
153
 
154
154
  If you use ``miepython`` in academic, instructional, or applied technical work, please cite:
155
155
 
156
- Prahl, S. (2026). *miepython: Pure python calculation of Mie scattering* (Version 3.2.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
156
+ Prahl, S. (2026). *miepython: Pure python calculation of Mie scattering* (Version 3.3.1) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263
157
157
 
158
158
  BibTeX:
159
159
 
@@ -165,7 +165,7 @@ BibTeX:
165
165
  url = {https://github.com/scottprahl/miepython},
166
166
  doi = {10.5281/zenodo.7949263},
167
167
  year = {2026},
168
- version = {3.2.0},
168
+ version = {3.3.1},
169
169
  publisher = {Zenodo}
170
170
  }
171
171
 
@@ -22,7 +22,7 @@ If the size parameter is known, then use::
22
22
 
23
23
  mie.efficiencies_mx(m, x)
24
24
 
25
- Mie scattering amplitudes S1 and S2 (complex numbers):
25
+ Mie scattering amplitudes S1 and S2 (complex numbers)::
26
26
 
27
27
  mie.S1_S2(m, x, mu)
28
28
 
@@ -38,10 +38,25 @@ Mie scattering intensities normalized to one when integrated over all angles::
38
38
  mie.i_par(m, x, mu, norm='one')
39
39
  mie.i_unpolarized(m, x, mu, norm='one')
40
40
 
41
- The scattering matrix
41
+ The scattering matrix::
42
42
 
43
43
  mie.phase_matrix(m, x, mu)
44
44
 
45
+ Time convention
46
+ ---------------
47
+
48
+ Complex results (coefficients, S1 and S2, fields, the S34 element of the phase
49
+ matrix) depend on whether the time dependence is written exp(+jωt) or exp(-iωt);
50
+ the two are complex conjugates. The default is exp(+jωt), which goes with the
51
+ m = n - ik form of the refractive index and reproduces Wiscombe's MIEV0. Bohren
52
+ & Huffman, Jackson and scattnlay use exp(-iωt)::
53
+
54
+ mie.set_time_convention("-") # for the rest of the session
55
+ with mie.time_convention("-"): # or just for a block
56
+ a, b = mie.coefficients(m, x)
57
+
58
+ Efficiencies, g and intensities are the same either way.
59
+
45
60
  Submodules
46
61
  ----------
47
62
 
@@ -56,7 +71,7 @@ the textbook formulas. It is a reference for development and cross-checking rat
56
71
  than a fast path, it requires the optional ``scipy`` dependency, and so it is bound
57
72
  only when scipy is installed::
58
73
 
59
- mie.vsh.M_odd(1, k, d_sphere, r, theta, phi)
74
+ mie.vsh.M_odd(1, 0.5, 1.0, 1.5, 0.8, 0.7, 0.2)
60
75
 
61
76
  ``miepython.monte_carlo`` samples scattering angles from the Mie phase function. It
62
77
  imports this package, so importing it from here would be circular; ask for it
@@ -91,6 +106,8 @@ from ._backend import single_sphere, small_conducting_sphere, small_sphere
91
106
  from .core import efficiencies, intensities, i_par, i_per, i_unpolarized
92
107
  from .core import efficiencies_mx, S1_S2, phase_matrix, coefficients
93
108
 
109
+ from ._convention import get_time_convention, set_time_convention, time_convention
110
+
94
111
  from . import rayleigh
95
112
 
96
113
  _FIELD_IMPORT_ERROR = None
@@ -148,6 +165,9 @@ else:
148
165
  # scipy is installed, and a star-import must not depend on that.
149
166
  __all__ = (
150
167
  "rayleigh",
168
+ "get_time_convention",
169
+ "set_time_convention",
170
+ "time_convention",
151
171
  "intensities",
152
172
  "i_par",
153
173
  "i_per",
@@ -178,7 +198,7 @@ __all__ = (
178
198
  "_D_downwards",
179
199
  )
180
200
 
181
- __version__ = "3.3.0"
201
+ __version__ = "3.4.0"
182
202
  __author__ = "Scott Prahl"
183
203
  __email__ = "scott.prahl@oit.edu"
184
204
  __copyright__ = "2017-2026, Scott Prahl"
@@ -0,0 +1,109 @@
1
+ """Time-harmonic sign convention for the complex values miepython returns.
2
+
3
+ A monochromatic field can be written with time dependence exp(+jωt) or
4
+ exp(-iωt). The two descriptions carry the same physics and, for the
5
+ non-magnetic spheres handled here, every complex result in one is the complex
6
+ conjugate of the same result in the other:
7
+
8
+ ``"+"`` (the default), exp(+jωt)
9
+ The convention of van de Hulst, Kerker and Wiscombe's MIEV0, natural for the
10
+ m = n - ik form of the refractive index that miepython has always used.
11
+ Outgoing spherical waves go as h_n^(2)(kr), a plane wave travelling along +z
12
+ as exp(-jkz), and ``S1_S2`` reproduces MIEV0's amplitudes directly.
13
+
14
+ ``"-"``, exp(-iωt)
15
+ The convention of Bohren & Huffman, Jackson and scattnlay. Outgoing waves go
16
+ as h_n^(1)(kr), a plane wave along +z as exp(+ikz), and the amplitudes,
17
+ coefficients and phase matrix match Bohren & Huffman's equations and tables.
18
+
19
+ Only complex results depend on the choice: the Mie coefficients, S1 and S2, the
20
+ near and far fields, the vector spherical harmonics, and the S34 element of the
21
+ phase matrix (which changes sign, along with the handedness of the Stokes V).
22
+ Efficiencies, g, intensities and the other phase-matrix elements are identical.
23
+
24
+ The refractive index is accepted with either sign of its imaginary part and is
25
+ always taken to be absorbing, whatever convention is active.
26
+
27
+ The setting is global to the process. Library code that needs a particular
28
+ convention should use the context manager, which restores the caller's choice::
29
+
30
+ with miepython.time_convention("-"):
31
+ a, b = miepython.coefficients(m, x)
32
+
33
+ The raw kernels (``an_bn``, ``cn_dn``, ``_S1_S2``, ...) ignore this setting and
34
+ always work in exp(-iωt); the public functions convert on the way out.
35
+ """
36
+
37
+ import contextlib
38
+
39
+ import numpy as np
40
+
41
+ __all__ = ("get_time_convention", "set_time_convention", "time_convention")
42
+
43
+ _VALID = ("+", "-")
44
+ _current = "+"
45
+
46
+
47
+ def _validate(sign):
48
+ """Return ``sign`` if it names a convention, else raise ``ValueError``."""
49
+ if not isinstance(sign, str) or sign not in _VALID:
50
+ raise ValueError(f"time convention must be '+' for exp(+jωt) or '-' for exp(-iωt), not {sign!r}")
51
+ return sign
52
+
53
+
54
+ def get_time_convention():
55
+ """Return the active time convention.
56
+
57
+ Returns:
58
+ str: ``"+"`` for exp(+jωt) or ``"-"`` for exp(-iωt).
59
+ """
60
+ return _current
61
+
62
+
63
+ def set_time_convention(sign):
64
+ """Choose the time convention for every complex result miepython returns.
65
+
66
+ Args:
67
+ sign (str): ``"+"`` for exp(+jωt), the default, or ``"-"`` for exp(-iωt).
68
+
69
+ Returns:
70
+ str: The convention that was active before the call, so it can be restored.
71
+
72
+ Raises:
73
+ ValueError: if ``sign`` is neither ``"+"`` nor ``"-"``.
74
+ """
75
+ global _current # pylint: disable=global-statement
76
+ previous = _current
77
+ _current = _validate(sign)
78
+ return previous
79
+
80
+
81
+ @contextlib.contextmanager
82
+ def time_convention(sign):
83
+ """Use a time convention inside a ``with`` block, then restore the previous one.
84
+
85
+ Args:
86
+ sign (str): ``"+"`` for exp(+jωt) or ``"-"`` for exp(-iωt).
87
+
88
+ Yields:
89
+ str: The convention in force inside the block.
90
+
91
+ Raises:
92
+ ValueError: if ``sign`` is neither ``"+"`` nor ``"-"``.
93
+ """
94
+ previous = set_time_convention(sign)
95
+ try:
96
+ yield sign
97
+ finally:
98
+ set_time_convention(previous)
99
+
100
+
101
+ def _convert(value):
102
+ """Convert between exp(-iωt), used internally, and the active convention.
103
+
104
+ Conjugation is its own inverse, so the same call takes an internal value out
105
+ to the user and a user-supplied value (such as ``abcd``) in.
106
+ """
107
+ if _current == "+":
108
+ return np.conjugate(value)
109
+ return value