Skip to content

Commit 73edddb

Browse files
committed
Fixed error for scalar angles in angular.sht_matrix
1 parent 27cb0f7 commit 73edddb

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

examples/modal_beamforming_rigid_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import micarray
99

1010
N = 20 # order of modal beamformer/microphone array
11-
azi_pw = np.array([np.pi]) # incidence angle of plane wave
11+
azi_pw = np.pi # incidence angle of plane wave
1212
azi_pwd = np.linspace(0, 2*np.pi, 91, endpoint=False) # angles for plane wave decomposition
1313
kr = np.linspace(0.1, 20, 100) # wavenumber-radius vector
1414

micarray/modal/angular.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from __future__ import division
22
import numpy as np
33
from scipy import special
4+
from .. import util
45

56

67
def sht_matrix(N, azi, elev, weights=None):
78
""" (N+1)**2 x M SHT matrix"""
9+
azi = util.asarray_1d(azi)
10+
elev = util.asarray_1d(elev)
811
if azi.ndim == 0:
912
M = 1
1013
else:

micarray/util.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,20 @@ def coherence_of_columns(A):
1717
for j in range(N):
1818
Gram_A[j, j] = 0
1919
return np.max(np.abs(Gram_A))
20+
21+
22+
def asarray_1d(a, **kwargs):
23+
"""Squeeze the input and check if the result is one-dimensional.
24+
25+
Returns *a* converted to a `numpy.ndarray` and stripped of
26+
all singleton dimensions. Scalars are "upgraded" to 1D arrays.
27+
The result must have exactly one dimension.
28+
If not, an error is raised.
29+
30+
"""
31+
result = np.squeeze(np.asarray(a, **kwargs))
32+
if result.ndim == 0:
33+
result = result.reshape((1,))
34+
elif result.ndim > 1:
35+
raise ValueError("array must be one-dimensional")
36+
return result

0 commit comments

Comments
 (0)