acoular 24.3__py3-none-any.whl → 24.7__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 +119 -54
- acoular/calib.py +29 -38
- acoular/configuration.py +132 -82
- acoular/demo/__init__.py +10 -4
- acoular/demo/acoular_demo.py +73 -55
- acoular/environments.py +270 -264
- acoular/fastFuncs.py +366 -196
- acoular/fbeamform.py +1797 -1934
- acoular/grids.py +504 -548
- acoular/h5cache.py +74 -83
- acoular/h5files.py +159 -142
- acoular/internal.py +13 -14
- acoular/microphones.py +57 -53
- acoular/sdinput.py +57 -53
- acoular/signals.py +180 -178
- acoular/sources.py +920 -724
- acoular/spectra.py +353 -363
- acoular/tbeamform.py +416 -416
- acoular/tfastfuncs.py +180 -104
- acoular/tools/__init__.py +25 -0
- acoular/tools/aiaa.py +185 -0
- acoular/tools/helpers.py +189 -0
- acoular/tools/metrics.py +165 -0
- acoular/tprocess.py +1240 -1182
- acoular/traitsviews.py +513 -501
- acoular/trajectory.py +50 -52
- acoular/version.py +5 -6
- acoular/xml/minidsp_uma-16.xml +20 -0
- acoular/xml/{minidsp_uma16.xml → minidsp_uma-16_mirrored.xml} +3 -0
- {acoular-24.3.dist-info → acoular-24.7.dist-info}/METADATA +58 -39
- acoular-24.7.dist-info/RECORD +50 -0
- {acoular-24.3.dist-info → acoular-24.7.dist-info}/WHEEL +1 -1
- acoular-24.7.dist-info/licenses/LICENSE +28 -0
- acoular/fileimport.py +0 -380
- acoular/nidaqimport.py +0 -273
- acoular/tests/reference_data/BeamformerBase.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse1.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse2.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse3.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseFalse4.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue1.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue2.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue3.npy +0 -0
- acoular/tests/reference_data/BeamformerBaseTrue4.npy +0 -0
- acoular/tests/reference_data/BeamformerCMFLassoLarsBIC.npy +0 -0
- acoular/tests/reference_data/BeamformerCMFNNLS.npy +0 -0
- acoular/tests/reference_data/BeamformerCapon.npy +0 -0
- acoular/tests/reference_data/BeamformerClean.npy +0 -0
- acoular/tests/reference_data/BeamformerCleansc.npy +0 -0
- acoular/tests/reference_data/BeamformerCleant.npy +0 -0
- acoular/tests/reference_data/BeamformerCleantSq.npy +0 -0
- acoular/tests/reference_data/BeamformerCleantSqTraj.npy +0 -0
- acoular/tests/reference_data/BeamformerCleantTraj.npy +0 -0
- acoular/tests/reference_data/BeamformerDamas.npy +0 -0
- acoular/tests/reference_data/BeamformerDamasPlus.npy +0 -0
- acoular/tests/reference_data/BeamformerEig.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse1.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse2.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse3.npy +0 -0
- acoular/tests/reference_data/BeamformerEigFalse4.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue1.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue2.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue3.npy +0 -0
- acoular/tests/reference_data/BeamformerEigTrue4.npy +0 -0
- acoular/tests/reference_data/BeamformerFunctional.npy +0 -0
- acoular/tests/reference_data/BeamformerGIB.npy +0 -0
- acoular/tests/reference_data/BeamformerGridlessOrth.npy +0 -0
- acoular/tests/reference_data/BeamformerMusic.npy +0 -0
- acoular/tests/reference_data/BeamformerOrth.npy +0 -0
- acoular/tests/reference_data/BeamformerSODIX.npy +0 -0
- acoular/tests/reference_data/BeamformerTime.npy +0 -0
- acoular/tests/reference_data/BeamformerTimeSq.npy +0 -0
- acoular/tests/reference_data/BeamformerTimeSqTraj.npy +0 -0
- acoular/tests/reference_data/BeamformerTimeTraj.npy +0 -0
- acoular/tests/reference_data/Environment.npy +0 -0
- acoular/tests/reference_data/Example1_numerical_values_testsum.h5 +0 -0
- acoular/tests/reference_data/FiltFiltOctave__.npy +0 -0
- acoular/tests/reference_data/FiltFiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
- acoular/tests/reference_data/FiltFreqWeight_weight_A_.npy +0 -0
- acoular/tests/reference_data/FiltFreqWeight_weight_C_.npy +0 -0
- acoular/tests/reference_data/FiltFreqWeight_weight_Z_.npy +0 -0
- acoular/tests/reference_data/FiltOctave__.npy +0 -0
- acoular/tests/reference_data/FiltOctave_band_100_0_fraction_Thirdoctave_.npy +0 -0
- acoular/tests/reference_data/Filter__.npy +0 -0
- acoular/tests/reference_data/GeneralFlowEnvironment.npy +0 -0
- acoular/tests/reference_data/OctaveFilterBank__.npy +0 -0
- acoular/tests/reference_data/OpenJet.npy +0 -0
- acoular/tests/reference_data/PointSource.npy +0 -0
- acoular/tests/reference_data/PowerSpectra_csm.npy +0 -0
- acoular/tests/reference_data/PowerSpectra_ev.npy +0 -0
- acoular/tests/reference_data/RotatingFlow.npy +0 -0
- acoular/tests/reference_data/SlotJet.npy +0 -0
- acoular/tests/reference_data/TimeAverage__.npy +0 -0
- acoular/tests/reference_data/TimeCumAverage__.npy +0 -0
- acoular/tests/reference_data/TimeExpAverage_weight_F_.npy +0 -0
- acoular/tests/reference_data/TimeExpAverage_weight_I_.npy +0 -0
- acoular/tests/reference_data/TimeExpAverage_weight_S_.npy +0 -0
- acoular/tests/reference_data/TimeInOut__.npy +0 -0
- acoular/tests/reference_data/TimePower__.npy +0 -0
- acoular/tests/reference_data/TimeReverse__.npy +0 -0
- acoular/tests/reference_data/UniformFlowEnvironment.npy +0 -0
- acoular/tests/reference_data/beamformer_traj_time_data.h5 +0 -0
- acoular/tests/run_tests.sh +0 -18
- acoular/tests/run_tests_osx.sh +0 -16
- acoular/tests/test.npy +0 -0
- acoular/tests/test_beamformer_results.py +0 -213
- acoular/tests/test_classes.py +0 -60
- acoular/tests/test_digest.py +0 -125
- acoular/tests/test_environments.py +0 -73
- acoular/tests/test_example1.py +0 -124
- acoular/tests/test_grid.py +0 -92
- acoular/tests/test_integrate.py +0 -102
- acoular/tests/test_signals.py +0 -60
- acoular/tests/test_sources.py +0 -65
- acoular/tests/test_spectra.py +0 -38
- acoular/tests/test_timecache.py +0 -35
- acoular/tests/test_tprocess.py +0 -90
- acoular/tests/test_traj_beamformer_results.py +0 -164
- acoular/tests/unsupported/SpeedComparison/OvernightTestcasesBeamformer_nMics32_nGridPoints100_nFreqs4_nTrials10.png +0 -0
- acoular/tests/unsupported/SpeedComparison/cythonBeamformer.pyx +0 -237
- acoular/tests/unsupported/SpeedComparison/mainForCython.py +0 -103
- acoular/tests/unsupported/SpeedComparison/mainForParallelJit.py +0 -143
- acoular/tests/unsupported/SpeedComparison/setupCythonOpenMP.py +0 -63
- acoular/tests/unsupported/SpeedComparison/sharedFunctions.py +0 -153
- acoular/tests/unsupported/SpeedComparison/timeOverNMics_AllImportantMethods.png +0 -0
- acoular/tests/unsupported/SpeedComparison/timeOverNMics_faverage.png +0 -0
- acoular/tests/unsupported/SpeedComparison/vglOptimierungFAverage.py +0 -204
- acoular/tests/unsupported/SpeedComparison/vglOptimierungGaussSeidel.py +0 -182
- acoular/tests/unsupported/SpeedComparison/vglOptimierungR_BEAMFULL_INVERSE.py +0 -764
- acoular/tests/unsupported/SpeedComparison/vglOptimierungR_BEAM_OS.py +0 -231
- acoular/tests/unsupported/SpeedComparison/whatsFastestWayFor_absASquared.py +0 -48
- acoular/tests/unsupported/functionalBeamformer.py +0 -123
- acoular/tests/unsupported/precisionTest.py +0 -153
- acoular/tests/unsupported/validationOfBeamformerFuncsPOSTAcoularIntegration.py +0 -254
- acoular/tests/unsupported/validationOfBeamformerFuncsPREeAcoularIntegration.py +0 -531
- acoular/tools.py +0 -422
- acoular-24.3.dist-info/RECORD +0 -148
- acoular-24.3.dist-info/licenses/LICENSE +0 -29
- {acoular-24.3.dist-info → acoular-24.7.dist-info}/licenses/AUTHORS.rst +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
acoular/tests/run_tests.sh
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
#remove cache data before testing
|
|
4
|
-
rm -rf ./cache/*
|
|
5
|
-
rm -rf ./__pycache__
|
|
6
|
-
|
|
7
|
-
#build a test suite object which runs the tests in this folder
|
|
8
|
-
python -m unittest discover -v -p "test_*.py"
|
|
9
|
-
|
|
10
|
-
VAL=$?
|
|
11
|
-
|
|
12
|
-
#remove cache data after testing
|
|
13
|
-
rm -rf ./cache/*
|
|
14
|
-
rm -rf ./__pycache__
|
|
15
|
-
|
|
16
|
-
exit $VAL
|
|
17
|
-
|
|
18
|
-
|
acoular/tests/run_tests_osx.sh
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
#remove cache data before testing
|
|
4
|
-
rm -rf ./cache/*
|
|
5
|
-
rm -rf ./__pycache__
|
|
6
|
-
|
|
7
|
-
#build a test suite object which runs the tests in this folder
|
|
8
|
-
python3 -m unittest discover -v -p "test_*.py"
|
|
9
|
-
|
|
10
|
-
VAL=$?
|
|
11
|
-
|
|
12
|
-
#remove cache data after testing
|
|
13
|
-
rm -rf ./cache/*
|
|
14
|
-
rm -rf ./__pycache__
|
|
15
|
-
|
|
16
|
-
exit $VAL
|
acoular/tests/test.npy
DELETED
|
Binary file
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#pylint: disable-msg=E0611, E1101, C0103, R0901, R0902, R0903, R0904, W0232
|
|
3
|
-
#------------------------------------------------------------------------------
|
|
4
|
-
# Copyright (c) Acoular Development Team.
|
|
5
|
-
#------------------------------------------------------------------------------
|
|
6
|
-
"""Implements testing of frequency beamformers.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import unittest
|
|
10
|
-
|
|
11
|
-
from os.path import join
|
|
12
|
-
|
|
13
|
-
import numpy as np
|
|
14
|
-
|
|
15
|
-
#acoular imports
|
|
16
|
-
import acoular
|
|
17
|
-
acoular.config.global_caching = 'none' # to make sure that nothing is cached
|
|
18
|
-
|
|
19
|
-
from acoular import Calib, MicGeom, PowerSpectra, \
|
|
20
|
-
RectGrid, BeamformerBase, BeamformerEig, BeamformerOrth, BeamformerCleansc, \
|
|
21
|
-
MaskedTimeSamples, BeamformerCMF, \
|
|
22
|
-
BeamformerCapon, BeamformerMusic, BeamformerDamas, BeamformerClean, \
|
|
23
|
-
BeamformerFunctional, BeamformerDamasPlus, BeamformerGIB, BeamformerGridlessOrth,\
|
|
24
|
-
SteeringVector, Environment, BeamformerSODIX
|
|
25
|
-
|
|
26
|
-
# copy CMF classes as workaround so that reference data name is unique later
|
|
27
|
-
class BeamformerCMFLassoLarsBIC (BeamformerCMF):
|
|
28
|
-
pass
|
|
29
|
-
|
|
30
|
-
class BeamformerCMFNNLS (BeamformerCMF):
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
# if this flag is set to True
|
|
34
|
-
WRITE_NEW_REFERENCE_DATA = False
|
|
35
|
-
# new beamformer results are generated for comparison during testing.
|
|
36
|
-
# Should always be False. Only set to True if it is necessary to
|
|
37
|
-
# recalculate the data due to intended changes of the Beamformers.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
#load exampledata
|
|
41
|
-
datafile = join('..','..','examples','example_data.h5')
|
|
42
|
-
calibfile = join('..','..','examples','example_calib.xml')
|
|
43
|
-
micgeofile = join( '..','xml','array_56.xml')
|
|
44
|
-
|
|
45
|
-
#frequencies to test
|
|
46
|
-
cfreqs = 1000,8000
|
|
47
|
-
|
|
48
|
-
# values from example 1
|
|
49
|
-
t1 = MaskedTimeSamples(name=datafile)
|
|
50
|
-
t1.start = 0 # first sample, default
|
|
51
|
-
t1.stop = 16000 # last valid sample = 15999
|
|
52
|
-
invalid = [1,7] # list of invalid channels (unwanted microphones etc.)
|
|
53
|
-
t1.invalid_channels = invalid
|
|
54
|
-
t1.calib = Calib(from_file=calibfile)
|
|
55
|
-
m = MicGeom(from_file=micgeofile)
|
|
56
|
-
m.invalid_channels = invalid
|
|
57
|
-
g = RectGrid(x_min=-0.6, x_max=-0.0, y_min=-0.3, y_max=0.3, z=0.68,
|
|
58
|
-
increment=0.05 )
|
|
59
|
-
env=Environment(c=346.04)
|
|
60
|
-
st = SteeringVector(grid=g, mics=m, env=env)
|
|
61
|
-
f = PowerSpectra(time_data=t1,
|
|
62
|
-
window='Hanning', overlap='50%', block_size=128, #FFT-parameters
|
|
63
|
-
cached = False )
|
|
64
|
-
|
|
65
|
-
# produces a tuple of beamformer objects to test
|
|
66
|
-
# because we need new objects for each test we have to call this more than once
|
|
67
|
-
def fbeamformers():
|
|
68
|
-
bb = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = False)
|
|
69
|
-
be = BeamformerEig(freq_data=f, steer=st, r_diag=True, n=54, cached = False)
|
|
70
|
-
|
|
71
|
-
#frequency beamformers to test
|
|
72
|
-
bbase = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = False)
|
|
73
|
-
bc = BeamformerCapon(freq_data=f, steer=st, cached=False)
|
|
74
|
-
beig = BeamformerEig(freq_data=f, steer=st, r_diag=True, n=54, cached = False)
|
|
75
|
-
bm = BeamformerMusic(freq_data=f, steer=st, n=6, cached = False)
|
|
76
|
-
bd = BeamformerDamas(beamformer=bb, n_iter=10, cached = False)
|
|
77
|
-
bdp = BeamformerDamasPlus(beamformer=bb, n_iter=100, cached = False)
|
|
78
|
-
bo = BeamformerOrth(freq_data=f, steer=st, r_diag=True, eva_list=list(range(38,54)), cached = False)
|
|
79
|
-
bs = BeamformerCleansc(freq_data=f, steer=st, r_diag=True, cached = False)
|
|
80
|
-
bcmflassobic = BeamformerCMFLassoLarsBIC(freq_data=f, steer=st, method='LassoLarsBIC', cached = False)
|
|
81
|
-
bcmfnnls = BeamformerCMFNNLS(freq_data=f, steer=st, method='NNLS', cached = False)
|
|
82
|
-
bl = BeamformerClean(beamformer=bb, n_iter=10, cached = False)
|
|
83
|
-
bf = BeamformerFunctional(freq_data=f, steer=st, r_diag=False, gamma=3, cached = False)
|
|
84
|
-
bgib = BeamformerGIB(freq_data=f, steer=st, method= 'LassoLars', n=2, cached = False)
|
|
85
|
-
bgo = BeamformerGridlessOrth(freq_data=f, steer=st, r_diag=False, n=1, shgo={'n':16}, cached = False)
|
|
86
|
-
bsodix = BeamformerSODIX(freq_data=f, steer=st,max_iter=10, cached = False)
|
|
87
|
-
return (bbase, bc, beig, bm, bl, bo, bs, bd, bcmflassobic, bcmfnnls, bf, bdp, bgib, bgo,bsodix)
|
|
88
|
-
|
|
89
|
-
class acoular_beamformer_test(unittest.TestCase):
|
|
90
|
-
|
|
91
|
-
def test_beamformer_freq_results(self):
|
|
92
|
-
# we expect the results to computed
|
|
93
|
-
acoular.config.global_caching = 'none'
|
|
94
|
-
for b in fbeamformers():
|
|
95
|
-
with self.subTest(b.__class__.__name__+" global_caching = none"):
|
|
96
|
-
name = join('reference_data',f'{b.__class__.__name__}.npy')
|
|
97
|
-
# stack all frequency band results together
|
|
98
|
-
actual_data = np.array([b.synthetic(cf,1) for cf in cfreqs],dtype=np.float32)
|
|
99
|
-
if WRITE_NEW_REFERENCE_DATA:
|
|
100
|
-
np.save(name,actual_data)
|
|
101
|
-
ref_data = np.load(name)
|
|
102
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=5e-5, atol=5e-8)
|
|
103
|
-
# we expect the results to be computed and written to cache
|
|
104
|
-
acoular.config.global_caching = 'individual'
|
|
105
|
-
for b in fbeamformers():
|
|
106
|
-
b.cached = True
|
|
107
|
-
with self.subTest(b.__class__.__name__+" global_caching = individual"):
|
|
108
|
-
name = join('reference_data',f'{b.__class__.__name__}.npy')
|
|
109
|
-
actual_data = np.array([b.synthetic(cf,1) for cf in cfreqs],dtype=np.float32)
|
|
110
|
-
ref_data = np.load(name)
|
|
111
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=5e-5, atol=5e-8)
|
|
112
|
-
# we expect the results to be read from cache
|
|
113
|
-
acoular.config.global_caching = 'all'
|
|
114
|
-
for b in fbeamformers():
|
|
115
|
-
b.cached = True
|
|
116
|
-
with self.subTest(b.__class__.__name__+" global_caching = all"):
|
|
117
|
-
name = join('reference_data',f'{b.__class__.__name__}.npy')
|
|
118
|
-
actual_data = np.array([b.synthetic(cf,1) for cf in cfreqs],dtype=np.float32)
|
|
119
|
-
ref_data = np.load(name)
|
|
120
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=5e-5, atol=5e-8)
|
|
121
|
-
# we expect the cached results to be overwritten
|
|
122
|
-
acoular.config.global_caching = 'overwrite'
|
|
123
|
-
for b0,b1 in zip(fbeamformers(),fbeamformers()):
|
|
124
|
-
b0.cached = True
|
|
125
|
-
b1.cached = True
|
|
126
|
-
with self.subTest(b0.__class__.__name__+" global_caching = overwrite"):
|
|
127
|
-
if hasattr(b0,'beamformer'): # BeamformerClean, BeamformerDamas, BeamformerDamasplus
|
|
128
|
-
# do not pass because the .beamformer result is not take from cache
|
|
129
|
-
continue # nor recalculated
|
|
130
|
-
b0.result[:] = 0
|
|
131
|
-
self.assertFalse(np.any(b0.result))
|
|
132
|
-
name = join('reference_data',f'{b1.__class__.__name__}.npy')
|
|
133
|
-
actual_data = np.array([b1.synthetic(cf,1) for cf in cfreqs],dtype=np.float32)
|
|
134
|
-
ref_data = np.load(name)
|
|
135
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=5e-5, atol=5e-8)
|
|
136
|
-
|
|
137
|
-
def test_beamformer_caching(self):
|
|
138
|
-
# within each subcase, we need new beamformer objects because result is not updated when
|
|
139
|
-
# global_caching or cached changes
|
|
140
|
-
with self.subTest("global_caching = 'none'"):
|
|
141
|
-
acoular.config.global_caching = 'none'
|
|
142
|
-
b0 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
143
|
-
b1 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
144
|
-
self.assertNotEqual(id(b0.result),id(b1.result))
|
|
145
|
-
with self.subTest("global_caching = 'individual'"):
|
|
146
|
-
acoular.config.global_caching = 'individual'
|
|
147
|
-
b0 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
148
|
-
b1 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
149
|
-
self.assertEqual(id(b0.result),id(b1.result))
|
|
150
|
-
b1 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = False)
|
|
151
|
-
self.assertNotEqual(id(b0.result),id(b1.result))
|
|
152
|
-
with self.subTest("global_caching = 'all'"):
|
|
153
|
-
acoular.config.global_caching = 'all'
|
|
154
|
-
b0 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
155
|
-
b1 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = False)
|
|
156
|
-
self.assertEqual(id(b0.result),id(b1.result))
|
|
157
|
-
with self.subTest("global_caching = 'readonly'"):
|
|
158
|
-
acoular.config.global_caching = 'readonly'
|
|
159
|
-
b0 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
160
|
-
b1 = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached = True)
|
|
161
|
-
self.assertEqual(id(b0.result),id(b1.result))
|
|
162
|
-
|
|
163
|
-
class Test_PowerSpectra(unittest.TestCase):
|
|
164
|
-
|
|
165
|
-
def test_csm(self):
|
|
166
|
-
""" test that csm result has not changed over different releases"""
|
|
167
|
-
name = join('reference_data',f'{f.__class__.__name__}_csm.npy')
|
|
168
|
-
# test only two frequencies
|
|
169
|
-
actual_data = np.array(f.csm[(16,32),:,:],dtype=np.complex64)
|
|
170
|
-
if WRITE_NEW_REFERENCE_DATA:
|
|
171
|
-
np.save(name,actual_data)
|
|
172
|
-
ref_data = np.load(name)
|
|
173
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=1e-5, atol=1e-8)
|
|
174
|
-
|
|
175
|
-
def test_ev(self):
|
|
176
|
-
""" test that eve and eva result has not changed over different releases"""
|
|
177
|
-
name = join('reference_data',f'{f.__class__.__name__}_ev.npy')
|
|
178
|
-
# test only two frequencies
|
|
179
|
-
actual_data = np.array((f.eve*f.eva[:,:,np.newaxis])[(16,32),:,:],dtype=np.complex64)
|
|
180
|
-
if WRITE_NEW_REFERENCE_DATA:
|
|
181
|
-
np.save(name,actual_data)
|
|
182
|
-
ref_data = np.load(name)
|
|
183
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=1e-5, atol=1e-8)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
class TestSteerFormulation(unittest.TestCase):
|
|
187
|
-
|
|
188
|
-
def test_all_steer_formulation(self):
|
|
189
|
-
""" tests all variants of beamformerFreq subroutines
|
|
190
|
-
"""
|
|
191
|
-
st = SteeringVector(grid=g, mics=m, env=env)
|
|
192
|
-
b0 = BeamformerBase(freq_data=f, steer=st, cached = False)
|
|
193
|
-
b1 = BeamformerEig(freq_data=f, steer=st, n=54, cached = False)
|
|
194
|
-
for ki,kind in enumerate(('classic', 'inverse','true level', 'true location')):
|
|
195
|
-
st.steer_type = kind
|
|
196
|
-
for b in (b0,b1):
|
|
197
|
-
for dr in (True,False):
|
|
198
|
-
b.r_diag = dr
|
|
199
|
-
with self.subTest(f"{b.__class__.__name__} r_diag:{dr} steer:{kind}"):
|
|
200
|
-
name = join('reference_data',f"{b.__class__.__name__}{dr}{ki+1}.npy")
|
|
201
|
-
actual_data = np.array([b.synthetic(cf,1) for cf in cfreqs],dtype=np.float32)
|
|
202
|
-
if WRITE_NEW_REFERENCE_DATA:
|
|
203
|
-
np.save(name,actual_data)
|
|
204
|
-
ref_data = np.load(name)
|
|
205
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=1e-5, atol=1e-8)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if __name__ == '__main__':
|
|
209
|
-
unittest.main() #exit=False
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
acoular/tests/test_classes.py
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#pylint: disable-msg=E0611, E1101, C0103, R0901, R0902, R0903, R0904, W0232
|
|
3
|
-
#------------------------------------------------------------------------------
|
|
4
|
-
# Copyright (c) Acoular Development Team.
|
|
5
|
-
#------------------------------------------------------------------------------
|
|
6
|
-
"""Implements testing of frequency beamformers.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import unittest
|
|
10
|
-
import acoular as ac
|
|
11
|
-
from traits.api import HasTraits, Int, Float, Bool, Range, TraitEnum, Enum
|
|
12
|
-
|
|
13
|
-
class Test_Instancing(unittest.TestCase):
|
|
14
|
-
"""Test that ensures that digest of Acoular classes changes correctly on
|
|
15
|
-
changes of CArray and List attributes.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def test_instancing(self):
|
|
19
|
-
""" test that all Acoular classes can be instatiated """
|
|
20
|
-
# iterate over all Acoular definitions labels
|
|
21
|
-
for i in dir(ac):
|
|
22
|
-
with self.subTest(i):
|
|
23
|
-
j = getattr(ac,i) # class, function or variable
|
|
24
|
-
if isinstance(j,type): # is this a class ?
|
|
25
|
-
j() # this is an instance of the class
|
|
26
|
-
|
|
27
|
-
def test_set_traits(self):
|
|
28
|
-
""" test that important traits can be set"""
|
|
29
|
-
# iterate over all Acoular definitions labels
|
|
30
|
-
for i in dir(ac):
|
|
31
|
-
j = getattr(ac,i) # class, function or variable
|
|
32
|
-
# HasTraits derived class ?
|
|
33
|
-
if isinstance(j,type) \
|
|
34
|
-
and issubclass(j,HasTraits) \
|
|
35
|
-
and ('digest' in j.class_traits().keys()):
|
|
36
|
-
do = j.class_traits()['digest'].depends_on
|
|
37
|
-
if do:
|
|
38
|
-
obj = j()
|
|
39
|
-
for k in do:
|
|
40
|
-
with self.subTest(i+'.'+k):
|
|
41
|
-
if k in j.class_trait_names():
|
|
42
|
-
tr = j.class_traits()[k]
|
|
43
|
-
# handling different Trait types
|
|
44
|
-
# todo: use hypothesis based setattr
|
|
45
|
-
if tr.is_trait_type(Int):
|
|
46
|
-
setattr(obj,k,1)
|
|
47
|
-
elif tr.is_trait_type(Float):
|
|
48
|
-
setattr(obj,k,0.1)
|
|
49
|
-
elif tr.is_trait_type(Bool):
|
|
50
|
-
setattr(obj,k,False)
|
|
51
|
-
elif tr.is_trait_type(Range):
|
|
52
|
-
low = tr.handler._low
|
|
53
|
-
high = tr.handler._high
|
|
54
|
-
setattr(obj,k,(high+low)/2)
|
|
55
|
-
elif tr.is_trait_type(TraitEnum) or tr.is_trait_type(Enum):
|
|
56
|
-
v = tr.handler.values
|
|
57
|
-
setattr(obj,k,v[len(v)//2])
|
|
58
|
-
|
|
59
|
-
if __name__ == '__main__':
|
|
60
|
-
unittest.main()
|
acoular/tests/test_digest.py
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
from acoular import UniformFlowEnvironment,SlotJet,OpenJet,RotatingFlow,MicGeom, SteeringVector,\
|
|
2
|
-
BeamformerOrth, RectGrid, MaskedTimeSamples, Sector,\
|
|
3
|
-
UncorrelatedNoiseSource, SourceMixer, SamplesGenerator, BeamformerTimeTraj, BeamformerTimeSqTraj,\
|
|
4
|
-
BeamformerCleantTraj, BeamformerCleantSqTraj, IntegratorSectorTime, MaskedTimeInOut, ChannelMixer,\
|
|
5
|
-
SpatialInterpolator, SpatialInterpolatorRotation, SpatialInterpolatorConstantRotation, Mixer,\
|
|
6
|
-
WriteWAV, MergeGrid, FiltWNoiseGenerator, SphericalHarmonicSource, PointSource
|
|
7
|
-
from numpy import array
|
|
8
|
-
from unittest import TestCase
|
|
9
|
-
|
|
10
|
-
# a dictionary containing all classes that should change their digest on
|
|
11
|
-
# changes of the following trait types:
|
|
12
|
-
# * List
|
|
13
|
-
# * CArray
|
|
14
|
-
UNEQUAL_DIGEST_TEST_DICT = {
|
|
15
|
-
# "MicGeom.mpos_tot item assignment" : (MicGeom(mpos_tot=[[1.,2.,3.]]), "obj.mpos_tot[:] = 0."),
|
|
16
|
-
"MicGeom.mpos_tot new array assignment" : (MicGeom(mpos_tot=[[1.,2.,3.]]), "obj.mpos_tot = array([0.])"),
|
|
17
|
-
# "MicGeom.invalid_channels item assignment" : (MicGeom(mpos_tot=[[1.,2.,3.]],invalid_channels=[1]), "obj.invalid_channels[0] = 0"),
|
|
18
|
-
"MicGeom.invalid_channels new list assignment" : (MicGeom(mpos_tot=[[1.,2.,3.]],invalid_channels=[1]), "obj.invalid_channels = [0]"),
|
|
19
|
-
# environments.py
|
|
20
|
-
# "UniformFlowEnvironment.fdv item assignment": (UniformFlowEnvironment(), "obj.fdv[0] = 0."),
|
|
21
|
-
"UniformFlowEnvironment.fdv array assignment": (UniformFlowEnvironment(), "obj.fdv = array((0., 0., 0.))"),
|
|
22
|
-
# "SlotJet.origin item assignment": (SlotJet(), "obj.origin[0] = 1."),
|
|
23
|
-
"SlotJet.origin array assignment": (SlotJet(), "obj.origin = array((1., 0., 0.))"),
|
|
24
|
-
# "SlotJet.flow item assignment": (SlotJet(), "obj.flow[0] = 0."),
|
|
25
|
-
"SlotJet.flow array assignment": (SlotJet(), "obj.flow = array((0., 0., 0.))"),
|
|
26
|
-
# "SlotJet.plane item assignment": (SlotJet(), "obj.plane[0] = 1."),
|
|
27
|
-
"SlotJet.plane array assignment": (SlotJet(), "obj.plane = array((1., 0., 0.))"),
|
|
28
|
-
# "OpenJet.origin item assignment": (OpenJet(), "obj.origin[0] = 1."),
|
|
29
|
-
"OpenJet.origin array assignment": (OpenJet(), "obj.origin = array((1., 0., 0.))"),
|
|
30
|
-
# "RotatingFlow.origin item assignment": (RotatingFlow(), "obj.origin[0] = 1."),
|
|
31
|
-
"RotatingFlow.origin array assignment": (RotatingFlow(), "obj.origin = array((1., 0., 0.))"),
|
|
32
|
-
#fbeamform.py
|
|
33
|
-
# "SteeringVector.ref item assignment": (SteeringVector(), "obj.ref[0] = 1."),
|
|
34
|
-
"SteeringVector.ref array assignment": (SteeringVector(), "obj.ref = array((1., 1., 1.))"),
|
|
35
|
-
# "BeamformerOrth.eva_list item assignment": (BeamformerOrth(eva_list=array((0, 1))), "obj.eva_list[0] = 2"),
|
|
36
|
-
"BeamformerOrth.eva_list array assignment": (BeamformerOrth(eva_list=array((0, 1))), "obj.eva_list = array((2))"),
|
|
37
|
-
#grids.py
|
|
38
|
-
"MergeGrid.grids item assignment": (MergeGrid(grids=[RectGrid()]), "obj.grids[0] = RectGrid()"),
|
|
39
|
-
"MergeGrid.grids list assignment": (MergeGrid(), "obj.grids = [RectGrid()]"),
|
|
40
|
-
# signals.py
|
|
41
|
-
# "FiltWNoiseGenerator.ar item assignment": (FiltWNoiseGenerator(ar=[1.,2.,3.]), "obj.ar[0] = 0."),
|
|
42
|
-
"FiltWNoiseGenerator.ar array assignment": (FiltWNoiseGenerator(ar=[1.,2.,3.]), "obj.ar = array((0., 0., 0.))"),
|
|
43
|
-
# "FiltWNoiseGenerator.ma item assignment": (FiltWNoiseGenerator(ma=[1.,2.,3.]), "obj.ma[0] = 0."),
|
|
44
|
-
"FiltWNoiseGenerator.mar array assignment": (FiltWNoiseGenerator(ma=[1.,2.,3.]), "obj.ma = array((0., 0., 0.))"),
|
|
45
|
-
#sources.py
|
|
46
|
-
"MaskedTimeSamples.invalid_channels item assignment": (MaskedTimeSamples(invalid_channels=[1]), "obj.invalid_channels[0] = 0"),
|
|
47
|
-
"MaskedTimeSamples.invalid_channels list assignment": (MaskedTimeSamples(), "obj.invalid_channels = [0]"),
|
|
48
|
-
# "SphericalHarmonicSource.alpha item assignment": (SphericalHarmonicSource(alpha=array((0, 1))), "obj.alpha[0] = 1."),
|
|
49
|
-
"SphericalHarmonicSource.alpha array assignment": (SphericalHarmonicSource(alpha=array((0, 1))), "obj.alpha = array((1., 1., 1.))"),
|
|
50
|
-
# "UncorrelatedNoiseSource.seed item assignment": (UncorrelatedNoiseSource(seed=array((1, 2))), "obj.seed[0] = 3"),
|
|
51
|
-
"UncorrelatedNoiseSource.seed array assignment": (UncorrelatedNoiseSource(seed=array((1, 2))), "obj.seed = array((3,4))"),
|
|
52
|
-
"SourceMixer.sources item assignment": (SourceMixer(sources=[SamplesGenerator()]), "obj.sources[0] = PointSource()"),
|
|
53
|
-
"SourceMixer.sources list assignment": (SourceMixer(sources=[SamplesGenerator()]), "obj.sources = [PointSource()]"),
|
|
54
|
-
# tbeamform.py
|
|
55
|
-
# "BeamformerTimeTraj.rvec item assignment": (BeamformerTimeTraj(), "obj.rvec[0] = 1."),
|
|
56
|
-
"BeamformerTimeTraj.rvec array assignment": (BeamformerTimeTraj(), "obj.rvec = array((1., 0., 0.))"),
|
|
57
|
-
# "BeamformerTimeSqTraj.rvec item assignment": (BeamformerTimeSqTraj(), "obj.rvec[0] = 1."),
|
|
58
|
-
"BeamformerTimeSqTraj.rvec array assignment": (BeamformerTimeSqTraj(), "obj.rvec = array((1., 0., 0.))"),
|
|
59
|
-
# "BeamformerCleantTraj.rvec item assignment": (BeamformerCleantTraj(), "obj.rvec[0] = 1."),
|
|
60
|
-
"BeamformerCleantTraj.rvec array assignment": (BeamformerCleantTraj(), "obj.rvec = array((1., 0., 0.))"),
|
|
61
|
-
# "BeamformerCleantSqTraj.rvec item assignment": (BeamformerCleantSqTraj(), "obj.rvec[0] = 1."),
|
|
62
|
-
"BeamformerCleantSqTraj.rvec array assignment": (BeamformerCleantSqTraj(), "obj.rvec = array((1., 0., 0.))"),
|
|
63
|
-
"IntegratorSectorTime.sectors item assignment": (IntegratorSectorTime(sectors=[Sector()]), "obj.sectors[0] = Sector()"),
|
|
64
|
-
"IntegratorSectorTime.sectors list assignment": (IntegratorSectorTime(sectors=[Sector()]), "obj.sectors = [Sector()]"),
|
|
65
|
-
# tprocess.py
|
|
66
|
-
"MaskedTimeInOut.invalid_channels item assignment": (MaskedTimeInOut(invalid_channels=[1]), "obj.invalid_channels[0] = 0"),
|
|
67
|
-
"MaskedTimeInOut.invalid_channels list assignment": (MaskedTimeInOut(), "obj.invalid_channels = [0]"),
|
|
68
|
-
# "ChannelMixer.weights item assignment" : (ChannelMixer(weights=[[1.,2.,3.]]), "obj.weights[0] = 0."),
|
|
69
|
-
"ChannelMixer.weights new array assignment" : (ChannelMixer(weights=[[1.,2.,3.]]), "obj.weights = array([0.])"),
|
|
70
|
-
# "SpatialInterpolator.Q item assignment": (SpatialInterpolator(), "obj.Q[0] = 0."),
|
|
71
|
-
"SpatialInterpolator.Q array assignment": (SpatialInterpolator(), "obj.Q = array([[0.,0.,0.],[0.,0.,0.],[0.,0.,0.]])"),
|
|
72
|
-
# "SpatialInterpolatorRotation.Q item assignment": (SpatialInterpolatorRotation(), "obj.Q[0] = 0."),
|
|
73
|
-
"SpatialInterpolatorRotation.Q array assignment": (SpatialInterpolatorRotation(), "obj.Q = array([[0.,0.,0.],[0.,0.,0.],[0.,0.,0.]])"),
|
|
74
|
-
# "SpatialInterpolatorConstantRotation.Q item assignment": (SpatialInterpolatorConstantRotation(), "obj.Q[0] = 0."),
|
|
75
|
-
"SpatialInterpolatorConstantRotation.Q array assignment": (SpatialInterpolatorConstantRotation(), "obj.Q = array([[0.,0.,0.],[0.,0.,0.],[0.,0.,0.]])"),
|
|
76
|
-
"Mixer.sources item assignment": (Mixer(source=SamplesGenerator(), sources=[SamplesGenerator()]), "obj.sources[0] = SamplesGenerator(numchannels=1)"),
|
|
77
|
-
"Mixer.sources list assignment": (Mixer(sources=[SamplesGenerator()]), "obj.sources = [SamplesGenerator(), SamplesGenerator()]"),
|
|
78
|
-
"WriteWAV.channels item assignment": (WriteWAV(channels=[1]), "obj.channels[0] = 0"),
|
|
79
|
-
"WriteWAV.channels list assignment": (WriteWAV(), "obj.channels = [0]"),
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class Test_DigestChange(TestCase):
|
|
84
|
-
"""Test that ensures that digest of Acoular classes changes correctly on
|
|
85
|
-
changes of CArray and List attributes.
|
|
86
|
-
"""
|
|
87
|
-
|
|
88
|
-
def get_digests(self,obj,statement):
|
|
89
|
-
"""A function that collects the digest of the obj before (d1) and
|
|
90
|
-
after (d2) executing the statement that should yield to a change
|
|
91
|
-
of the object digest.
|
|
92
|
-
|
|
93
|
-
Parameters
|
|
94
|
-
----------
|
|
95
|
-
obj : instance
|
|
96
|
-
class instance that has an attribute `digest`
|
|
97
|
-
statement : "str"
|
|
98
|
-
a string that can be executed
|
|
99
|
-
|
|
100
|
-
Returns
|
|
101
|
-
-------
|
|
102
|
-
str, str
|
|
103
|
-
digest before and after statement execution
|
|
104
|
-
"""
|
|
105
|
-
d1 = obj.digest
|
|
106
|
-
exec(statement)
|
|
107
|
-
d2 = obj.digest
|
|
108
|
-
return d1,d2
|
|
109
|
-
|
|
110
|
-
def test_digest_changes_on_assignment(self):
|
|
111
|
-
""" test that object digest change on statement execution """
|
|
112
|
-
for test_label,(obj,statement) in UNEQUAL_DIGEST_TEST_DICT.items():
|
|
113
|
-
# use subtest to get individual test result.
|
|
114
|
-
# tests will not stop if one subtest fails!
|
|
115
|
-
with self.subTest(test_label):
|
|
116
|
-
digest_before_statement,digest_after_statement = self.get_digests(obj, statement)
|
|
117
|
-
self.assertNotEqual(digest_before_statement,digest_after_statement)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if __name__ == '__main__':
|
|
122
|
-
import unittest
|
|
123
|
-
unittest.main()
|
|
124
|
-
|
|
125
|
-
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#pylint: disable-msg=E0611, E1101, C0103, R0901, R0902, R0903, R0904, W0232
|
|
3
|
-
#------------------------------------------------------------------------------
|
|
4
|
-
# Copyright (c) Acoular Development Team.
|
|
5
|
-
#------------------------------------------------------------------------------
|
|
6
|
-
"""Implements testing of environments and helpers.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import unittest
|
|
10
|
-
|
|
11
|
-
from os.path import join
|
|
12
|
-
|
|
13
|
-
import numpy as np
|
|
14
|
-
#acoular imports
|
|
15
|
-
import acoular
|
|
16
|
-
acoular.config.global_caching = 'none' # to make sure that nothing is cached
|
|
17
|
-
|
|
18
|
-
from acoular import MicGeom, RectGrid3D, \
|
|
19
|
-
SlotJet, OpenJet, RotatingFlow, \
|
|
20
|
-
Environment, UniformFlowEnvironment, GeneralFlowEnvironment
|
|
21
|
-
|
|
22
|
-
# if this flag is set to True
|
|
23
|
-
WRITE_NEW_REFERENCE_DATA = False
|
|
24
|
-
# results are generated for comparison during testing.
|
|
25
|
-
# Should always be False. Only set to True if it is necessary to
|
|
26
|
-
# recalculate the data due to intended changes of the Beamformers.
|
|
27
|
-
|
|
28
|
-
m = MicGeom()
|
|
29
|
-
m.mpos_tot = ((0.5,0.5,0),(0,0,0),(-0.5,-0.5,0))
|
|
30
|
-
mc = m.mpos
|
|
31
|
-
g = RectGrid3D(x_min=-0.2, x_max=0.2, y_min=-0.2, y_max=0.2, z_min=0.5, z_max=0.9,
|
|
32
|
-
increment=0.2 )
|
|
33
|
-
gc = g.gpos
|
|
34
|
-
|
|
35
|
-
flows = [
|
|
36
|
-
SlotJet(v0=70.0, origin=(-0.7,0,0.7)),
|
|
37
|
-
OpenJet(v0=70.0, origin=(-0.7,0,0.7)),
|
|
38
|
-
RotatingFlow(v0=70.0, rpm=1000.0)
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
envs = [
|
|
42
|
-
Environment(),
|
|
43
|
-
UniformFlowEnvironment(ma=0.3),
|
|
44
|
-
GeneralFlowEnvironment(ff=OpenJet(v0=70.0, origin=(-0.7,0,0.7)))
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class acoular_env_test(unittest.TestCase):
|
|
49
|
-
|
|
50
|
-
def test_flow_results(self):
|
|
51
|
-
for fl in flows:
|
|
52
|
-
with self.subTest(fl.__class__.__name__):
|
|
53
|
-
name = join('reference_data',f'{fl.__class__.__name__}.npy')
|
|
54
|
-
# stack all results
|
|
55
|
-
actual_data = np.array([np.vstack(fl.v(x)) for x in gc.T])
|
|
56
|
-
if WRITE_NEW_REFERENCE_DATA:
|
|
57
|
-
np.save(name,actual_data)
|
|
58
|
-
ref_data = np.load(name)
|
|
59
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=1e-5, atol=1e-8)
|
|
60
|
-
|
|
61
|
-
def test_env_results(self):
|
|
62
|
-
for env in envs:
|
|
63
|
-
with self.subTest(env.__class__.__name__):
|
|
64
|
-
name = join('reference_data',f'{env.__class__.__name__}.npy')
|
|
65
|
-
# stack all results
|
|
66
|
-
actual_data = np.vstack((env._r(gc,mc).T,env._r(gc).T))
|
|
67
|
-
if WRITE_NEW_REFERENCE_DATA:
|
|
68
|
-
np.save(name,actual_data)
|
|
69
|
-
ref_data = np.load(name)
|
|
70
|
-
np.testing.assert_allclose(actual_data, ref_data, rtol=1e-5, atol=1e-8)
|
|
71
|
-
|
|
72
|
-
if __name__ == '__main__':
|
|
73
|
-
unittest.main()
|