2424 grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
2525
2626 array = sfs.array.circular(N=32, R=R)
27+ array2 = sfs.array.circular(N=64, R=R)
2728
2829 def plot(d, selection, secondary_source):
2930 p = sfs.fd.synthesize(d, selection, array, secondary_source, grid=grid)
@@ -220,39 +221,38 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
220221 .. plot::
221222 :context: close-figs
222223
223- array = sfs.array.circular(N=128, R=R)
224- f = 343*4 # Hz
225- omega = 2 * np.pi * f # rad/s
226-
227- # example is hard coded for a point source on negative x-axis:
228- xs = -4, 0, 0
224+ xs = -4, 0, 0 # point source on negative x-axis
229225 xref_line = 0 # reference contour is a straight line
230226
231- # calc xref(x0):
232- x0_ = array.x.T[np.newaxis, :]
233- xs_ = np.array(xs)[np.newaxis, :, np.newaxis]
234- x0xs = x0_ - xs_
227+ lmb = 1 / 4 # m
228+ f = sfs.default.c / lmb # Hz
229+ omega = 2 * np.pi * f # rad/s
230+
231+ # calc reference contour xref(x0):
232+ x0_tmp = array2.x.T[np.newaxis, :]
233+ xs_tmp = np.array(xs)[np.newaxis, :, np.newaxis]
234+ x0xs = x0_tmp - xs_tmp
235235 x0xs_length = np.linalg.norm(x0xs, axis=1)
236236 x0xs_unit = x0xs / x0xs_length
237- n0_ = array .n.T[np.newaxis, :]
238- xref = np.zeros_like(x0_ )
237+ n0_ = array2 .n.T[np.newaxis, :]
238+ xref = np.zeros_like(x0_tmp )
239239 # cf. https://github.com/spatialaudio/wfs_chapter_hda/blob/master/python/wfs25d_circSSD.py#L91 # noqa
240- # hard coded for a point source on negative x-axis
241- for i in range(array .x.shape[0]):
240+ # code is valid for a virtual point source on negative x-axis:
241+ for i in range(array2 .x.shape[0]):
242242 cosbeta = np.dot(-n0_[0, :, i], [-1, 0, 0]) # use outward SSD normal
243243 tmp = x0xs_unit[0, :, i]
244244 tmp *= -x0xs_length[0, i]
245245 tmp *= xref_line + R * cosbeta
246- tmp /= xs_ [0, 0, 0] + R * cosbeta
247- xref[0, :, i] = x0_ [0, :, i] + tmp
246+ tmp /= xs_tmp [0, 0, 0] + R * cosbeta
247+ xref[0, :, i] = x0_tmp [0, :, i] + tmp
248248 xref = np.squeeze(xref).T
249249
250250 d, selection, secondary_source = sfs.fd.wfs.point_25d(
251- omega, array .x, array .n, xs, xref=xref)
251+ omega, array2 .x, array2 .n, xs, xref=xref)
252252 normalize_gain = 4 * np.pi * np.linalg.norm(xs)
253253 p = sfs.fd.synthesize(d * normalize_gain,
254254 selection,
255- array ,
255+ array2 ,
256256 secondary_source,
257257 grid=grid)
258258
@@ -263,12 +263,12 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
263263 sfs.plot2d.level(p, grid, vmax=6, vmin=-6,
264264 cmap='seismic', ax=ax_lvl,
265265 colorbar_kwargs={'label': 'dB'})
266- sfs.plot2d.loudspeakers(array .x, array .n,
267- selection * array .a,
268- size=0.15 , ax=ax_amp)
269- sfs.plot2d.loudspeakers(array .x, array .n,
270- selection * array .a,
271- size=0.15 , ax=ax_lvl)
266+ sfs.plot2d.loudspeakers(array2 .x, array2 .n,
267+ selection * array2 .a,
268+ size=0.125 , ax=ax_amp)
269+ sfs.plot2d.loudspeakers(array2 .x, array2 .n,
270+ selection * array2 .a,
271+ size=0.125 , ax=ax_lvl)
272272 # plot xref(x0) contour:
273273 ax_amp.plot(xref[:, 0][selection],
274274 xref[:, 1][selection], 'C5o', ms=4)
@@ -279,28 +279,28 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
279279 .. plot::
280280 :context: close-figs
281281
282- f = 343*4 # Hz
283- omega = 2 * np.pi * f # rad/s
284-
285- # example is hard coded for a point source on negative x-axis:
286- xs = -4, 0, 0
282+ xs = -4, 0, 0 # point source on negative x-axis
287283 xref_dist = 4 # radius for reference contour circle with origin xs
288284
289- # calc xref(x0):
290- x0_ = array.x.T[np.newaxis, :]
291- xs_ = np.array(xs)[np.newaxis, :, np.newaxis]
292- x0xs = x0_ - xs_
285+ lmb = 1 / 4 # m
286+ f = sfs.default.c / lmb # Hz
287+ omega = 2 * np.pi * f # rad/s
288+
289+ # calc reference contour xref(x0):
290+ x0_tmp = array2.x.T[np.newaxis, :]
291+ xs_tmp = np.array(xs)[np.newaxis, :, np.newaxis]
292+ x0xs = x0_tmp - xs_tmp
293293 x0xs_length = np.linalg.norm(x0xs, axis=1)
294294 x0xs_unit = x0xs / x0xs_length
295- xref = x0_ + (xref_dist - x0xs_length) * x0xs_unit
295+ xref = x0_tmp + (xref_dist - x0xs_length) * x0xs_unit
296296 xref = np.squeeze(xref).T
297297
298298 d, selection, secondary_source = sfs.fd.wfs.point_25d(
299- omega, array .x, array .n, xs, xref=xref)
299+ omega, array2 .x, array2 .n, xs, xref=xref)
300300 normalize_gain = 4 * np.pi * np.linalg.norm(xs)
301301 p = sfs.fd.synthesize(d * normalize_gain,
302302 selection,
303- array ,
303+ array2 ,
304304 secondary_source,
305305 grid=grid)
306306
@@ -311,12 +311,12 @@ def point_25d(omega, x0, n0, xs, xref=[0, 0, 0], c=None, omalias=None):
311311 sfs.plot2d.level(p, grid, vmax=6, vmin=-6,
312312 cmap='seismic', ax=ax_lvl,
313313 colorbar_kwargs={'label': 'dB'})
314- sfs.plot2d.loudspeakers(array .x, array .n,
315- selection * array .a,
316- size=0.15 , ax=ax_amp)
317- sfs.plot2d.loudspeakers(array .x, array .n,
318- selection * array .a,
319- size=0.15 , ax=ax_lvl)
314+ sfs.plot2d.loudspeakers(array2 .x, array2 .n,
315+ selection * array2 .a,
316+ size=0.125 , ax=ax_amp)
317+ sfs.plot2d.loudspeakers(array2 .x, array2 .n,
318+ selection * array2 .a,
319+ size=0.125 , ax=ax_lvl)
320320 # plot xref(x0) contour:
321321 ax_amp.plot(xref[:, 0][selection],
322322 xref[:, 1][selection], 'C5o', ms=4)
0 commit comments