Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c0b4e7

Browse files
committed
Some docstring reformatting
1 parent a7bd876 commit 8c0b4e7

File tree

8 files changed

+97
-98
lines changed

8 files changed

+97
-98
lines changed

sfs/array.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,24 @@ def rounded_edge(Nxy, Nr, dx, center=[0, 0, 0], n0=None):
184184
185185
Parameters
186186
----------
187-
Nxy : integer
187+
Nxy : int
188188
Number of secondary sources along x- and y-axis.
189-
Nr : integer
190-
Number of secondary sources in rounded edge. Radius of edge is
189+
Nr : int
190+
Number of secondary sources in rounded edge. Radius of edge is
191191
adjusted to equdistant sampling along entire array.
192-
center : triple of floats
192+
center : (3,) array_like, optional
193193
Position of edge.
194-
n0 : triple of floats
195-
Normal vector of array. Default orientation is along xy-axis.
194+
n0 : (3,) array_like, optional
195+
Normal vector of array. Default orientation is along xy-axis.
196196
197197
Returns
198198
-------
199-
positions : list of triplets of floats
200-
positions of secondary sources
201-
directions : list of triplets of floats
202-
orientations (normal vectors) of secondary sources
203-
weights : list of floats
204-
integration weights of secondary sources
199+
positions : (N, 3) numpy.ndarray
200+
Positions of secondary sources
201+
directions : (N, 3) numpy.ndarray
202+
Orientations (normal vectors) of secondary sources
203+
weights : (N,) numpy.ndarray
204+
Integration weights of secondary sources
205205
206206
Example
207207
-------
@@ -338,8 +338,9 @@ def cube(Nx, dx, Ny, dy, Nz, dz, center=[0, 0, 0], n0=None):
338338
def sphere_load(fname, radius, center=[0, 0, 0]):
339339
"""Spherical secondary source distribution loaded from datafile.
340340
341-
ASCII Format (see MATLAB SFS Toolbox) with 4 numbers (3 position, 1 weight)
342-
per secondary source located on the unit circle.
341+
ASCII Format (see MATLAB SFS Toolbox) with 4 numbers (3 position, 1
342+
weight) per secondary source located on the unit circle.
343+
343344
"""
344345
x0 = np.loadtxt(fname)
345346
weights = x0[:, 3]
@@ -352,8 +353,9 @@ def sphere_load(fname, radius, center=[0, 0, 0]):
352353
def load(fname, center=[0, 0, 0], n0=None):
353354
"""Load secondary source positions from datafile.
354355
355-
Comma Seperated Values (CSV) format with 7 values
356-
(3 positions, 3 directions, 1 weight) per secondary source
356+
Comma Seperated Values (CSV) format with 7 values
357+
(3 positions, 3 directions, 1 weight) per secondary source.
358+
357359
"""
358360
data = np.loadtxt(fname, delimiter=',')
359361
positions = data[:, [0, 1, 2]]
@@ -372,7 +374,8 @@ def load(fname, center=[0, 0, 0], n0=None):
372374
def weights_linear(positions):
373375
"""Calculate loudspeaker weights for a linear array.
374376
375-
The linear array has to be parallel to the y-axis.
377+
The linear array has to be parallel to the y-axis.
378+
376379
"""
377380
N = len(positions)
378381
weights = np.zeros(N)
@@ -388,9 +391,10 @@ def weights_linear(positions):
388391
def weights_closed(positions):
389392
"""Calculate loudspeaker weights for a simply connected array.
390393
391-
The weights are calculated according to the midpoint rule
394+
The weights are calculated according to the midpoint rule.
392395
393-
Note: The loudspeaker positions have to be ordered on the closed contour
396+
Note: The loudspeaker positions have to be ordered on the closed
397+
contour.
394398
395399
"""
396400
positions = np.asarray(positions)

