11from __future__ import division
22import numpy as np
33from scipy import special
4+ from .. import util
45
56
6- def spherical (N , kr , setup , plane_wave ):
7- if np .isscalar (kr ):
8- kr = np .asarray ([kr ])
7+ def spherical_pw (N , k , r , setup ):
8+ r"""Radial coefficients for a plane wave
9+
10+ Computes the radial component of the spherical harmonics expansion of a
11+ plane wave impinging on a spherical array.
12+
13+ .. math::
14+
15+ \mathring{P}_n(k) = 4 \pi i^n b_n(kr)
16+
17+ Parameters
18+ ----------
19+ N : int
20+ Maximum order.
21+ k : array_like
22+ Wavenumber.
23+ r : float
24+ Radius of microphone array.
25+ setup : {'open', 'card', 'rigid'}
26+ Array configuration (open, cardioids, rigid).
27+
28+ Returns
29+ -------
30+ numpy.ndarray
31+ Radial weights for all orders up to N and the given wavenumbers.
32+ """
33+ kr = util .asarray_1d (k * r )
34+ n = np .arange (N + 1 )
35+
36+ bn = weights (N , kr , setup )
37+ for i , x in enumerate (kr ):
38+ bn [i , :] = bn [i , :] * 4 * np .pi * (1j )** n
39+ return bn
40+
41+
42+ def spherical_ps (N , k , r , rs , setup ):
43+ r"""Radial coefficients for a point source
44+
45+ Computes the radial component of the spherical harmonics expansion of a
46+ point source impinging on a spherical array.
47+
48+ .. math::
49+
50+ \mathring{P}_n(k) = 4 \pi (-i) k h_n^{(2)}(k r_s) b_n(kr)
51+
52+ Parameters
53+ ----------
54+ N : int
55+ Maximum order.
56+ k : array_like
57+ Wavenumber.
58+ r : float
59+ Radius of microphone array.
60+ rs : float
61+ Distance of source.
62+ setup : {'open', 'card', 'rigid'}
63+ Array configuration (open, cardioids, rigid).
64+
65+ Returns
66+ -------
67+ numpy.ndarray
68+ Radial weights for all orders up to N and the given wavenumbers.
69+ """
70+ k = util .asarray_1d (k )
71+ krs = k * rs
72+ n = np .arange (N + 1 )
73+
74+ bn = weights (N , k * r , setup )
75+ for i , x in enumerate (krs ):
76+ hn = special .spherical_jn (n , x ) - 1j * special .spherical_yn (n , x )
77+ bn [i , :] = bn [i , :] * 4 * np .pi * (- 1j ) * hn * k [i ]
78+
79+ return bn
80+
81+
82+ def weights (N , kr , setup ):
83+ r"""Radial weighing functions
84+
85+ Computes the radial weighting functions for diferent array types
86+ (cf. eq.(2.62), Rafaely 2015).
87+
88+ For instance for an rigid array
89+
90+ .. math::
91+
92+ b_n(kr) = j_n(kr) - \frac{j_n^\prime(kr)}{h_n^{(2)\prime}(kr)}h_n^{(2)}(kr)
93+
94+ Parameters
95+ ----------
96+ N : int
97+ Maximum order.
98+ kr : array_like
99+ Wavenumber * radius.
100+ setup : {'open', 'card', 'rigid'}
101+ Array configuration (open, cardioids, rigid).
102+
103+ Returns
104+ -------
105+ numpy.ndarray
106+ Radial weights for all orders up to N and the given wavenumbers.
107+
108+ """
9109 n = np .arange (N + 1 )
10110 bns = np .zeros ((len (kr ), N + 1 ), dtype = complex )
11111 for i , x in enumerate (kr ):
@@ -21,11 +121,8 @@ def spherical(N, kr, setup, plane_wave):
21121 bn = jn - jnd / hnd * hn
22122 else :
23123 raise ValueError ('setup must be either: open, card or rigid' )
24- if plane_wave :
25- bn = bn * 4 * np .pi * (1j )** n
26124 bns [i , :] = bn
27- bns = np .squeeze (bns )
28- return bns
125+ return np .squeeze (bns )
29126
30127
31128def regularize (dn , a0 , method ):
0 commit comments