Skip to content

Commit 66dc41c

Browse files
fs446mgeier
authored andcommitted
New mono drivingfunction handling (#125)
1 parent 552c306 commit 66dc41c

10 files changed

+1512
-1434
lines changed

doc/examples/horizontal_plane_arrays.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,34 @@ def compute_and_plot_soundfield(title):
4646
# linear array, secondary point sources, virtual monopole
4747
array = sfs.array.linear(N, dx, center=acenter, orientation=anormal)
4848

49-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_point(
49+
d, selection, secondary_source = sfs.mono.wfs.point_3d(
5050
omega, array.x, array.n, xs)
5151
compute_and_plot_soundfield('linear_ps_wfs_3d_point')
5252

53-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
53+
d, selection, secondary_source = sfs.mono.wfs.point_25d(
5454
omega, array.x, array.n, xs, xref=xnorm)
5555
compute_and_plot_soundfield('linear_ps_wfs_25d_point')
5656

57-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_point(
57+
d, selection, secondary_source = sfs.mono.wfs.point_2d(
5858
omega, array.x, array.n, xs)
5959
compute_and_plot_soundfield('linear_ps_wfs_2d_point')
6060

6161
# linear array, secondary line sources, virtual line source
62-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_line(
62+
d, selection, secondary_source = sfs.mono.wfs.line_2d(
6363
omega, array.x, array.n, xs)
6464
compute_and_plot_soundfield('linear_ls_wfs_2d_line')
6565

6666

6767
# linear array, secondary point sources, virtual plane wave
68-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_plane(
68+
d, selection, secondary_source = sfs.mono.wfs.plane_3d(
6969
omega, array.x, array.n, npw)
7070
compute_and_plot_soundfield('linear_ps_wfs_3d_plane')
7171

72-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
72+
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
7373
omega, array.x, array.n, npw, xref=xnorm)
7474
compute_and_plot_soundfield('linear_ps_wfs_25d_plane')
7575

76-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_plane(
76+
d, selection, secondary_source = sfs.mono.wfs.plane_2d(
7777
omega, array.x, array.n, npw)
7878
compute_and_plot_soundfield('linear_ps_wfs_2d_plane')
7979

@@ -82,11 +82,11 @@ def compute_and_plot_soundfield(title):
8282
array = sfs.array.linear_diff(N//3 * [dx] + N//3 * [dx/2] + N//3 * [dx],
8383
center=acenter, orientation=anormal)
8484

85-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
85+
d, selection, secondary_source = sfs.mono.wfs.point_25d(
8686
omega, array.x, array.n, xs, xref=xnorm)
8787
compute_and_plot_soundfield('linear_nested_ps_wfs_25d_point')
8888

89-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
89+
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
9090
omega, array.x, array.n, npw, xref=xnorm)
9191
compute_and_plot_soundfield('linear_nested_ps_wfs_25d_plane')
9292

@@ -95,34 +95,34 @@ def compute_and_plot_soundfield(title):
9595
array = sfs.array.linear_random(N, dx/2, 1.5*dx, center=acenter,
9696
orientation=anormal)
9797

98-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
98+
d, selection, secondary_source = sfs.mono.wfs.point_25d(
9999
omega, array.x, array.n, xs, xref=xnorm)
100100
compute_and_plot_soundfield('linear_random_ps_wfs_25d_point')
101101

102-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
102+
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
103103
omega, array.x, array.n, npw, xref=xnorm)
104104
compute_and_plot_soundfield('linear_random_ps_wfs_25d_plane')
105105

106106

107107
# rectangular array, secondary point sources
108108
array = sfs.array.rectangular((N, N//2), dx, center=acenter, orientation=anormal)
109-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
109+
d, selection, secondary_source = sfs.mono.wfs.point_25d(
110110
omega, array.x, array.n, xs, xref=xnorm)
111111
compute_and_plot_soundfield('rectangular_ps_wfs_25d_point')
112112

113-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
113+
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
114114
omega, array.x, array.n, npw, xref=xnorm)
115115
compute_and_plot_soundfield('rectangular_ps_wfs_25d_plane')
116116

117117

118118
# circular array, secondary point sources
119119
N = 60
120120
array = sfs.array.circular(N, 1, center=acenter)
121-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(
121+
d, selection, secondary_source = sfs.mono.wfs.point_25d(
122122
omega, array.x, array.n, xs, xref=xnorm)
123123
compute_and_plot_soundfield('circular_ps_wfs_25d_point')
124124

125-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(
125+
d, selection, secondary_source = sfs.mono.wfs.plane_25d(
126126
omega, array.x, array.n, npw, xref=xnorm)
127127
compute_and_plot_soundfield('circular_ps_wfs_25d_plane')
128128

@@ -132,7 +132,7 @@ def compute_and_plot_soundfield(title):
132132
xnorm = [0, 0, 0]
133133
talpha = 0 # switches off tapering
134134

135-
d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_2d_plane(
135+
d, selection, secondary_source = sfs.mono.nfchoa.plane_2d(
136136
omega, array.x, 1, npw)
137137
compute_and_plot_soundfield('circular_ls_nfchoa_2d_plane')
138138

@@ -142,10 +142,10 @@ def compute_and_plot_soundfield(title):
142142
xnorm = [0, 0, 0]
143143
talpha = 0 # switches off tapering
144144

145-
d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_point(
145+
d, selection, secondary_source = sfs.mono.nfchoa.point_25d(
146146
omega, array.x, 1, xs)
147147
compute_and_plot_soundfield('circular_ps_nfchoa_25d_point')
148148

149-
d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_plane(
149+
d, selection, secondary_source = sfs.mono.nfchoa.plane_25d(
150150
omega, array.x, 1, npw)
151151
compute_and_plot_soundfield('circular_ps_nfchoa_25d_plane')

doc/examples/sound_field_synthesis.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@
4444

4545

4646
# === compute driving function and determine active secondary sources ===
47-
#d, selection, secondary_source = sfs.mono.drivingfunction.delay_3d_plane(omega, array.x, array.n, npw)
47+
#d, selection, secondary_source = sfs.mono.wfs.plane_3d_delay(omega, array.x, array.n, npw)
4848

49-
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_line(omega, array.x, array.n, xs)
49+
#d, selection, secondary_source = sfs.mono.wfs.line_2d(omega, array.x, array.n, xs)
5050

51-
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_plane(omega, array.x, array.n, npw)
52-
d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_plane(omega, array.x, array.n, npw, xref)
53-
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_plane(omega, array.x, array.n, npw)
51+
#d, selection, secondary_source = sfs.mono.wfs.plane_2d(omega, array.x, array.n, npw)
52+
d, selection, secondary_source = sfs.mono.wfs.plane_25d(omega, array.x, array.n, npw, xref)
53+
#d, selection, secondary_source = sfs.mono.wfs.plane_3d(omega, array.x, array.n, npw)
5454

55-
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_2d_point(omega, array.x, array.n, xs)
56-
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_25d_point(omega, array.x, array.n, xs)
57-
#d, selection, secondary_source = sfs.mono.drivingfunction.wfs_3d_point(omega, array.x, array.n, xs)
55+
#d, selection, secondary_source = sfs.mono.wfs.point_2d(omega, array.x, array.n, xs)
56+
#d, selection, secondary_source = sfs.mono.wfs.point_25d(omega, array.x, array.n, xs)
57+
#d, selection, secondary_source = sfs.mono.wfs.point_3d(omega, array.x, array.n, xs)
5858

59-
#d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_2d_plane(omega, array.x, R, npw)
59+
#d, selection, secondary_source = sfs.mono.nfchoa.plane_2d(omega, array.x, R, npw)
6060

61-
#d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_point(omega, array.x, R, xs)
62-
#d, selection, secondary_source = sfs.mono.drivingfunction.nfchoa_25d_plane(omega, array.x, R, npw)
61+
#d, selection, secondary_source = sfs.mono.nfchoa.point_25d(omega, array.x, R, xs)
62+
#d, selection, secondary_source = sfs.mono.nfchoa.plane_25d(omega, array.x, R, npw)
6363

6464

6565
# === compute tapering window ===

doc/examples/soundfigures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# driving function for sound figure
3030
figure = np.array(Image.open('figures/tree.png')) # read image from file
3131
figure = np.rot90(figure) # turn 0deg to the top
32-
d, selection, secondary_source = sfs.mono.soundfigure.wfs_3d_pw(
32+
d, selection, secondary_source = sfs.mono.wfs.soundfigure_3d(
3333
omega, array.x, array.n, figure, npw=npw)
3434

3535
# compute synthesized sound field

sfs/mono/__init__.py

+30-7
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
.. autosummary::
44
:toctree:
55
6-
drivingfunction
76
source
8-
soundfigure
97
10-
"""
11-
import numpy as _np
8+
wfs
9+
nfchoa
10+
sdm
11+
esa
1212
13-
from . import drivingfunction
13+
"""
1414
from . import source
15-
from . import soundfigure
16-
1715
from .. import array as _array
16+
import numpy as _np
1817

1918

2019
def shiftphase(p, phase):
@@ -58,3 +57,27 @@ def synthesize(d, weights, ssd, secondary_source_function, **kwargs):
5857
if weight != 0:
5958
p += a * weight * d * secondary_source_function(x, n, **kwargs)
6059
return p
60+
61+
62+
def secondary_source_point(omega, c):
63+
"""Create a point source for use in `sfs.mono.synthesize()`."""
64+
65+
def secondary_source(position, _, grid):
66+
return source.point(omega, position, grid, c)
67+
68+
return secondary_source
69+
70+
71+
def secondary_source_line(omega, c):
72+
"""Create a line source for use in `sfs.mono.synthesize()`."""
73+
74+
def secondary_source(position, _, grid):
75+
return source.line(omega, position, grid, c)
76+
77+
return secondary_source
78+
79+
80+
from . import esa
81+
from . import nfchoa
82+
from . import sdm
83+
from . import wfs

0 commit comments

Comments
 (0)