acoular 25.4__py3-none-any.whl → 25.10__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/__init__.py +2 -4
- acoular/aiaa/aiaa.py +10 -10
- acoular/base.py +12 -34
- acoular/calib.py +20 -19
- acoular/configuration.py +3 -3
- acoular/demo/__init__.py +6 -1
- acoular/demo/acoular_demo.py +34 -10
- acoular/deprecation.py +10 -1
- acoular/environments.py +107 -117
- acoular/fastFuncs.py +16 -10
- acoular/fbeamform.py +300 -402
- acoular/fprocess.py +7 -33
- acoular/grids.py +228 -134
- acoular/h5cache.py +10 -4
- acoular/h5files.py +106 -9
- acoular/internal.py +4 -0
- acoular/microphones.py +22 -10
- acoular/process.py +7 -53
- acoular/sdinput.py +8 -5
- acoular/signals.py +29 -27
- acoular/sources.py +205 -335
- acoular/spectra.py +33 -43
- acoular/tbeamform.py +220 -199
- acoular/tools/helpers.py +52 -33
- acoular/tools/metrics.py +5 -10
- acoular/tprocess.py +1392 -647
- acoular/traitsviews.py +1 -3
- acoular/trajectory.py +5 -5
- acoular/version.py +4 -3
- {acoular-25.4.dist-info → acoular-25.10.dist-info}/METADATA +8 -4
- acoular-25.10.dist-info/RECORD +56 -0
- acoular-25.4.dist-info/RECORD +0 -56
- {acoular-25.4.dist-info → acoular-25.10.dist-info}/WHEEL +0 -0
- {acoular-25.4.dist-info → acoular-25.10.dist-info}/licenses/AUTHORS.rst +0 -0
- {acoular-25.4.dist-info → acoular-25.10.dist-info}/licenses/LICENSE +0 -0
acoular/signals.py
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
"""
|
|
5
5
|
Implements signal generators for the simulation of acoustic sources.
|
|
6
6
|
|
|
7
|
+
.. inheritance-diagram::
|
|
8
|
+
acoular.signals
|
|
9
|
+
:top-classes:
|
|
10
|
+
acoular.signals.SignalGenerator
|
|
11
|
+
:parts: 1
|
|
12
|
+
|
|
7
13
|
.. autosummary::
|
|
8
14
|
:toctree: generated/
|
|
9
15
|
|
|
@@ -21,8 +27,7 @@ Implements signal generators for the simulation of acoustic sources.
|
|
|
21
27
|
from abc import abstractmethod
|
|
22
28
|
from warnings import warn
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
from numpy.random import RandomState
|
|
30
|
+
import numpy as np
|
|
26
31
|
from scipy.signal import resample, sosfilt, tf2sos
|
|
27
32
|
from traits.api import (
|
|
28
33
|
ABCHasStrictTraits,
|
|
@@ -39,11 +44,9 @@ from traits.api import (
|
|
|
39
44
|
|
|
40
45
|
# acoular imports
|
|
41
46
|
from .base import SamplesGenerator
|
|
42
|
-
from .deprecation import deprecated_alias
|
|
43
47
|
from .internal import digest
|
|
44
48
|
|
|
45
49
|
|
|
46
|
-
@deprecated_alias({'numsamples': 'num_samples'})
|
|
47
50
|
class SignalGenerator(ABCHasStrictTraits):
|
|
48
51
|
"""
|
|
49
52
|
ABC for a simple one-channel signal generator.
|
|
@@ -170,9 +173,9 @@ class NoiseGenerator(SignalGenerator):
|
|
|
170
173
|
|
|
171
174
|
See Also
|
|
172
175
|
--------
|
|
173
|
-
:class
|
|
174
|
-
:class
|
|
175
|
-
:class
|
|
176
|
+
:class:`~acoular.signals.PNoiseGenerator` : For pink noise generation.
|
|
177
|
+
:class:`~acoular.signals.WNoiseGenerator` : For pink white generation.
|
|
178
|
+
:class:`~acoular.sources.UncorrelatedNoiseSource` : For per-channel noise generation.
|
|
176
179
|
"""
|
|
177
180
|
|
|
178
181
|
#: Root mean square (RMS) amplitude of the signal. For a point source,
|
|
@@ -211,8 +214,8 @@ class WNoiseGenerator(NoiseGenerator):
|
|
|
211
214
|
--------
|
|
212
215
|
:obj:`numpy.random.RandomState.standard_normal` :
|
|
213
216
|
Used here to generate normally distributed noise.
|
|
214
|
-
:class
|
|
215
|
-
:class
|
|
217
|
+
:class:`~acoular.signals.PNoiseGenerator` : For pink noise generation.
|
|
218
|
+
:class:`~acoular.sources.UncorrelatedNoiseSource` : For per-channel noise generation.
|
|
216
219
|
|
|
217
220
|
Examples
|
|
218
221
|
--------
|
|
@@ -260,7 +263,7 @@ class WNoiseGenerator(NoiseGenerator):
|
|
|
260
263
|
A 1D array of floats containing the generated white noise signal.
|
|
261
264
|
The length of the array is equal to :attr:`~SignalGenerator.num_samples`.
|
|
262
265
|
"""
|
|
263
|
-
rnd_gen = RandomState(self.seed)
|
|
266
|
+
rnd_gen = np.random.RandomState(self.seed)
|
|
264
267
|
return self.rms * rnd_gen.standard_normal(self.num_samples)
|
|
265
268
|
|
|
266
269
|
|
|
@@ -278,8 +281,8 @@ class PNoiseGenerator(NoiseGenerator):
|
|
|
278
281
|
|
|
279
282
|
See Also
|
|
280
283
|
--------
|
|
281
|
-
:class
|
|
282
|
-
:class
|
|
284
|
+
:class:`~acoular.signals.WNoiseGenerator` : For white noise generation.
|
|
285
|
+
:class:`~acoular.sources.UncorrelatedNoiseSource` : For per-channel noise generation.
|
|
283
286
|
|
|
284
287
|
References
|
|
285
288
|
----------
|
|
@@ -320,26 +323,26 @@ class PNoiseGenerator(NoiseGenerator):
|
|
|
320
323
|
simulation. If the specified depth exceeds the maximum possible value based on
|
|
321
324
|
the number of samples, it is automatically adjusted, and a warning is printed.
|
|
322
325
|
- The output signal is scaled to have the same overall level as white noise by dividing
|
|
323
|
-
the result by ``sqrt(depth + 1.5)``.
|
|
326
|
+
the result by ``np.sqrt(depth + 1.5)``.
|
|
324
327
|
"""
|
|
325
328
|
nums = self.num_samples
|
|
326
329
|
depth = self.depth
|
|
327
330
|
# maximum depth depending on number of samples
|
|
328
|
-
max_depth = int(log(nums) / log(2))
|
|
331
|
+
max_depth = int(np.log(nums) / np.log(2))
|
|
329
332
|
|
|
330
333
|
if depth > max_depth:
|
|
331
334
|
depth = max_depth
|
|
332
335
|
print(f'Pink noise filter depth set to maximum possible value of {max_depth:d}.')
|
|
333
336
|
|
|
334
|
-
rnd_gen = RandomState(self.seed)
|
|
337
|
+
rnd_gen = np.random.RandomState(self.seed)
|
|
335
338
|
s = rnd_gen.standard_normal(nums)
|
|
336
339
|
for _ in range(depth):
|
|
337
340
|
ind = 2**_ - 1
|
|
338
341
|
lind = nums - ind
|
|
339
342
|
dind = 2 ** (_ + 1)
|
|
340
|
-
s[ind:] += repeat(rnd_gen.standard_normal(nums // dind + 1), dind)[:lind]
|
|
341
|
-
# divide by sqrt(depth+1.5) to get same overall level as white noise
|
|
342
|
-
return self.rms / sqrt(depth + 1.5) * s
|
|
343
|
+
s[ind:] += np.repeat(rnd_gen.standard_normal(nums // dind + 1), dind)[:lind]
|
|
344
|
+
# divide by np.sqrt(depth+1.5) to get same overall level as white noise
|
|
345
|
+
return self.rms / np.sqrt(depth + 1.5) * s
|
|
343
346
|
|
|
344
347
|
|
|
345
348
|
class FiltWNoiseGenerator(WNoiseGenerator):
|
|
@@ -399,11 +402,11 @@ class FiltWNoiseGenerator(WNoiseGenerator):
|
|
|
399
402
|
|
|
400
403
|
#: A :class:`numpy.ndarray` of autoregressive coefficients (denominator). Default is ``[]``,
|
|
401
404
|
#: which results in no AR filtering (i.e., all-pole filter is ``[1.0]``).
|
|
402
|
-
ar = CArray(value=array([]), dtype=float, desc='autoregressive coefficients (coefficients of the denominator)')
|
|
405
|
+
ar = CArray(value=np.array([]), dtype=float, desc='autoregressive coefficients (coefficients of the denominator)')
|
|
403
406
|
|
|
404
407
|
#: A :class:`numpy.ndarray` of moving-average coefficients (numerator). Default is ``[]``,
|
|
405
408
|
#: which results in no MA filtering (i.e., all-zero filter is ``[1.0]``).
|
|
406
|
-
ma = CArray(value=array([]), dtype=float, desc='moving-average coefficients (coefficients of the numerator)')
|
|
409
|
+
ma = CArray(value=np.array([]), dtype=float, desc='moving-average coefficients (coefficients of the numerator)')
|
|
407
410
|
|
|
408
411
|
#: A unique checksum identifier based on the object properties. (read-only)
|
|
409
412
|
digest = Property(depends_on=['rms', 'seed', 'sample_freq', 'num_samples', 'ar', 'ma'])
|
|
@@ -432,7 +435,7 @@ class FiltWNoiseGenerator(WNoiseGenerator):
|
|
|
432
435
|
if the input array is empty.
|
|
433
436
|
"""
|
|
434
437
|
if coefficients.size == 0:
|
|
435
|
-
return array([1.0])
|
|
438
|
+
return np.array([1.0])
|
|
436
439
|
return coefficients
|
|
437
440
|
|
|
438
441
|
def signal(self):
|
|
@@ -450,7 +453,7 @@ class FiltWNoiseGenerator(WNoiseGenerator):
|
|
|
450
453
|
An array representing the filtered white noise signal. The length of the returned array
|
|
451
454
|
is equal to :attr:`the number of samples<SignalGenerator.num_samples>`.
|
|
452
455
|
"""
|
|
453
|
-
rnd_gen = RandomState(self.seed)
|
|
456
|
+
rnd_gen = np.random.RandomState(self.seed)
|
|
454
457
|
ma = self.handle_empty_coefficients(self.ma)
|
|
455
458
|
ar = self.handle_empty_coefficients(self.ar)
|
|
456
459
|
sos = tf2sos(ma, ar)
|
|
@@ -552,11 +555,10 @@ class SineGenerator(PeriodicSignalGenerator):
|
|
|
552
555
|
The generator supports high-frequency and high-resolution signals,
|
|
553
556
|
limited by the Nyquist criterion.
|
|
554
557
|
"""
|
|
555
|
-
t = arange(self.num_samples, dtype=float) / self.sample_freq
|
|
556
|
-
return self.amplitude * sin(2 * pi * self.freq * t + self.phase)
|
|
558
|
+
t = np.arange(self.num_samples, dtype=float) / self.sample_freq
|
|
559
|
+
return self.amplitude * np.sin(2 * np.pi * self.freq * t + self.phase)
|
|
557
560
|
|
|
558
561
|
|
|
559
|
-
@deprecated_alias({'rms': 'amplitude'})
|
|
560
562
|
class GenericSignalGenerator(SignalGenerator):
|
|
561
563
|
"""
|
|
562
564
|
Generate signals from a :class:`~acoular.base.SamplesGenerator` or derived object.
|
|
@@ -648,7 +650,7 @@ class GenericSignalGenerator(SignalGenerator):
|
|
|
648
650
|
stacklevel=2,
|
|
649
651
|
)
|
|
650
652
|
nums = self.num_samples
|
|
651
|
-
track = zeros(nums)
|
|
653
|
+
track = np.zeros(nums)
|
|
652
654
|
|
|
653
655
|
# iterate through source generator to fill signal track
|
|
654
656
|
for i, temp in enumerate(self.source.result(block)):
|
|
@@ -665,7 +667,7 @@ class GenericSignalGenerator(SignalGenerator):
|
|
|
665
667
|
# fill up empty track with as many full source signals as possible
|
|
666
668
|
nloops = nums // stop
|
|
667
669
|
if nloops > 1:
|
|
668
|
-
track[stop : stop * nloops] = tile(track[:stop], nloops - 1)
|
|
670
|
+
track[stop : stop * nloops] = np.tile(track[:stop], nloops - 1)
|
|
669
671
|
# fill up remaining empty track
|
|
670
672
|
res = nums % stop # last part of unfinished loop
|
|
671
673
|
if res > 0:
|