Skip to content

Commit e3670f0

Browse files
committed
changed phi_min, phi_max kwargs to not be Quantity; updated docstrings
1 parent 445b2d1 commit e3670f0

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

pymie/mie.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ def calc_energy(radius, n_medium, m, x, nstop,
256256
radius of the scatterer (Quantity in [length])
257257
n_medium: float
258258
refractive index of the medium in which scatterer is embedded
259-
(Quantity, dimensionless)
260259
m: float
261260
complex relative refractive index
262261
x: float
@@ -290,9 +289,9 @@ def calc_dwell_time(radius, n_medium, n_particle, wavelen,
290289
----------
291290
radius: float
292291
radius of the scatterer (Quantity in [length])
293-
n_medium: float (Quantity, dimensionless)
292+
n_medium: float
294293
refractive index of the medium in which scatterer is embedded
295-
n_particle: float (Quantity, dimensionless)
294+
n_particle: float
296295
refractive index of the scatterer
297296
wavelen: structcol.Quantity [length]
298297
wavelength of incident light in vacuum
@@ -322,7 +321,7 @@ def calc_dwell_time(radius, n_medium, n_particle, wavelen,
322321
# calculate total cross section
323322
k = 2*np.pi/wavelen_media
324323
if np.imag(x)>0:
325-
angles = Quantity(np.linspace(min_angle, np.pi, num_angles), 'rad')
324+
angles = np.linspace(min_angle, np.pi, num_angles)
326325
distance = radius.max()
327326
kd = (k*distance).to("").magnitude
328327
(diff_cscat_par,
@@ -763,9 +762,8 @@ def _cross_sections_complex_medium_fu(al, bl, cl, dl, radius, n_particle,
763762
al, bl: Mie scattering coefficients
764763
cl, dl: Mie internal coefficients
765764
radius: radius of the scatterer (Quantity in [length])
766-
n_particle: refractive index of the scatterer (Quantity, dimensionless)
765+
n_particle: refractive index of the scatterer
767766
n_medium: refractive index of the medium in which scatterer is embedded
768-
(Quantity, dimensionless)
769767
x_scatterer: size parameter using the particle's refractive index
770768
x_medium: size parameter using the medium's refractive index
771769
wavelen: wavelength of light in vacuum (Quantity in [length])
@@ -938,11 +936,10 @@ def _scat_fields_complex_medium(m, x, thetas, kd, near_field=False):
938936
----------
939937
m: complex relative refractive index
940938
x: size parameter using the medium's refractive index
941-
thetas: array of scattering angles (Quantity in rad)
939+
thetas: array of scattering angles
942940
kd: k * distance, where k = 2*np.pi*n_matrix/wavelen, and distance is the
943941
distance away from the center of the particle. The standard far-field
944942
solution is obtained when distance >> radius in a non absorbing medium.
945-
(Quantity, dimensionless)
946943
near_field: boolean
947944
Set to True to include the near-fields. Sometimes the full solutions
948945
that include the near fields aren't wanted, for ex when the total cross
@@ -1090,10 +1087,10 @@ def diff_scat_intensity_complex_medium(m, x, thetas, kd, phis=None,
10901087
complex particle relative refractive index, n_part/n_med
10911088
x : complex, array-like
10921089
size parameter, x = ka = 2*pi*n_med/lambda * a (sphere radius a)
1093-
thetas : array-like (Quantity [angle])
1090+
thetas : array-like
10941091
scattering angles. Should be 2D, as output from np.meshgrid, if
10951092
cartesian=True
1096-
kd : float (Quantity, dimensionless)
1093+
kd : float
10971094
k * distance, where k = 2*np.pi*n_matrix/wavelen, and distance is the
10981095
distance away from the center of the particle. The standard far-field
10991096
solutions are obtained when distance >> radius in a non-absorbing
@@ -1221,8 +1218,8 @@ def diff_scat_intensity_complex_medium(m, x, thetas, kd, phis=None,
12211218
return np.array([I_1.real.squeeze(), I_2.real.squeeze()])
12221219

12231220
def integrate_intensity_complex_medium(dscat, distance, thetas, k,
1224-
phi_min=Quantity(0.0, 'rad'),
1225-
phi_max=Quantity(2*np.pi, 'rad'),
1221+
phi_min=0.0,
1222+
phi_max=2*np.pi,
12261223
cartesian=False,
12271224
phis = None):
12281225
"""
@@ -1241,19 +1238,19 @@ def integrate_intensity_complex_medium(dscat, distance, thetas, k,
12411238
the theta dimension MUST come first
12421239
distance : float (Quantity in [length])
12431240
distance away from the scatterer
1244-
thetas : array-like of Quantity in [angle], shape num_thetas
1241+
thetas : array-like, shape num_thetas
12451242
scattering angles
12461243
k : array-like of Quantity in [1/length], shape num_values
12471244
wavevector given by 2 * pi * n_medium / wavelength
1248-
phi_min : float (Quantity in [angle]).
1245+
phi_min : float
12491246
minimum azimuthal angle, default set to 0
12501247
optional, only necessary if cartesian=False (coordinate system is
12511248
'scattering plane')
1252-
phi_max : float (Quantity in [angle]).
1249+
phi_max : float
12531250
maximum azimuthal angle, default set to 2pi
12541251
optional, only necessary if cartesian=False (coordinate system is
12551252
'scattering plane')
1256-
phis : None or ndarray (Quantity in [angle], shape num_phis)
1253+
phis : None or ndarray (shape num_phis)
12571254
azimuthal angles
12581255
12591256
Returns
@@ -1313,10 +1310,6 @@ def integrate_intensity_complex_medium(dscat, distance, thetas, k,
13131310
"depend on azimuthal angle, so specified values "
13141311
"will be ignored")
13151312

1316-
# convert to radians
1317-
phi_min = phi_min.to('rad').magnitude
1318-
phi_max = phi_max.to('rad').magnitude
1319-
13201313
# strip units from integrand
13211314
if isinstance(dsigma_1, Quantity):
13221315
integrand_par = dsigma_1.magnitude * np.abs(np.sin(thetas))
@@ -1416,16 +1409,16 @@ def diff_abs_intensity_complex_medium(m, x, thetas, ktd):
14161409
complex relative refractive index
14171410
x : array-like
14181411
size parameter using the medium's refractive index
1419-
thetas: Quantity[angle], array-like
1420-
array of scattering angles (Quantity in rad or degrees)
1421-
ktd: Quantity[dimensionless], array-like
1412+
thetas: array-like
1413+
array of scattering angles. Must be specified in radians.
1414+
ktd: array-like
14221415
kt * distance, where kt = 2*np.pi*n_particle/wavelen, and distance is
14231416
the distance away from the center of the particle. The far-field
14241417
solution is obtained when distance >> radius.
14251418
14261419
Returns
14271420
-------
1428-
I_par, I_perp : Quantity[dimensionless], array-like
1421+
I_par, I_perp : array-like
14291422
differential absorption intensities for an array of theta
14301423
14311424
Reference

pymie/tests/test_mie_vectorized.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,11 @@ def test_vectorized_angular_functions(self, num_wavelen,
623623
cartesian=cartesian,
624624
phis = phis)
625625

626-
integral = mie.integrate_intensity_complex_medium(i12, d,
627-
thetas, k, phi_min = Quantity(0.0, 'rad'),
628-
phi_max = Quantity(2*np.pi, 'rad'),
629-
cartesian=cartesian, phis = phis)
626+
integral = mie.integrate_intensity_complex_medium(i12, d, thetas, k,
627+
phi_min=0.0,
628+
phi_max=2*np.pi,
629+
cartesian=cartesian,
630+
phis=phis)
630631

631632
# check that shapes of all the computed quantities are correct
632633
for element in vsa + mat:
@@ -675,9 +676,14 @@ def test_vectorized_angular_functions(self, num_wavelen,
675676
phis = phis)
676677

677678
integral_loop = mie.integrate_intensity_complex_medium(i_loop, d,
678-
thetas, k[i], phi_min = Quantity(0.0, 'rad'),
679-
phi_max = Quantity(2*np.pi, 'rad'),
680-
cartesian=cartesian, phis = phis)
679+
thetas,
680+
k[i],
681+
phi_min=0.0,
682+
phi_max =
683+
2*np.pi,
684+
cartesian =
685+
cartesian,
686+
phis=phis)
681687

682688
S1[i], S2[i], S3[i], S4[i] = mat_loop
683689
amp0[i], amp1[i] = vsa_loop

0 commit comments

Comments
 (0)