sfs/defs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Definition of constants"""
1+
"""Definition of constants."""
22

33
# speed of sound
44
c = 343

sfs/mono/drivingfunction.py

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ def wfs_2d_line(omega, x0, n0, xs, c=None):
1313
1414
::
1515
16-
17-
D(x0,k) = j k (x0-xs) n0 / |x0-xs| * H1(k |x0-xs|)
18-
16+
D(x0,k) = j k (x0-xs) n0 / |x0-xs| * H1(k |x0-xs|)
1917
2018
"""
2119
x0 = np.asarray(x0)
@@ -32,9 +30,9 @@ def _wfs_point(omega, x0, n0, xs, c=None):
3230
3331
::
3432
35-
(x0-xs) n0
36-
D(x0,k) = j k ------------- e^(-j k |x0-xs|)
37-
|x0-xs|^(3/2)
33+
(x0-xs) n0
34+
D(x0,k) = j k ------------- e^(-j k |x0-xs|)
35+
|x0-xs|^(3/2)
3836
3937
"""
4038
x0 = np.asarray(x0)
@@ -54,9 +52,9 @@ def wfs_25d_point(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
5452
5553
::
5654
57-
____________ (x0-xs) n0
58-
D(x0,k) = \|j k |xref-x0| ------------- e^(-j k |x0-xs|)
59-
|x0-xs|^(3/2)
55+
____________ (x0-xs) n0
56+
D(x0,k) = \|j k |xref-x0| ------------- e^(-j k |x0-xs|)
57+
|x0-xs|^(3/2)
6058
6159
"""
6260
x0 = np.asarray(x0)
@@ -80,7 +78,7 @@ def _wfs_plane(omega, x0, n0, n=[0, 1, 0], c=None):
8078
8179
Eq.(17) from [Spors et al, 2008]::
8280
83-
D(x0,k) = j k n n0 e^(-j k n x0)
81+
D(x0,k) = j k n n0 e^(-j k n x0)
8482
8583
"""
8684
x0 = np.asarray(x0)
@@ -99,8 +97,8 @@ def wfs_25d_plane(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None,
9997
10098
::
10199
102-
____________
103-
D_2.5D(x0,w) = \|j k |xref-x0| n n0 e^(-j k n x0)
100+
____________
101+
D_2.5D(x0,w) = \|j k |xref-x0| n n0 e^(-j k n x0)
104102
105103
"""
106104
x0 = np.asarray(x0)
@@ -117,7 +115,7 @@ def wfs_25d_plane(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None,
117115

118116

119117
def wfs_25d_preeq(omega, omalias, c):
120-
"""Preqeualization for 2.5D WFS"""
118+
"""Preqeualization for 2.5D WFS."""
121119
if omalias is None:
122120
return np.sqrt(1j * util.wavenumber(omega, c))
123121
else:
@@ -186,11 +184,11 @@ def nfchoa_25d_point(omega, x0, r0, xs, c=None):
186184
187185
::
188186
189-
__ (2)
190-
1 \ h|m| (w/c r)
191-
D(phi0,w) = ----- /__ ------------- e^(i m (phi0-phi))
192-
2pi r0 m=-N..N (2)
193-
h|m| (w/c r0)
187+
__ (2)
188+
1 \ h|m| (w/c r)
189+
D(phi0,w) = ----- /__ ------------- e^(i m (phi0-phi))
190+
2pi r0 m=-N..N (2)
191+
h|m| (w/c r0)
194192
195193
"""
196194
x0 = np.asarray(x0)
@@ -218,6 +216,7 @@ def nfchoa_25d_plane(omega, x0, r0, n=[0, 1, 0], c=None):
218216
D_25D(phi0,w) = -- /__ ------------------ e^(i m (phi0-phi_pw) )
219217
r0 m=-N..N (2)
220218
w/c h|m| (w/c r0)
219+
221220
"""
222221
x0 = np.asarray(x0)
223222
k = util.wavenumber(omega, c)
@@ -238,11 +237,10 @@ def nfchoa_25d_plane(omega, x0, r0, n=[0, 1, 0], c=None):
238237
def sdm_2d_line(omega, x0, n0, xs, c=None):
239238
"""Line source by two-dimensional SDM.
240239
241-
The secondary sources have to be located on the x-axis (y0=0).
242-
Derived from [Spors 2009, 126th AES Convention], Eq.(9), Eq.(4)
243-
::
240+
The secondary sources have to be located on the x-axis (y0=0).
241+
Derived from [Spors 2009, 126th AES Convention], Eq.(9), Eq.(4)::
244242
245-
D(x0,k) =
243+
D(x0,k) =
246244
247245
"""
248246
x0 = np.asarray(x0)
@@ -257,11 +255,10 @@ def sdm_2d_line(omega, x0, n0, xs, c=None):
257255
def sdm_2d_plane(omega, x0, n0, n=[0, 1, 0], c=None):
258256
"""Plane wave by two-dimensional SDM.
259257
260-
The secondary sources have to be located on the x-axis (y0=0).
261-
Derived from [Ahrens 2011, Springer], Eq.(3.73), Eq.(C.5), Eq.(C.11)
262-
::
258+
The secondary sources have to be located on the x-axis (y0=0).
259+
Derived from [Ahrens 2011, Springer], Eq.(3.73), Eq.(C.5), Eq.(C.11)::
263260
264-
D(x0,k) = kpw,y * e^(-j*kpw,x*x)
261+
D(x0,k) = kpw,y * e^(-j*kpw,x*x)
265262
266263
"""
267264
x0 = np.asarray(x0)
@@ -274,11 +271,10 @@ def sdm_2d_plane(omega, x0, n0, n=[0, 1, 0], c=None):
274271
def sdm_25d_plane(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None):
275272
"""Plane wave by 2.5-dimensional SDM.
276273
277-
The secondary sources have to be located on the x-axis (y0=0).
278-
Eq.(3.79) from [Ahrens 2011, Springer].
279-
::
274+
The secondary sources have to be located on the x-axis (y0=0).
275+
Eq.(3.79) from [Ahrens 2011, Springer]::
280276
281-
D_2.5D(x0,w) =
277+
D_2.5D(x0,w) =
282278
283279
"""
284280
x0 = np.asarray(x0)
@@ -293,13 +289,10 @@ def sdm_25d_plane(omega, x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None):
293289
def sdm_25d_point(omega, x0, n0, xs, xref=[0, 0, 0], c=None):
294290
"""Point source by 2.5-dimensional SDM.
295291
296-
The secondary sources have to be located on the x-axis (y0=0).
297-
Driving funcnction from [Spors 2010, 128th AES Covention], Eq.(24)
298-
299-
::
300-
301-
D(x0,k) =
292+
The secondary sources have to be located on the x-axis (y0=0).
293+
Driving funcnction from [Spors 2010, 128th AES Covention], Eq.(24)::
302294
295+
D(x0,k) =
303296
304297
"""
305298
x0 = np.asarray(x0)

sfs/mono/soundfigure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def wfs_3d_pw(omega, x0, n0, figure, npw=[0, 0, 1], c=None):
99
"""Compute driving function for a 2D sound figure.
1010
1111
Based on
12-
[Hewani et al., The Synthesis of Sound Figures, MSSP, 2013]
12+
[Helwani et al., The Synthesis of Sound Figures, MSSP, 2013]
13+
1314
"""
1415

1516
x0 = np.asarray(x0)

sfs/mono/source.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def point(omega, x0, n0, grid, c=None):
2727
2828
::
2929
30-
1 e^(-j w/c |x-x0|)
31-
G(x-x0, w) = --- -----------------
32-
4pi |x-x0|
30+
1 e^(-j w/c |x-x0|)
31+
G(x-x0, w) = --- -----------------
32+
4pi |x-x0|
3333
3434
Examples
3535
--------
@@ -65,28 +65,30 @@ def point_modal(omega, x0, n0, grid, L, N=None, deltan=0, c=None):
6565
----------
6666
omega : float
6767
Frequency of source.
68-
x0 : triple of floats
68+
x0 : (3,) array_like
6969
Position of source.
70-
n0 : triple of floats
71-
Normal vector (direction) of source (only required for compatibility).
72-
grid : list of numpy.ndarrays
70+
n0 : (3,) array_like
71+
Normal vector (direction) of source (only required for
72+
compatibility).
73+
grid : triple of numpy.ndarray
7374
The grid that is used for the sound field calculations.
74-
L : triple of floats
75+
L : (3,) array_like
7576
Dimensionons of the rectangular room.
76-
N : triple of integers or integer
77+
N : (3,) array_like or int, optional
7778
Combination of modal orders in the three-spatial dimensions to
78-
calculate the sound field for or maximum order for all dimensions.
79-
If not given, the maximum modal order is approximately determined and
80-
the sound field is computed up to this maximum order.
81-
deltan : float
79+
calculate the sound field for or maximum order for all
80+
dimensions. If not given, the maximum modal order is
81+
approximately determined and the sound field is computed up to
82+
this maximum order.
83+
deltan : float, optional
8284
Absorption coefficient of the walls.
83-
c : float
85+
c : float, optional
8486
Speed of sound.
8587
8688
Returns
8789
-------
88-
p : array of floats
89-
Sound pressure at positions given by grid
90+
numpy.ndarray
91+
Sound pressure at positions given by `grid`.
9092
9193
"""
9294
k = util.wavenumber(omega, c)
@@ -134,8 +136,8 @@ def line(omega, x0, n0, grid, c=None):
134136
135137
::
136138
137-
(2)
138-
G(x-x0, w) = -j/4 H0 (w/c |x-x0|)
139+
(2)
140+
G(x-x0, w) = -j/4 H0 (w/c |x-x0|)
139141
140142
Examples
141143
--------
@@ -174,8 +176,8 @@ def line_dipole(omega, x0, n0, grid, c=None):
174176
175177
::
176178
177-
(2)
178-
G(x-x0, w) = jk/4 H1 (w/c |x-x0|) cos(phi)
179+
(2)
180+
G(x-x0, w) = jk/4 H1 (w/c |x-x0|) cos(phi)
179181
180182
181183
"""
@@ -196,7 +198,7 @@ def plane(omega, x0, n0, grid, c=None):
196198
197199
::
198200
199-
G(x, w) = e^(-i w/c n x)
201+
G(x, w) = e^(-i w/c n x)
200202
201203
Example
202204
-------
@@ -219,7 +221,7 @@ def plane(omega, x0, n0, grid, c=None):
219221

220222

221223
def _duplicate_zdirection(p, grid):
222-
"""If necessary, duplicate field in z-direction"""
224+
"""If necessary, duplicate field in z-direction."""
223225
gridshape = np.broadcast(*grid).shape
224226
if len(gridshape) > 2:
225227
return np.tile(p, [1, 1, gridshape[2]])

sfs/mono/synthesized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def generic(omega, x0, n0, d, grid, c=None, source=point):
8-
"""Compute sound field for a generic driving function"""
8+
"""Compute sound field for a generic driving function."""
99
d = np.squeeze(np.asarray(d))
1010
if len(d) != len(x0):
1111
raise ValueError("length mismatch")

sfs/plot.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Plot sound fields etc"""
1+
"""Plot sound fields etc."""
22

33
import matplotlib.pyplot as plt
44
from matplotlib.patches import Polygon
@@ -44,7 +44,7 @@ def virtualsource_2d(xs, ns=None, type='point', ax=None):
4444

4545

4646
def reference_2d(xref, size=0.1, ax=None):
47-
"""Draw reference/normalization point"""
47+
"""Draw reference/normalization point."""
4848
xref = np.asarray(xref)
4949
if ax is None:
5050
ax = plt.axes()
@@ -126,7 +126,7 @@ def loudspeaker_2d(x0, n0, a0=None, w=0.08, h=0.08, index=False, grid=None):
126126

127127

128128
def _visible_secondarysources_2d(x0, n0, grid):
129-
"""Determines secondary sources which lie within grid"""
129+
"""Determine secondary sources which lie within `grid`."""
130130
grid = util.asarray_of_arrays(grid)
131131
x, y = grid[:2]
132132
idx = np.where((x0[:, 0] > x.min()) & (x0[:, 0] < x.max()) &
@@ -137,8 +137,7 @@ def _visible_secondarysources_2d(x0, n0, grid):
137137

138138

139139
def loudspeaker_3d(x0, n0, a0=None, w=0.08, h=0.08):
140-
"""Plot positions and normal vectors of a 3D secondary source
141-
distribution."""
140+
"""Plot positions and normals of a 3D secondary source distribution."""
142141
fig = plt.figure(figsize=(15, 15))
143142
ax = fig.add_subplot(111, projection='3d')
144143
ax.quiver(x0[:, 0], x0[:, 1], x0[:, 2], n0[:, 0],

0 commit comments

Comments
 (0)