@@ -126,12 +126,7 @@ def soundfield(p, grid, xnorm=None, colorbar=True, cmap='coolwarm_clip',
126
126
127
127
# normalize sound field wrt xnorm
128
128
if xnorm is not None :
129
- xnorm = util .asarray_1d (xnorm )
130
- r = np .linalg .norm (grid - xnorm )
131
- idx = np .unravel_index (r .argmin (), r .shape )
132
- # p is normally squeezed, therefore we need only 2 dimensions:
133
- idx = idx [:p .ndim ]
134
- p = p / abs (p [idx ])
129
+ p = util .normalize (p , grid , xnorm )
135
130
136
131
x , y = grid [:2 ] # ignore z-component
137
132
@@ -154,7 +149,13 @@ def soundfield(p, grid, xnorm=None, colorbar=True, cmap='coolwarm_clip',
154
149
def level (p , grid , xnorm = None , colorbar = True , cmap = 'coolwarm_clip' ,
155
150
ax = None , xlabel = 'x (m)' , ylabel = 'y (m)' , vmax = 3.0 , vmin = - 50 ,
156
151
** kwargs ):
157
- """Two-dimensional plot of level of sound field."""
158
- im = soundfield (20 * np .log10 (np .abs (p )), grid , xnorm , colorbar , cmap , ax , xlabel , ylabel , vmax , vmin , ** kwargs )
152
+ """Two-dimensional plot of level (dB) of sound field."""
153
+ # normalize sound field wrt xnorm
154
+ if xnorm is not None :
155
+ p = util .normalize (p , grid , xnorm )
159
156
160
- return im
157
+ xnorm = None
158
+ im = soundfield (20 * np .log10 (np .abs (p )), grid , xnorm , colorbar , cmap , ax ,
159
+ xlabel , ylabel , vmax , vmin , ** kwargs )
160
+
161
+ return im
0 commit comments