15
15
16
16
17
17
class ArrayData (namedtuple ('ArrayData' , 'x n a' )):
18
- """Get named tuple returned by array functions.
18
+ """Named tuple returned by array functions.
19
19
20
20
See `collections.namedtuple`.
21
21
@@ -43,7 +43,7 @@ def take(self, indices):
43
43
44
44
45
45
def linear (N , spacing , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
46
- """Get linear, equidistantly sampled secondary source distribution.
46
+ """Return linear, equidistantly sampled secondary source distribution.
47
47
48
48
Parameters
49
49
----------
@@ -78,7 +78,7 @@ def linear(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
78
78
79
79
80
80
def linear_diff (distances , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
81
- """Get linear secondary source distribution from a list of distances.
81
+ """Return linear secondary source distribution from a list of distances.
82
82
83
83
Parameters
84
84
----------
@@ -112,7 +112,7 @@ def linear_diff(distances, center=[0, 0, 0], orientation=[1, 0, 0]):
112
112
113
113
def linear_random (N , min_spacing , max_spacing , center = [0 , 0 , 0 ],
114
114
orientation = [1 , 0 , 0 ], seed = None ):
115
- """Get randomly sampled linear array.
115
+ """Return randomly sampled linear array.
116
116
117
117
Parameters
118
118
----------
@@ -136,11 +136,14 @@ def linear_random(N, min_spacing, max_spacing, center=[0, 0, 0],
136
136
.. plot::
137
137
:context: close-figs
138
138
139
- x0, n0, a0 = sfs.array.linear_random(12, 0.15, 0.4, orientation=[0, -1, 0])
139
+ x0, n0, a0 = sfs.array.linear_random(
140
+ N=12,
141
+ min_spacing=0.15, max_spacing=0.4,
142
+ orientation=[0, -1, 0])
140
143
sfs.plot.loudspeaker_2d(x0, n0, a0)
141
144
plt.axis('equal')
142
145
plt.xlabel('x / m')
143
- plt.ylabel('y / m')
146
+ plt.ylabel('y / m')
144
147
145
148
"""
146
149
r = np .random .RandomState (seed )
@@ -149,7 +152,7 @@ def linear_random(N, min_spacing, max_spacing, center=[0, 0, 0],
149
152
150
153
151
154
def circular (N , R , center = [0 , 0 , 0 ]):
152
- """Get circular secondary source distribution parallel to the xy-plane.
155
+ """Return circular secondary source distribution parallel to the xy-plane.
153
156
154
157
Parameters
155
158
----------
@@ -191,7 +194,7 @@ def circular(N, R, center=[0, 0, 0]):
191
194
192
195
193
196
def rectangular (N , spacing , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
194
- """Get rectangular secondary source distribution.
197
+ """Return rectangular secondary source distribution.
195
198
196
199
Parameters
197
200
----------
@@ -239,7 +242,8 @@ def rectangular(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
239
242
240
243
241
244
def rounded_edge (Nxy , Nr , dx , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
242
- """Get secondary source distribution along the xy-axis with rounded edge at the origin.
245
+ """Return secondary source distribution along the xy-axis with rounded
246
+ edge at the origin.
243
247
244
248
Parameters
245
249
----------
@@ -313,7 +317,8 @@ def rounded_edge(Nxy, Nr, dx, center=[0, 0, 0], orientation=[1, 0, 0]):
313
317
314
318
315
319
def edge (Nxy , dx , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
316
- """Get secondary source distribution along the xy-axis with sharp edge at the origin.
320
+ """Return secondary source distribution along the xy-axis with sharp
321
+ edge at the origin.
317
322
318
323
Parameters
319
324
----------
@@ -365,7 +370,7 @@ def edge(Nxy, dx, center=[0, 0, 0], orientation=[1, 0, 0]):
365
370
366
371
367
372
def planar (N , spacing , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
368
- """Get planar secondary source distribtion.
373
+ """Return planar secondary source distribtion.
369
374
370
375
Parameters
371
376
----------
@@ -389,7 +394,9 @@ def planar(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
389
394
.. plot::
390
395
:context: close-figs
391
396
392
- x0, n0, a0 = sfs.array.planar((4,3), 0.5, center=[0, 0, 0], orientation=[0, 0, 1])
397
+ x0, n0, a0 = sfs.array.planar(
398
+ N=(4,3), spacing=0.5,
399
+ center=[0, 0, 0], orientation=[0, 0, 1])
393
400
sfs.plot.loudspeaker_2d(x0, n0, a0)
394
401
plt.axis('equal')
395
402
plt.xlabel('x / m')
@@ -409,7 +416,7 @@ def planar(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
409
416
410
417
411
418
def cube (N , spacing , center = [0 , 0 , 0 ], orientation = [1 , 0 , 0 ]):
412
- """Get cube-shaped secondary source distribtion.
419
+ """Return cube-shaped secondary source distribtion.
413
420
414
421
Parameters
415
422
----------
@@ -433,7 +440,9 @@ def cube(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
433
440
.. plot::
434
441
:context: close-figs
435
442
436
- x0, n0, a0 = sfs.array.cube(2, 0.5, center=[0, 0, 0], orientation=[1, 0, 0])
443
+ x0, n0, a0 = sfs.array.cube(
444
+ N=2, spacing=0.5,
445
+ center=[0, 0, 0], orientation=[1, 0, 0])
437
446
sfs.plot.loudspeaker_2d(x0, n0, a0)
438
447
plt.axis('equal')
439
448
plt.xlabel('x / m')
@@ -462,8 +471,8 @@ def cube(N, spacing, center=[0, 0, 0], orientation=[1, 0, 0]):
462
471
def sphere_load (file , radius , center = [0 , 0 , 0 ]):
463
472
"""Load spherical secondary source distribution from file.
464
473
465
- ASCII Format (see MATLAB SFS Toolbox) with 4 numbers (3 for the cartesian
466
- position vector, 1 for the integration weight) per secondary source located
474
+ ASCII Format (see MATLAB SFS Toolbox) with 4 numbers (3 for the cartesian
475
+ position vector, 1 for the integration weight) per secondary source located
467
476
on the unit circle which is resized by the given radius and shifted to the
468
477
given center.
469
478
@@ -474,7 +483,7 @@ def sphere_load(file, radius, center=[0, 0, 0]):
474
483
475
484
Examples
476
485
--------
477
- content of ` example_array_6LS_3D.txt`
486
+ content of example_array_6LS_3D.txt
478
487
::
479
488
1 0 0 1
480
489
-1 0 0 1
@@ -489,12 +498,15 @@ def sphere_load(file, radius, center=[0, 0, 0]):
489
498
.. plot::
490
499
:context: close-figs
491
500
492
- x0, n0, a0 = sfs.array.sphere_load('../data/arrays/example_array_6LS_3D.txt', radius=2, center=[0, 0, 0])
501
+ x0, n0, a0 = sfs.array.sphere_load(
502
+ '../data/arrays/example_array_6LS_3D.txt',
503
+ radius=2,
504
+ center=[0, 0, 0])
493
505
sfs.plot.loudspeaker_2d(x0, n0, a0, size=0.25)
494
506
plt.axis('equal')
495
507
plt.xlabel('x / m')
496
508
plt.ylabel('y / m')
497
- plt.title('view onto xy-plane')
509
+ plt.title('view onto xy-plane')
498
510
499
511
"""
500
512
data = np .loadtxt (file )
@@ -509,7 +521,7 @@ def load(file, center=[0, 0, 0], orientation=[1, 0, 0]):
509
521
"""Load secondary source distribution from file.
510
522
511
523
Comma Separated Values (CSV) format with 7 values
512
- (3 for the cartesian position vector, 3 for the cartesian inward normal
524
+ (3 for the cartesian position vector, 3 for the cartesian inward normal
513
525
vector, 1 for the integration weight) per secondary source.
514
526
515
527
Returns
@@ -519,7 +531,7 @@ def load(file, center=[0, 0, 0], orientation=[1, 0, 0]):
519
531
520
532
Examples
521
533
--------
522
- content of ` example_array_4LS_2D.csv`
534
+ content of example_array_4LS_2D.csv
523
535
::
524
536
1,0,0,-1,0,0,1
525
537
0,1,0,0,-1,0,1
@@ -538,6 +550,17 @@ def load(file, center=[0, 0, 0], orientation=[1, 0, 0]):
538
550
plt.xlabel('x / m')
539
551
plt.ylabel('y / m')
540
552
553
+ .. plot::
554
+ :context: close-figs
555
+
556
+ x0, n0, a0 = sfs.array.load(
557
+ '../data/arrays/wfs_university_rostock_2018.csv')
558
+ sfs.plot.loudspeaker_2d(x0, n0, a0)
559
+ plt.axis('equal')
560
+ plt.xlabel('x / m')
561
+ plt.ylabel('y / m')
562
+ plt.title('top view of 64 channel WFS system at university of Rostock')
563
+
541
564
"""
542
565
data = np .loadtxt (file , delimiter = ',' )
543
566
positions , normals , weights = data [:, :3 ], data [:, 3 :6 ], data [:, 6 ]
@@ -574,7 +597,7 @@ def weights_midpoint(positions, closed):
574
597
>>> import sfs
575
598
>>> x0, n0, a0 = sfs.array.circular(2**5, 1)
576
599
>>> a = sfs.array.weights_midpoint(x0, closed=True)
577
- >>> print( max(abs(a0-a) ))
600
+ >>> max(abs(a0-a))
578
601
0.0003152601902411123
579
602
580
603
"""
@@ -616,7 +639,8 @@ def concatenate(*arrays):
616
639
Returns
617
640
-------
618
641
`ArrayData`
619
- Positions, orientations and weights of the concatenated secondary sources.
642
+ Positions, orientations and weights
643
+ of the concatenated secondary sources.
620
644
621
645
Examples
622
646
--------
0 commit comments