acoular 25.10__py3-none-any.whl → 26.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- acoular/aiaa/aiaa.py +1 -1
- acoular/base.py +7 -7
- acoular/calib.py +6 -6
- acoular/demo/__init__.py +97 -9
- acoular/demo/__main__.py +37 -0
- acoular/environments.py +24 -24
- acoular/fbeamform.py +145 -142
- acoular/fprocess.py +11 -9
- acoular/grids.py +45 -211
- acoular/microphones.py +8 -8
- acoular/process.py +7 -14
- acoular/sdinput.py +9 -9
- acoular/signals.py +10 -10
- acoular/sources.py +84 -68
- acoular/spectra.py +27 -36
- acoular/tbeamform.py +26 -26
- acoular/tools/helpers.py +1 -1
- acoular/tools/utils.py +168 -0
- acoular/tprocess.py +76 -63
- acoular/trajectory.py +1 -2
- acoular/version.py +2 -2
- {acoular-25.10.dist-info → acoular-26.1.dist-info}/METADATA +53 -108
- {acoular-25.10.dist-info → acoular-26.1.dist-info}/RECORD +26 -26
- {acoular-25.10.dist-info → acoular-26.1.dist-info}/WHEEL +1 -1
- acoular/demo/acoular_demo.py +0 -135
- {acoular-25.10.dist-info → acoular-26.1.dist-info}/licenses/AUTHORS.rst +0 -0
- {acoular-25.10.dist-info → acoular-26.1.dist-info}/licenses/LICENSE +0 -0
acoular/fprocess.py
CHANGED
|
@@ -51,7 +51,7 @@ class RFFT(BaseSpectra, SpectraOut):
|
|
|
51
51
|
#: The number of workers to use for FFT calculation.
|
|
52
52
|
#: If set to a negative value, all available logical CPUs are used.
|
|
53
53
|
#: Default is ``None``, which relies on the :func:`scipy.fft.rfft` implementation.
|
|
54
|
-
workers = Union(Int(), None, default_value=None
|
|
54
|
+
workers = Union(Int(), None, default_value=None)
|
|
55
55
|
|
|
56
56
|
#: Defines the scaling method for the FFT result. Options are:
|
|
57
57
|
#:
|
|
@@ -79,7 +79,8 @@ class RFFT(BaseSpectra, SpectraOut):
|
|
|
79
79
|
|
|
80
80
|
# Internal representation of the block size for FFT processing.
|
|
81
81
|
# Used for validation and property management.
|
|
82
|
-
|
|
82
|
+
#: block size of the FFT
|
|
83
|
+
_block_size = Int(1024)
|
|
83
84
|
|
|
84
85
|
#: A unique identifier based on the process properties.
|
|
85
86
|
digest = Property(depends_on=['source.digest', 'scaling', 'precision', '_block_size', 'window', 'overlap'])
|
|
@@ -189,12 +190,12 @@ class IRFFT(TimeOut):
|
|
|
189
190
|
#: The number of workers (threads) to use for the IFFT calculation.
|
|
190
191
|
#: A negative value utilizes all available logical CPUs.
|
|
191
192
|
#: Default is ``None``, which relies on the :func:`scipy.fft.irfft` implementation.
|
|
192
|
-
workers = Union(Int(), None, default_value=None
|
|
193
|
+
workers = Union(Int(), None, default_value=None)
|
|
193
194
|
|
|
194
195
|
#: Determines the floating-point precision of the resulting time-domain signals.
|
|
195
196
|
#: Options include ``'float64'`` and ``'float32'``.
|
|
196
197
|
#: Default is ``'float64'``, ensuring high precision.
|
|
197
|
-
precision = Enum('float64', 'float32'
|
|
198
|
+
precision = Enum('float64', 'float32')
|
|
198
199
|
|
|
199
200
|
#: The total number of time-domain samples in the output.
|
|
200
201
|
#: Computed as the product of the number of input samples and the block size.
|
|
@@ -203,7 +204,8 @@ class IRFFT(TimeOut):
|
|
|
203
204
|
|
|
204
205
|
# Internal signal buffer used for handling arbitrary output block sizes. Optimizes
|
|
205
206
|
# processing when the requested output block size does not match the source block size.
|
|
206
|
-
|
|
207
|
+
#: signal buffer
|
|
208
|
+
_buffer = CArray()
|
|
207
209
|
|
|
208
210
|
#: A unique identifier based on the process properties.
|
|
209
211
|
digest = Property(depends_on=['source.digest', 'scaling', 'precision', '_block_size', 'window', 'overlap'])
|
|
@@ -297,11 +299,11 @@ class AutoPowerSpectra(SpectraOut):
|
|
|
297
299
|
scaling = Enum('power', 'psd')
|
|
298
300
|
|
|
299
301
|
#: A Boolean flag indicating whether the input spectra are single-sided. Default is ``True``.
|
|
300
|
-
single_sided = Bool(True
|
|
302
|
+
single_sided = Bool(True)
|
|
301
303
|
|
|
302
304
|
#: Specifies the floating-point precision of the computed auto-power spectra.
|
|
303
305
|
#: Options are ``'float64'`` and ``'float32'``. Default is ``'float64'``.
|
|
304
|
-
precision = Enum('float64', 'float32'
|
|
306
|
+
precision = Enum('float64', 'float32')
|
|
305
307
|
|
|
306
308
|
#: A unique identifier based on the computation properties.
|
|
307
309
|
digest = Property(depends_on=['source.digest', 'precision', 'scaling', 'single_sided'])
|
|
@@ -372,7 +374,7 @@ class CrossPowerSpectra(AutoPowerSpectra):
|
|
|
372
374
|
|
|
373
375
|
#: Specifies the floating-point precision of the computed cross-spectral matrix (CSM).
|
|
374
376
|
#: Options are ``'complex128'`` and ``'complex64'``. Default is ``'complex128'``.
|
|
375
|
-
precision = Enum('complex128', 'complex64'
|
|
377
|
+
precision = Enum('complex128', 'complex64')
|
|
376
378
|
|
|
377
379
|
#: Defines the calculation mode for the cross-spectral matrix:
|
|
378
380
|
#:
|
|
@@ -383,7 +385,7 @@ class CrossPowerSpectra(AutoPowerSpectra):
|
|
|
383
385
|
#: excluding redundant upper-triangle elements.
|
|
384
386
|
#:
|
|
385
387
|
#: Default is ``'full'``.
|
|
386
|
-
calc_mode = Enum('full', 'upper', 'lower'
|
|
388
|
+
calc_mode = Enum('full', 'upper', 'lower')
|
|
387
389
|
|
|
388
390
|
#: The number of channels in the output data. The value depends on the number of input channels
|
|
389
391
|
#: :math:`n` and the selected :attr:`calc_mode`:
|
acoular/grids.py
CHANGED
|
@@ -74,6 +74,7 @@ from traits.trait_errors import TraitError
|
|
|
74
74
|
|
|
75
75
|
# acoular imports
|
|
76
76
|
from .internal import digest, ldigest
|
|
77
|
+
from .tools.utils import Polygon
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
def in_hull(p, hull, border=True, tol=0):
|
|
@@ -128,173 +129,6 @@ def in_hull(p, hull, border=True, tol=0):
|
|
|
128
129
|
return hull.find_simplex(p, tol=tol) > 0
|
|
129
130
|
|
|
130
131
|
|
|
131
|
-
def _det(xvert, yvert):
|
|
132
|
-
xvert = np.asarray(xvert, dtype=float)
|
|
133
|
-
yvert = np.asarray(yvert, dtype=float)
|
|
134
|
-
x_prev = np.concatenate(([xvert[-1]], xvert[:-1]))
|
|
135
|
-
y_prev = np.concatenate(([yvert[-1]], yvert[:-1]))
|
|
136
|
-
return np.sum(yvert * x_prev - xvert * y_prev, axis=0)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
class Polygon:
|
|
140
|
-
"""
|
|
141
|
-
Create an object representing a general polygon in a 2D plane.
|
|
142
|
-
|
|
143
|
-
This class allows defining a polygon by specifying the coordinates of its vertices and provides
|
|
144
|
-
methods for checking whether a set of points lies inside the polygon, or if a point is closer to
|
|
145
|
-
a side or vertex of the polygon.
|
|
146
|
-
|
|
147
|
-
Parameters
|
|
148
|
-
----------
|
|
149
|
-
x : array_like
|
|
150
|
-
Array of x-coordinates of the vertices that define the polygon. These coordinates should
|
|
151
|
-
form a closed shape (i.e., the last point should be the same as the first point).
|
|
152
|
-
|
|
153
|
-
y : array_like
|
|
154
|
-
Array of y-coordinates of the vertices that define the polygon. These coordinates should
|
|
155
|
-
correspond to the x-coordinates, forming a closed shape.
|
|
156
|
-
|
|
157
|
-
Attributes
|
|
158
|
-
----------
|
|
159
|
-
x : :class:`numpy.ndarray`
|
|
160
|
-
Array of x-coordinates of the polygon vertices.
|
|
161
|
-
|
|
162
|
-
y : :class:`numpy.ndarray`
|
|
163
|
-
Array of y-coordinates of the polygon vertices.
|
|
164
|
-
"""
|
|
165
|
-
|
|
166
|
-
def __init__(self, x, y):
|
|
167
|
-
if len(x) != len(y):
|
|
168
|
-
msg = 'x and y must be equally sized.'
|
|
169
|
-
raise IndexError(msg)
|
|
170
|
-
self.x = np.asarray(x, dtype=float)
|
|
171
|
-
self.y = np.asarray(y, dtype=float)
|
|
172
|
-
# Closes the polygon if were open
|
|
173
|
-
x1, y1 = x[0], y[0]
|
|
174
|
-
xn, yn = x[-1], y[-1]
|
|
175
|
-
if x1 != xn or y1 != yn:
|
|
176
|
-
self.x = np.concatenate((self.x, [x1]))
|
|
177
|
-
self.y = np.concatenate((self.y, [y1]))
|
|
178
|
-
# Anti-clockwise coordinates
|
|
179
|
-
if _det(self.x, self.y) < 0:
|
|
180
|
-
self.x = self.x[::-1]
|
|
181
|
-
self.y = self.y[::-1]
|
|
182
|
-
|
|
183
|
-
def is_inside(self, xpoint, ypoint, smalld=1e-12):
|
|
184
|
-
"""
|
|
185
|
-
Check if a point or set of points are inside the polygon.
|
|
186
|
-
|
|
187
|
-
Parameters
|
|
188
|
-
----------
|
|
189
|
-
xpoint : :class:`float` or array_like
|
|
190
|
-
Array of x-coordinates of the points to be tested.
|
|
191
|
-
|
|
192
|
-
ypoint : :class:`float` or array_like
|
|
193
|
-
Array of y-coordinates of the points to be tested.
|
|
194
|
-
|
|
195
|
-
smalld : :class:`float`, optional
|
|
196
|
-
Tolerance used for floating point comparisons when checking if a point is exactly on a
|
|
197
|
-
polygon's edge. The default value is ``1e-12``.
|
|
198
|
-
|
|
199
|
-
Returns
|
|
200
|
-
-------
|
|
201
|
-
:class:`float` or array_like
|
|
202
|
-
The distance from the point to the nearest point on the polygon. The values returned
|
|
203
|
-
have the following meanings:
|
|
204
|
-
- ``mindst < 0``: Point is outside the polygon.
|
|
205
|
-
- ``mindst = 0``: Point is on an edge of the polygon.
|
|
206
|
-
- ``mindst > 0``: Point is inside the polygon.
|
|
207
|
-
|
|
208
|
-
Notes
|
|
209
|
-
-----
|
|
210
|
-
The method uses an improved algorithm based on Nordbeck and Rydstedt for determining
|
|
211
|
-
whether a point is inside a polygon :cite:`SLOAN198545`.
|
|
212
|
-
"""
|
|
213
|
-
xpoint = np.asarray(xpoint, dtype=float)
|
|
214
|
-
ypoint = np.asarray(ypoint, dtype=float)
|
|
215
|
-
# Scalar to array
|
|
216
|
-
if xpoint.shape == ():
|
|
217
|
-
xpoint = np.array([xpoint], dtype=float)
|
|
218
|
-
ypoint = np.array([ypoint], dtype=float)
|
|
219
|
-
scalar = True
|
|
220
|
-
else:
|
|
221
|
-
scalar = False
|
|
222
|
-
# Check consistency
|
|
223
|
-
if xpoint.shape != ypoint.shape:
|
|
224
|
-
msg = 'x and y has different shapes'
|
|
225
|
-
raise IndexError(msg)
|
|
226
|
-
# If snear = True: Dist to nearest side < nearest vertex
|
|
227
|
-
# If snear = False: Dist to nearest vertex < nearest side
|
|
228
|
-
snear = np.ma.masked_all(xpoint.shape, dtype=bool)
|
|
229
|
-
# Initialize arrays
|
|
230
|
-
mindst = np.ones_like(xpoint, dtype=float) * np.inf
|
|
231
|
-
j = np.ma.masked_all(xpoint.shape, dtype=int)
|
|
232
|
-
x = self.x
|
|
233
|
-
y = self.y
|
|
234
|
-
n = len(x) - 1 # Number of sides/vertices defining the polygon
|
|
235
|
-
# Loop over each side defining polygon
|
|
236
|
-
for i in range(n):
|
|
237
|
-
d = np.ones_like(xpoint, dtype=float) * np.inf
|
|
238
|
-
# Start of side has coords (x1, y1)
|
|
239
|
-
# End of side has coords (x2, y2)
|
|
240
|
-
# Point has coords (xpoint, ypoint)
|
|
241
|
-
x1 = x[i]
|
|
242
|
-
y1 = y[i]
|
|
243
|
-
x21 = x[i + 1] - x1
|
|
244
|
-
y21 = y[i + 1] - y1
|
|
245
|
-
x1p = x1 - xpoint
|
|
246
|
-
y1p = y1 - ypoint
|
|
247
|
-
# Points on infinite line defined by
|
|
248
|
-
# x = x1 + t * (x1 - x2)
|
|
249
|
-
# y = y1 + t * (y1 - y2)
|
|
250
|
-
# where
|
|
251
|
-
# t = 0 at (x1, y1)
|
|
252
|
-
# t = 1 at (x2, y2)
|
|
253
|
-
# Find where normal passing through (xpoint, ypoint) intersects
|
|
254
|
-
# infinite line
|
|
255
|
-
t = -(x1p * x21 + y1p * y21) / (x21**2 + y21**2)
|
|
256
|
-
tlt0 = t < 0
|
|
257
|
-
tle1 = (t >= 0) & (t <= 1)
|
|
258
|
-
# Normal intersects side
|
|
259
|
-
d[tle1] = (x1p[tle1] + t[tle1] * x21) ** 2 + (y1p[tle1] + t[tle1] * y21) ** 2
|
|
260
|
-
# Normal does not intersects side
|
|
261
|
-
# Point is closest to vertex (x1, y1)
|
|
262
|
-
# Compute square of distance to this vertex
|
|
263
|
-
d[tlt0] = x1p[tlt0] ** 2 + y1p[tlt0] ** 2
|
|
264
|
-
# Store distances
|
|
265
|
-
mask = d < mindst
|
|
266
|
-
mindst[mask] = d[mask]
|
|
267
|
-
j[mask] = i
|
|
268
|
-
# Point is closer to (x1, y1) than any other vertex or side
|
|
269
|
-
snear[mask & tlt0] = False
|
|
270
|
-
# Point is closer to this side than to any other side or vertex
|
|
271
|
-
snear[mask & tle1] = True
|
|
272
|
-
if np.ma.count(snear) != snear.size:
|
|
273
|
-
msg = 'Error computing distances'
|
|
274
|
-
raise IndexError(msg)
|
|
275
|
-
mindst **= 0.5
|
|
276
|
-
# Point is closer to its nearest vertex than its nearest side, check if
|
|
277
|
-
# nearest vertex is concave.
|
|
278
|
-
# If the nearest vertex is concave then point is inside the polygon,
|
|
279
|
-
# else the point is outside the polygon.
|
|
280
|
-
jo = j.copy()
|
|
281
|
-
jo[j == 0] -= 1
|
|
282
|
-
area = _det([x[j + 1], x[j], x[jo - 1]], [y[j + 1], y[j], y[jo - 1]])
|
|
283
|
-
mindst[~snear] = np.copysign(mindst, area)[~snear]
|
|
284
|
-
# Point is closer to its nearest side than to its nearest vertex, check
|
|
285
|
-
# if point is to left or right of this side.
|
|
286
|
-
# If point is to left of side it is inside polygon, else point is
|
|
287
|
-
# outside polygon.
|
|
288
|
-
area = _det([x[j], x[j + 1], xpoint], [y[j], y[j + 1], ypoint])
|
|
289
|
-
mindst[snear] = np.copysign(mindst, area)[snear]
|
|
290
|
-
# Point is on side of polygon
|
|
291
|
-
mindst[np.fabs(mindst) < smalld] = 0
|
|
292
|
-
# If input values were scalar then the output should be too
|
|
293
|
-
if scalar:
|
|
294
|
-
mindst = float(mindst)
|
|
295
|
-
return mindst
|
|
296
|
-
|
|
297
|
-
|
|
298
132
|
class Grid(ABCHasStrictTraits):
|
|
299
133
|
"""
|
|
300
134
|
Abstract base class for grid geometries.
|
|
@@ -315,16 +149,16 @@ class Grid(ABCHasStrictTraits):
|
|
|
315
149
|
|
|
316
150
|
#: The total number of grid points. This property is automatically calculated based on other
|
|
317
151
|
#: defining attributes of the grid. (read-only)
|
|
318
|
-
size = Property(
|
|
152
|
+
size = Property()
|
|
319
153
|
|
|
320
154
|
#: The shape of the grid, represented as a tuple. Primarily useful for Cartesian grids.
|
|
321
155
|
#: (read-only)
|
|
322
|
-
shape = Property(
|
|
156
|
+
shape = Property()
|
|
323
157
|
|
|
324
158
|
#: The grid positions represented as a (3, :attr:`size`) array of :class:`floats<float>`.
|
|
325
159
|
#: (read-only)
|
|
326
160
|
#: All positions' coordinates are in meters by default (:ref:`see here <units_note_grids>`).
|
|
327
|
-
pos = Property(
|
|
161
|
+
pos = Property()
|
|
328
162
|
|
|
329
163
|
#: A unique identifier for the grid, based on its properties. (read-only)
|
|
330
164
|
digest = Property
|
|
@@ -437,7 +271,7 @@ class Grid(ABCHasStrictTraits):
|
|
|
437
271
|
pos_str = ' '.join(
|
|
438
272
|
[
|
|
439
273
|
' <pos',
|
|
440
|
-
f'Name="Point {i+1}"',
|
|
274
|
+
f'Name="Point {i + 1}"',
|
|
441
275
|
f'x="{self.pos[0, i]}"',
|
|
442
276
|
f'y="{self.pos[1, i]}"',
|
|
443
277
|
f'z="{self.pos[2, i]}"',
|
|
@@ -457,31 +291,31 @@ class RectGrid(Grid):
|
|
|
457
291
|
"""
|
|
458
292
|
|
|
459
293
|
#: The lower x-limit that defines the grid. Default is ``-1``.
|
|
460
|
-
x_min = Float(-1.0
|
|
294
|
+
x_min = Float(-1.0)
|
|
461
295
|
|
|
462
296
|
#: The upper x-limit that defines the grid. Default is ``1``.
|
|
463
|
-
x_max = Float(1.0
|
|
297
|
+
x_max = Float(1.0)
|
|
464
298
|
|
|
465
299
|
#: The lower y-limit that defines the grid. Default is ``-1``.
|
|
466
|
-
y_min = Float(-1.0
|
|
300
|
+
y_min = Float(-1.0)
|
|
467
301
|
|
|
468
302
|
#: The upper y-limit that defines the grid. Default is ``1``.
|
|
469
|
-
y_max = Float(1.0
|
|
303
|
+
y_max = Float(1.0)
|
|
470
304
|
|
|
471
305
|
#: The constant z-coordinate of the grid plane. Default is ``1.0``.
|
|
472
|
-
z = Float(1.0
|
|
306
|
+
z = Float(1.0)
|
|
473
307
|
|
|
474
308
|
#: The side length of each cell. Default is ``0.1``.
|
|
475
|
-
increment = Float(0.1
|
|
309
|
+
increment = Float(0.1)
|
|
476
310
|
|
|
477
311
|
#: Number of grid points along x-axis. (read-only)
|
|
478
|
-
nxsteps = Property(
|
|
312
|
+
nxsteps = Property()
|
|
479
313
|
|
|
480
314
|
#: Number of grid points along y-axis. (read-only)
|
|
481
|
-
nysteps = Property(
|
|
315
|
+
nysteps = Property()
|
|
482
316
|
|
|
483
317
|
#: The grid's extension in :obj:`matplotlib.pyplot.imshow` compatible form. (read-only)
|
|
484
|
-
extent = Property(
|
|
318
|
+
extent = Property()
|
|
485
319
|
|
|
486
320
|
#: A unique identifier for the grid, based on its properties. (read-only)
|
|
487
321
|
digest = Property(
|
|
@@ -672,27 +506,26 @@ class RectGrid3D(RectGrid):
|
|
|
672
506
|
"""
|
|
673
507
|
|
|
674
508
|
#: The lower z-limit that defines the grid. Default is ``-1.0``.
|
|
675
|
-
z_min = Float(-1.0
|
|
509
|
+
z_min = Float(-1.0)
|
|
676
510
|
|
|
677
511
|
#: The upper z-limit that defines the grid. Default is ``1.0``.
|
|
678
|
-
z_max = Float(1.0
|
|
512
|
+
z_max = Float(1.0)
|
|
679
513
|
|
|
680
514
|
#: Number of grid points along x-axis. (read-only)
|
|
681
|
-
nxsteps = Property(
|
|
515
|
+
nxsteps = Property()
|
|
682
516
|
|
|
683
517
|
#: Number of grid points along y-axis. (read-only)
|
|
684
|
-
nysteps = Property(
|
|
518
|
+
nysteps = Property()
|
|
685
519
|
|
|
686
520
|
#: Number of grid points along z-axis. (read-only)
|
|
687
|
-
nzsteps = Property(
|
|
521
|
+
nzsteps = Property()
|
|
688
522
|
|
|
689
|
-
|
|
690
|
-
_increment = Union(Float(), CArray(shape=(3,), dtype=float), default_value=0.1, desc='step size')
|
|
523
|
+
_increment = Union(Float(), CArray(shape=(3,), dtype=float), default_value=0.1)
|
|
691
524
|
|
|
692
525
|
#: The cell side length for the grid. This can either be a scalar (same increments in all 3
|
|
693
526
|
#: dimensions) or a (3,) array of :class:`tuple` of :class:`floats<float>` with respective
|
|
694
527
|
#: increments in x-, y-, and z-direction. Default is ``0.1``.
|
|
695
|
-
increment = Property(
|
|
528
|
+
increment = Property()
|
|
696
529
|
|
|
697
530
|
def _get_increment(self):
|
|
698
531
|
return self._increment
|
|
@@ -865,13 +698,14 @@ class ImportGrid(Grid):
|
|
|
865
698
|
"""
|
|
866
699
|
|
|
867
700
|
#: Name of the .xml-file from which to read the data.
|
|
868
|
-
file = Union(None, File(filter=['*.xml'], exists=True)
|
|
701
|
+
file = Union(None, File(filter=['*.xml'], exists=True))
|
|
869
702
|
|
|
870
|
-
|
|
703
|
+
#: x, y, z position of all Grid Points
|
|
704
|
+
_gpos = CArray(dtype=float)
|
|
871
705
|
|
|
872
706
|
#: Names of subgrids for each point.
|
|
873
707
|
#: This is an optional property, typically used when grids are divided into named subregions.
|
|
874
|
-
subgrids = CArray(
|
|
708
|
+
subgrids = CArray()
|
|
875
709
|
|
|
876
710
|
#: A unique identifier for the grid, based on its properties. (read-only)
|
|
877
711
|
digest = Property(depends_on=['_gpos'])
|
|
@@ -1058,22 +892,22 @@ class LineGrid(Grid):
|
|
|
1058
892
|
loc = Tuple((0.0, 0.0, 0.0))
|
|
1059
893
|
|
|
1060
894
|
#: A vector defining the orientation of the line in 3D space. Default is ``(1.0, 0.0, 0.0)``.
|
|
1061
|
-
direction = Tuple((1.0, 0.0, 0.0)
|
|
895
|
+
direction = Tuple((1.0, 0.0, 0.0))
|
|
1062
896
|
|
|
1063
897
|
#: Total length of the line. Default is ``1.0``.
|
|
1064
|
-
length = Float(1
|
|
898
|
+
length = Float(1)
|
|
1065
899
|
|
|
1066
900
|
#: Number of grid points along the line. Default is ``1``.
|
|
1067
|
-
num_points = Int(1
|
|
901
|
+
num_points = Int(1)
|
|
1068
902
|
|
|
1069
903
|
#: The total number of grid points. Automatically updated when other grid-defining attributes
|
|
1070
904
|
#: are set. (read-only)
|
|
1071
|
-
size = Property(
|
|
905
|
+
size = Property()
|
|
1072
906
|
|
|
1073
907
|
#: A (3, :attr:`size`) array containing the x, y, and z positions of the grid points.
|
|
1074
908
|
#: (read-only)
|
|
1075
909
|
#: All positions' coordinates are in meters by default (:ref:`see here <units_note_grids>`).
|
|
1076
|
-
pos = Property(
|
|
910
|
+
pos = Property()
|
|
1077
911
|
|
|
1078
912
|
#: A unique identifier for the grid, based on its properties. (read-only)
|
|
1079
913
|
digest = Property(
|
|
@@ -1135,13 +969,13 @@ class MergeGrid(Grid):
|
|
|
1135
969
|
|
|
1136
970
|
#: A list of :class:`Grid` objects to be merged. Each grid is treated as a subdomain in the
|
|
1137
971
|
#: resulting merged grid.
|
|
1138
|
-
grids = List(
|
|
972
|
+
grids = List()
|
|
1139
973
|
|
|
1140
974
|
#: A list of unique digests for each grid being merged. (read-only)
|
|
1141
|
-
grid_digest = Str(
|
|
975
|
+
grid_digest = Str()
|
|
1142
976
|
|
|
1143
977
|
#: Names of subgrids corresponding to each point in the merged grid. (read-only)
|
|
1144
|
-
subgrids = Property(
|
|
978
|
+
subgrids = Property()
|
|
1145
979
|
|
|
1146
980
|
#: A unique identifier for the grid, based on its properties. (read-only)
|
|
1147
981
|
digest = Property(depends_on=['grids', 'grid_digest'])
|
|
@@ -1248,16 +1082,16 @@ class SingleSector(Sector):
|
|
|
1248
1082
|
|
|
1249
1083
|
#: If ``True``, grid points lying on the sector border are included in the sector. Default is
|
|
1250
1084
|
#: ``True``.
|
|
1251
|
-
include_border = Bool(True
|
|
1085
|
+
include_border = Bool(True)
|
|
1252
1086
|
|
|
1253
1087
|
#: The absolute tolerance to apply when determining if a grid point lies on the sector border.
|
|
1254
1088
|
#: Default is ``1e-12``.
|
|
1255
|
-
abs_tol = Float(1e-12
|
|
1089
|
+
abs_tol = Float(1e-12)
|
|
1256
1090
|
|
|
1257
1091
|
#: If ``True``, the ``contains`` method (as in :meth:`RectSector.contains`,
|
|
1258
1092
|
#: :meth:`RectSector3D.contains`, :meth:`CircSector.contains`, and :meth:`PolySector.contains`)
|
|
1259
1093
|
#: returns the nearest grid point if no grid points are inside the sector. Default is ``True``.
|
|
1260
|
-
default_nearest = Bool(True
|
|
1094
|
+
default_nearest = Bool(True)
|
|
1261
1095
|
|
|
1262
1096
|
|
|
1263
1097
|
class RectSector(SingleSector):
|
|
@@ -1276,16 +1110,16 @@ class RectSector(SingleSector):
|
|
|
1276
1110
|
"""
|
|
1277
1111
|
|
|
1278
1112
|
#: The minimum x position of the rectangle. Default is ``-1.0``.
|
|
1279
|
-
x_min = Float(-1.0
|
|
1113
|
+
x_min = Float(-1.0)
|
|
1280
1114
|
|
|
1281
1115
|
#: The maximum x position of the rectangle. Default is ``1.0``.
|
|
1282
|
-
x_max = Float(1.0
|
|
1116
|
+
x_max = Float(1.0)
|
|
1283
1117
|
|
|
1284
1118
|
#: The minimum y position of the rectangle. Default is ``-1.0``.
|
|
1285
|
-
y_min = Float(-1.0
|
|
1119
|
+
y_min = Float(-1.0)
|
|
1286
1120
|
|
|
1287
1121
|
#: The maximum y position of the rectangle. Default is ``1.0``.
|
|
1288
|
-
y_max = Float(1.0
|
|
1122
|
+
y_max = Float(1.0)
|
|
1289
1123
|
|
|
1290
1124
|
def contains(self, pos):
|
|
1291
1125
|
"""
|
|
@@ -1360,10 +1194,10 @@ class RectSector3D(RectSector):
|
|
|
1360
1194
|
"""
|
|
1361
1195
|
|
|
1362
1196
|
#: The lower z position of the cuboid. Default is ``-1.0``.
|
|
1363
|
-
z_min = Float(-1.0
|
|
1197
|
+
z_min = Float(-1.0)
|
|
1364
1198
|
|
|
1365
1199
|
#: The upper z position of the cuboid. Default is ``1.0``.
|
|
1366
|
-
z_max = Float(1.0
|
|
1200
|
+
z_max = Float(1.0)
|
|
1367
1201
|
|
|
1368
1202
|
def contains(self, pos):
|
|
1369
1203
|
"""
|
|
@@ -1449,13 +1283,13 @@ class CircSector(SingleSector):
|
|
|
1449
1283
|
"""
|
|
1450
1284
|
|
|
1451
1285
|
#: The x position of the circle center. Default is ``0.0``.
|
|
1452
|
-
x = Float(0.0
|
|
1286
|
+
x = Float(0.0)
|
|
1453
1287
|
|
|
1454
1288
|
#: The y position of the circle center. Default is ``0.0``.
|
|
1455
|
-
y = Float(0.0
|
|
1289
|
+
y = Float(0.0)
|
|
1456
1290
|
|
|
1457
1291
|
#: Radius of the circle. Default is ``1.0``.
|
|
1458
|
-
r = Float(1.0
|
|
1292
|
+
r = Float(1.0)
|
|
1459
1293
|
|
|
1460
1294
|
def contains(self, pos):
|
|
1461
1295
|
"""
|
acoular/microphones.py
CHANGED
|
@@ -137,32 +137,32 @@ class MicGeom(HasStrictTraits):
|
|
|
137
137
|
|
|
138
138
|
#: Path to the XML file containing microphone positions. The XML file should have elements with
|
|
139
139
|
#: the tag ``pos`` and attributes ``Name``, ``x``, ``y``, and ``z``.
|
|
140
|
-
file = Union(None, File(filter=['*.xml'], exists=True)
|
|
140
|
+
file = Union(None, File(filter=['*.xml'], exists=True))
|
|
141
141
|
|
|
142
142
|
#: Array containing the ``x, y, z`` positions of all microphones, including invalid ones, shape
|
|
143
143
|
#: ``(3,`` :attr:`num_mics` ``)``. This is set automatically when :attr:`file` changes or
|
|
144
144
|
#: explicitly by assigning an array of floats. All coordinates are in meters by default
|
|
145
145
|
#: (:ref:`see here <units_note_microphones>`).
|
|
146
|
-
pos_total = CArray(dtype=float, shape=(3, None)
|
|
146
|
+
pos_total = CArray(dtype=float, shape=(3, None))
|
|
147
147
|
|
|
148
148
|
#: Array containing the ``x, y, z`` positions of valid microphones (i.e., excluding those in
|
|
149
149
|
#: :attr:`invalid_channels`), shape ``(3,`` :attr:`num_mics` ``)``. (read-only)
|
|
150
150
|
#: All coordinates are in meters by default (:ref:`see here <units_note_microphones>`).
|
|
151
|
-
pos = Property(depends_on=['pos_total', 'invalid_channels']
|
|
151
|
+
pos = Property(depends_on=['pos_total', 'invalid_channels'])
|
|
152
152
|
|
|
153
153
|
#: List of indices indicating microphones to be excluded from calculations and results.
|
|
154
154
|
#: Default is ``[]``.
|
|
155
|
-
invalid_channels = List(int
|
|
155
|
+
invalid_channels = List(int)
|
|
156
156
|
|
|
157
157
|
#: Number of valid microphones in the array. (read-only)
|
|
158
|
-
num_mics = Property(depends_on=['pos']
|
|
158
|
+
num_mics = Property(depends_on=['pos'])
|
|
159
159
|
|
|
160
160
|
#: The geometric center of the array, calculated as the arithmetic mean of the positions of all
|
|
161
161
|
#: valid microphones. (read-only)
|
|
162
|
-
center = Property(depends_on=['pos']
|
|
162
|
+
center = Property(depends_on=['pos'])
|
|
163
163
|
|
|
164
164
|
#: The maximum distance between any two valid microphones in the array. (read-only)
|
|
165
|
-
aperture = Property(depends_on=['pos']
|
|
165
|
+
aperture = Property(depends_on=['pos'])
|
|
166
166
|
|
|
167
167
|
#: A unique identifier for the geometry, based on its properties. (read-only)
|
|
168
168
|
digest = Property(depends_on=['pos'])
|
|
@@ -270,6 +270,6 @@ class MicGeom(HasStrictTraits):
|
|
|
270
270
|
f.write(f'<?xml version="1.1" encoding="utf-8"?><MicArray name="{basename}">\n')
|
|
271
271
|
for i in range(self.pos.shape[-1]):
|
|
272
272
|
f.write(
|
|
273
|
-
f' <pos Name="Point {i+1}" x="{self.pos[0, i]}" y="{self.pos[1, i]}" z="{self.pos[2, i]}"/>\n',
|
|
273
|
+
f' <pos Name="Point {i + 1}" x="{self.pos[0, i]}" y="{self.pos[1, i]}" z="{self.pos[2, i]}"/>\n',
|
|
274
274
|
)
|
|
275
275
|
f.write('</MicArray>')
|
acoular/process.py
CHANGED
|
@@ -116,7 +116,7 @@ class Average(InOut):
|
|
|
116
116
|
|
|
117
117
|
#: The number of samples (time domain source) or snapshots (frequency domain source)
|
|
118
118
|
#: to average over. Default is ``64``.
|
|
119
|
-
num_per_average = Int(64
|
|
119
|
+
num_per_average = Int(64)
|
|
120
120
|
|
|
121
121
|
#: The sampling frequency of the output signal. It is set automatically as
|
|
122
122
|
#: (:attr:`~acoular.base.Generator.sample_freq` ``/`` :attr:`num_per_average`).
|
|
@@ -479,7 +479,6 @@ class SampleSplitter(InOut):
|
|
|
479
479
|
buffer_overflow_treatment = Dict(
|
|
480
480
|
key_trait=Instance(Generator),
|
|
481
481
|
value_trait=Enum('error', 'warning', 'none'),
|
|
482
|
-
desc='defines buffer overflow behaviour.',
|
|
483
482
|
)
|
|
484
483
|
|
|
485
484
|
# A shadow trait to monitor if source deliver samples or is empty.
|
|
@@ -728,7 +727,7 @@ class SamplesBuffer(InOut):
|
|
|
728
727
|
""" # noqa: W505
|
|
729
728
|
|
|
730
729
|
#: The number of samples that the buffer can hold.
|
|
731
|
-
length = Int(
|
|
730
|
+
length = Int()
|
|
732
731
|
|
|
733
732
|
#: The number of samples per block to obtain from the source. If set to ``None``, the number of
|
|
734
733
|
#: samples will be determined by the ``num`` argument of the :meth:`result` method.
|
|
@@ -736,7 +735,6 @@ class SamplesBuffer(InOut):
|
|
|
736
735
|
None,
|
|
737
736
|
Int(),
|
|
738
737
|
default_value=None,
|
|
739
|
-
desc='number of samples to return from the source. If "None", use "num" argument of result method',
|
|
740
738
|
)
|
|
741
739
|
|
|
742
740
|
#: The number of samples to return from the buffer. If set to ``None``, the number of
|
|
@@ -745,7 +743,6 @@ class SamplesBuffer(InOut):
|
|
|
745
743
|
None,
|
|
746
744
|
Int(),
|
|
747
745
|
default_value=None,
|
|
748
|
-
desc="number of samples to return from the buffer. If 'None', use 'num' argument of result method",
|
|
749
746
|
)
|
|
750
747
|
|
|
751
748
|
#: Index shift value for the buffer.
|
|
@@ -755,26 +752,22 @@ class SamplesBuffer(InOut):
|
|
|
755
752
|
#: samples.
|
|
756
753
|
shift_index_by = Enum(
|
|
757
754
|
('result_num', 'num'),
|
|
758
|
-
desc=(
|
|
759
|
-
'index shift value for the buffer. If "result_num", use "result_num" trait.'
|
|
760
|
-
' If "num", use "num" argument of result method'
|
|
761
|
-
),
|
|
762
755
|
)
|
|
763
756
|
|
|
764
757
|
#: The current filling level of the buffer, i.e., how many samples are currently available.
|
|
765
|
-
level = Property(
|
|
758
|
+
level = Property()
|
|
766
759
|
|
|
767
760
|
#: The data type of the elements in the buffer.
|
|
768
|
-
dtype = Any(
|
|
761
|
+
dtype = Any()
|
|
769
762
|
|
|
770
763
|
# Flag indicating if the source is empty (for internal use).
|
|
771
|
-
_empty_source = Bool(False
|
|
764
|
+
_empty_source = Bool(False)
|
|
772
765
|
|
|
773
766
|
# The actual buffer holding the samples for processing.
|
|
774
|
-
_buffer = Array(shape=(None, None)
|
|
767
|
+
_buffer = Array(shape=(None, None))
|
|
775
768
|
|
|
776
769
|
# The current index position in the buffer.
|
|
777
|
-
_index = Int(
|
|
770
|
+
_index = Int()
|
|
778
771
|
|
|
779
772
|
def _get_level(self):
|
|
780
773
|
return self._buffer.shape[0] - self._index
|
acoular/sdinput.py
CHANGED
|
@@ -35,36 +35,36 @@ class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
|
35
35
|
raise ImportError(msg)
|
|
36
36
|
|
|
37
37
|
#: input device index, refers to sounddevice list
|
|
38
|
-
device = Int(0
|
|
38
|
+
device = Int(0)
|
|
39
39
|
|
|
40
40
|
#: Number of input channels, maximum depends on device
|
|
41
|
-
num_channels = Int(1
|
|
41
|
+
num_channels = Int(1)
|
|
42
42
|
|
|
43
43
|
#: Number of samples to collect; defaults to -1. If is set to -1 device collects until user
|
|
44
44
|
# breaks streaming by setting Trait: collect_samples = False.
|
|
45
|
-
num_samples = Int(-1
|
|
45
|
+
num_samples = Int(-1)
|
|
46
46
|
|
|
47
47
|
#: Indicates if samples are collected, helper trait to break result loop
|
|
48
|
-
collect_samples = Bool(True
|
|
48
|
+
collect_samples = Bool(True)
|
|
49
49
|
|
|
50
50
|
#: Sampling frequency of the signal, changes with sinusdevices
|
|
51
|
-
sample_freq = Property(
|
|
51
|
+
sample_freq = Property()
|
|
52
52
|
|
|
53
53
|
_sample_freq = Float(default_value=None)
|
|
54
54
|
|
|
55
55
|
#: Datatype (resolution) of the signal, used as `dtype` in a sd `Stream` object
|
|
56
|
-
precision = Enum('float32', 'float16', 'int32', 'int16', 'int8', 'uint8'
|
|
56
|
+
precision = Enum('float32', 'float16', 'int32', 'int16', 'int8', 'uint8')
|
|
57
57
|
|
|
58
58
|
#: Indicates that the sounddevice buffer has overflown
|
|
59
|
-
overflow = Bool(False
|
|
59
|
+
overflow = Bool(False)
|
|
60
60
|
|
|
61
61
|
#: Indicates that the stream is collecting samples
|
|
62
|
-
running = Bool(False
|
|
62
|
+
running = Bool(False)
|
|
63
63
|
|
|
64
64
|
#: The sounddevice InputStream object for inspection
|
|
65
65
|
stream = Any
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
#: A unique identifier for the generator, based on its properties. (read-only)
|
|
68
68
|
digest = Property(depends_on=['device', 'num_channels', 'num_samples'])
|
|
69
69
|
|
|
70
70
|
@cached_property
|