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
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python2
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
import time as tm
|
|
7
|
-
|
|
8
|
-
import numpy as np
|
|
9
|
-
from numba import guvectorize, complex128, float64
|
|
10
|
-
|
|
11
|
-
import sharedFunctions as shFncs
|
|
12
|
-
from beamformer import r_beamfull_os_classic, r_beamdiag_os_classic # The benchmark (created with scipy.weave)
|
|
13
|
-
#from beamformer_withoutMP import r_beamfull_inverse_withoutMP # also created with scipy.weave, but WITHOUT using multiple cores via OpenMP
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#%% NUMBA - GUVECTORIZE
|
|
17
|
-
def csmBeamformer(csm, r0, rm, kj):
|
|
18
|
-
""" Benchmark for comparison of correctness.
|
|
19
|
-
"""
|
|
20
|
-
nFreqs = csm.shape[0]
|
|
21
|
-
nGridPoints = r0.shape[0]
|
|
22
|
-
beamformOutput = np.zeros((nFreqs, nGridPoints), np.complex128)
|
|
23
|
-
for cntFreqs in xrange(nFreqs):
|
|
24
|
-
for cntGrid in xrange(nGridPoints):
|
|
25
|
-
steeringVector = np.exp(-1j * np.float32(kj[cntFreqs].imag * (rm[cntGrid, :] - r0[cntGrid])))
|
|
26
|
-
# correct
|
|
27
|
-
result = np.dot(steeringVector, csm[cntFreqs, :, :])
|
|
28
|
-
beamformOutput[cntFreqs, cntGrid] = np.vdot(steeringVector, result)
|
|
29
|
-
|
|
30
|
-
# incorrect
|
|
31
|
-
# result = np.dot(csm[cntFreqs, :, :], steeringVector)
|
|
32
|
-
# beamformOutput[cntFreqs, cntGrid] = np.vdot(steeringVector, result)
|
|
33
|
-
return beamformOutput.real / nMics**2
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def correctResult(r0, rm, kj, eigVal, eigVec):
|
|
37
|
-
nFreqs, nGridPoints, nMics = kj.shape[0], rm.shape[0], rm.shape[1]
|
|
38
|
-
beamformOutput = np.zeros((nFreqs, nGridPoints), np.float64)
|
|
39
|
-
for cntFreqs in xrange(nFreqs):
|
|
40
|
-
for cntGrid in xrange(nGridPoints):
|
|
41
|
-
steeringVector = np.exp(-1j * np.float32(kj[cntFreqs].imag * (rm[cntGrid, :] - r0[cntGrid])))
|
|
42
|
-
result = 0.0
|
|
43
|
-
for cntEWs in range(eigVal.shape[1]):
|
|
44
|
-
# spectralCSM = np.outer(eigVec[cntFreqs, :, cntEWs], eigVec[cntFreqs, :, cntEWs].conj())
|
|
45
|
-
# result += np.inner(np.inner(steeringVector.conj(), spectralCSM), steeringVector) * eigVal[cntFreqs, cntEWs]
|
|
46
|
-
# beamformOutput[cntFreqs, cntGrid] = result
|
|
47
|
-
result += np.vdot(eigVec[cntFreqs, :, cntEWs], steeringVector.conj()) * eigVal[cntFreqs, cntEWs] * eigVec[cntFreqs, :, cntEWs]
|
|
48
|
-
beamformOutput[cntFreqs, cntGrid] = np.dot(steeringVector, result)
|
|
49
|
-
return beamformOutput.real / nMics**2
|
|
50
|
-
|
|
51
|
-
def loops_NumbaGuvectorizeOverGrid(r0, rm, kj, eigVal, eigVec):
|
|
52
|
-
nFreqs, nGridPoints, nMics = kj.shape[0], rm.shape[0], rm.shape[1]
|
|
53
|
-
beamformOutput = np.zeros((nFreqs, nGridPoints), np.float64)
|
|
54
|
-
for cntFreqs in xrange(nFreqs):
|
|
55
|
-
result = np.zeros(nGridPoints, np.float64)
|
|
56
|
-
loops_Core(eigVal[cntFreqs, :], eigVec[cntFreqs, :, :], r0, rm, kj[cntFreqs].imag, nMics, result)
|
|
57
|
-
beamformOutput[cntFreqs, :] = result
|
|
58
|
-
return beamformOutput
|
|
59
|
-
|
|
60
|
-
@guvectorize([(float64[:], complex128[:,:], float64[:], float64[:], float64[:], float64[:], float64[:])],
|
|
61
|
-
'(e),(m,e),(),(m),(),()->()', nopython=True, target='parallel')
|
|
62
|
-
def loops_Core(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics,
|
|
63
|
-
waveNumber, nMicsForNormalization, result):
|
|
64
|
-
# init
|
|
65
|
-
nMics = distGridToAllMics.shape[0]
|
|
66
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
67
|
-
|
|
68
|
-
# building steering vector: in order to save some operaions -> some normalization steps are applied after mat-vec-multipl.
|
|
69
|
-
for cntMics in xrange(nMics):
|
|
70
|
-
temp = np.float32(waveNumber[0] * (distGridToAllMics[cntMics] - distGridToArrayCenter[0]))
|
|
71
|
-
steerVec[cntMics] = (np.cos(temp) - 1j * np.sin(temp))
|
|
72
|
-
|
|
73
|
-
# performing matrix-vector-multiplication via spectral decomposition of the hermitian CSM-Matrix
|
|
74
|
-
temp1 = 0.0
|
|
75
|
-
for cntEigVal in range(len(eigVal)):
|
|
76
|
-
temp2 = 0.0
|
|
77
|
-
for cntMics in range(nMics): # Algebraic multiplicity = Geometric multiplicity for any hermitian matrix
|
|
78
|
-
temp2 += eigVec[cntMics, cntEigVal] * steerVec[cntMics]
|
|
79
|
-
temp1 += (temp2 * temp2.conjugate() * eigVal[cntEigVal]).real
|
|
80
|
-
result[0] = temp1 / nMicsForNormalization[0] ** 2
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def loopsCascade_NumbaGuvectorizeOverGrid(r0, rm, kj, eigVal, eigVec):
|
|
84
|
-
nFreqs, nGridPoints, nMics = kj.shape[0], rm.shape[0], rm.shape[1]
|
|
85
|
-
beamformOutput = np.zeros((nFreqs, nGridPoints), np.float64)
|
|
86
|
-
for cntFreqs in xrange(nFreqs):
|
|
87
|
-
result = np.zeros(nGridPoints, np.float64)
|
|
88
|
-
loopsCascade_Core(eigVal[cntFreqs, :], eigVec[cntFreqs, :, :], r0, rm, kj[cntFreqs].imag, nMics, result)
|
|
89
|
-
beamformOutput[cntFreqs, :] = result
|
|
90
|
-
return beamformOutput
|
|
91
|
-
|
|
92
|
-
@guvectorize([(float64[:], complex128[:,:], float64[:], float64[:], float64[:], float64[:], float64[:])],
|
|
93
|
-
'(e),(m,e),(),(m),(),()->()', nopython=True, target='parallel')
|
|
94
|
-
def loopsCascade_Core(eigVal, eigVec, distGridToArrayCenter, distGridToAllMics,
|
|
95
|
-
waveNumber, nMicsForNormalization, result):
|
|
96
|
-
# init
|
|
97
|
-
nMics = distGridToAllMics.shape[0]
|
|
98
|
-
steerVec = np.zeros((nMics), np.complex128)
|
|
99
|
-
|
|
100
|
-
# building steering vector: in order to save some operaions -> some normalization steps are applied after mat-vec-multipl.
|
|
101
|
-
for cntMics in xrange(nMics):
|
|
102
|
-
temp = np.float32(waveNumber[0] * (distGridToAllMics[cntMics] - distGridToArrayCenter[0]))
|
|
103
|
-
steerVec[cntMics] = (np.cos(temp) - 1j * np.sin(temp))
|
|
104
|
-
|
|
105
|
-
# performing matrix-vector-multiplication via spectral decomposition of the hermitian CSM-Matrix
|
|
106
|
-
temp1 = 0.0
|
|
107
|
-
for cntEigVal in range(len(eigVal)):
|
|
108
|
-
temp2 = np.dot(eigVec[:, cntEigVal], steerVec)
|
|
109
|
-
temp1 += (temp2 * temp2.conjugate() * eigVal[cntEigVal]).real
|
|
110
|
-
result[0] = temp1 / nMicsForNormalization[0] ** 2
|
|
111
|
-
#%% MAIN
|
|
112
|
-
listOfMics = [64, 100, 250, 500, 700, 1000]
|
|
113
|
-
listGridPoints = [100, 5000, 10000] # Standard value: 12000 # The number of gridpoints doesn't seeme to have to great of an influence
|
|
114
|
-
nTrials = 10
|
|
115
|
-
listOfNFreqs = [10000]
|
|
116
|
-
|
|
117
|
-
#==============================================================================
|
|
118
|
-
# The benchmark function 'r_beamfull_inverse' and also other implementations of
|
|
119
|
-
# the beamformer create a lot of overhead, which influences the computational
|
|
120
|
-
# effort of the succeding function. This is mostly the case, if concurrent
|
|
121
|
-
# calculations are done (multiple cores). So often the first trial of a new
|
|
122
|
-
# function takes some time longer than the other trials.
|
|
123
|
-
#==============================================================================
|
|
124
|
-
|
|
125
|
-
#funcsToTrial = [csmBeamformer, correctResult, r_beamfull_os_classic] # full csm
|
|
126
|
-
#funcsToTrial = [csmBeamformer, correctResult, r_beamdiag_os_classic] # removed diagonal of csm
|
|
127
|
-
funcsToTrial = [loopsCascade_NumbaGuvectorizeOverGrid, loops_NumbaGuvectorizeOverGrid, r_beamfull_os_classic]
|
|
128
|
-
removeDiagOfCSM = False
|
|
129
|
-
|
|
130
|
-
for nMics in listOfMics:
|
|
131
|
-
for nGridPoints in listGridPoints:
|
|
132
|
-
for nFreqs in listOfNFreqs:
|
|
133
|
-
# Init
|
|
134
|
-
print(10*'-' + 'New Test configuration: nMics=%s, nGridpoints=%s, nFreqs=%s' %(nMics, nGridPoints, nFreqs) + 10*'-')
|
|
135
|
-
print(10*'-' + 'Creation of inputInputs' + 10*'-')
|
|
136
|
-
|
|
137
|
-
# Inputs for the beamformer methods:
|
|
138
|
-
# At the moment the beamformer-methods are called once per
|
|
139
|
-
# frequency (CSM is a Matrix, no 3rd-order-tensor)
|
|
140
|
-
# For easier camparability we build the CSM as a 3rd-order-tensor) instead
|
|
141
|
-
csm = np.random.rand(nFreqs, nMics, nMics) + 1j*np.random.rand(nFreqs, nMics, nMics) # cross spectral matrix
|
|
142
|
-
for cntFreqs in range(nFreqs):
|
|
143
|
-
csm[cntFreqs, :, :] += csm[cntFreqs, :, :].T.conj() # make CSM hermetical
|
|
144
|
-
e = np.random.rand(nMics) + 1j*np.random.rand(nMics) # has no usage
|
|
145
|
-
h = np.zeros((nFreqs, nGridPoints)) # results are stored here, if function has no return value
|
|
146
|
-
r0 = np.random.rand(nGridPoints) # distance between gridpoints and middle of array
|
|
147
|
-
rm = np.random.rand(nGridPoints, nMics) # distance between gridpoints and all mics in the array
|
|
148
|
-
kj = np.zeros(nFreqs) + 1j*np.random.rand(nFreqs) # complex wavenumber
|
|
149
|
-
eigVal, eigVec = np.linalg.eigh(csm)
|
|
150
|
-
indLow = 5 # 5
|
|
151
|
-
indHigh = 10# 10
|
|
152
|
-
|
|
153
|
-
# remove diagonal of csm
|
|
154
|
-
if removeDiagOfCSM:
|
|
155
|
-
for cntMics in range(nMics):
|
|
156
|
-
csm[cntFreqs, cntMics, cntMics] = 0
|
|
157
|
-
eigValDiag, eigVecDiag = np.linalg.eigh(csm)
|
|
158
|
-
refFunc = 'r_beamdiag_os_classic'
|
|
159
|
-
resultReference = correctResult(r0, rm, kj, eigValDiag[:, indLow : indHigh], eigVecDiag[:, :, indLow : indHigh]) # For relative/absolute error
|
|
160
|
-
else:
|
|
161
|
-
refFunc = 'r_beamfull_os_classic'
|
|
162
|
-
resultReference = correctResult(r0, rm, kj, eigVal[:, indLow : indHigh], eigVec[:, :, indLow : indHigh]) # For relative/absolute error
|
|
163
|
-
|
|
164
|
-
nameOfFuncsToTrial = map(lambda x: x.__name__, funcsToTrial)
|
|
165
|
-
nameOfFuncsForError = [funcName for funcName in nameOfFuncsToTrial if funcName != refFunc]
|
|
166
|
-
maxRelativeDeviation = np.zeros((len(funcsToTrial), nTrials))
|
|
167
|
-
maxAbsoluteDeviation = np.zeros((len(funcsToTrial), nTrials))
|
|
168
|
-
timeConsumption = [[] for _ in range(len(funcsToTrial))]
|
|
169
|
-
indOfBaselineFnc = nameOfFuncsToTrial.index(refFunc)
|
|
170
|
-
|
|
171
|
-
# Testing
|
|
172
|
-
print(10*'-' + 'Testing of functions' + 10*'-')
|
|
173
|
-
cntFunc = 0
|
|
174
|
-
for func in funcsToTrial:
|
|
175
|
-
print(func.__name__)
|
|
176
|
-
for cntTrials in xrange(nTrials):
|
|
177
|
-
h = np.zeros((nFreqs, nGridPoints))
|
|
178
|
-
if func.__name__ == refFunc:
|
|
179
|
-
t0 = tm.time()
|
|
180
|
-
func(e, h, r0, rm, kj, eigVal, eigVec, indLow, indHigh)
|
|
181
|
-
t1 = tm.time()
|
|
182
|
-
result = h / nMics**2
|
|
183
|
-
elif func.__name__ == 'correctResult' and removeDiagOfCSM:
|
|
184
|
-
t0 = tm.time()
|
|
185
|
-
output = func(r0, rm, kj, eigValDiag[:, indLow : indHigh], eigVecDiag[:, :, indLow : indHigh])
|
|
186
|
-
t1 = tm.time()
|
|
187
|
-
result = output
|
|
188
|
-
elif func.__name__ == 'csmBeamformer':
|
|
189
|
-
t0 = tm.time()
|
|
190
|
-
output = func(csm, r0, rm, kj)
|
|
191
|
-
t1 = tm.time()
|
|
192
|
-
result = output
|
|
193
|
-
else:
|
|
194
|
-
t0 = tm.time()
|
|
195
|
-
output = func(r0, rm, kj, eigVal[:, indLow : indHigh], eigVec[:, :, indLow : indHigh])
|
|
196
|
-
t1 = tm.time()
|
|
197
|
-
result = output
|
|
198
|
-
timeConsumption[cntFunc].append(t1 - t0)
|
|
199
|
-
relativeDiffBetweenNewCodeAndRef = (result - resultReference) / (result + resultReference) * 2 # error in relation to the resulting value
|
|
200
|
-
maxRelativeDeviation[cntFunc, cntTrials] = np.amax(np.amax(abs(relativeDiffBetweenNewCodeAndRef), axis=1), axis=0) # relative error in inf-norm
|
|
201
|
-
maxAbsoluteDeviation[cntFunc, cntTrials] = np.amax(np.amax(abs(result - resultReference), axis=1), axis=0) # absolute error in inf-norm
|
|
202
|
-
cntFunc += 1
|
|
203
|
-
factorTimeConsump = [np.mean(timeConsumption[cnt]) for cnt in range(0, len(funcsToTrial))] \
|
|
204
|
-
/ np.mean(timeConsumption[indOfBaselineFnc])
|
|
205
|
-
|
|
206
|
-
# Save the current test-config as .sav
|
|
207
|
-
helpString = 'The order of the variables is: \n nameOfFuncsToTrial \n maxRelativeDeviation'\
|
|
208
|
-
'\n timeConsumption [nFuncs, nTrials] \n nMics \n nGridPoints \n nFreqs '\
|
|
209
|
-
'\n Factor of time consumption (in relation to the original .cpp) \n maxAbsoluteDeviation \n nThreadsGlobal'
|
|
210
|
-
saveTupel = (helpString, nameOfFuncsToTrial, maxRelativeDeviation, timeConsumption,
|
|
211
|
-
nMics, nGridPoints, nFreqs, factorTimeConsump, maxAbsoluteDeviation, 0)
|
|
212
|
-
stringParameters = 'OvernightTestcasesBeamformer_nMics%s_nGridPoints%s_nFreqs%s_nTrials%s' %(nMics, nGridPoints, nFreqs, nTrials)
|
|
213
|
-
|
|
214
|
-
# stringSaveName = 'Peter'
|
|
215
|
-
stringSaveName = 'Sicherung_DurchgelaufeneTests/Beamformer/cascadingSums/' + stringParameters
|
|
216
|
-
# stringSaveName = 'Sicherung_DurchgelaufeneTests/Beamformer/AllImportantMethods/' + stringParameters
|
|
217
|
-
# stringSaveName = 'Sicherung_DurchgelaufeneTests/Beamformer/EinflussGridpoints/AMDFX6100/' + stringParameters
|
|
218
|
-
# stringSaveName = 'Sicherung_DurchgelaufeneTests/Beamformer/JitPrange/' + stringParameters
|
|
219
|
-
# stringSaveName = 'Sicherung_DurchgelaufeneTests/Beamformer/Multithreading_02Threads/' + stringParameters
|
|
220
|
-
|
|
221
|
-
shFncs.savingTimeConsumption(stringSaveName, saveTupel) # saving as "stringSaveName.sav"
|
|
222
|
-
|
|
223
|
-
# shFncs.plottingOfOvernightTestcasesBeamformer(stringSaveName + '.sav') # plot of the current test-config
|
|
224
|
-
|
|
225
|
-
#==============================================================================
|
|
226
|
-
#The Following use of the numba decorators could lead to less code (as a function
|
|
227
|
-
#body could be used more often) but is also slower, which is why it wasn't used
|
|
228
|
-
#in this comparison.
|
|
229
|
-
# signature = complex128[:,:](complex128[:,:,:], float64[:], float64[:,:])
|
|
230
|
-
# numbaOptimizedFunction= jit(signature, nopython=True)(plainPythonFunction.py_func)
|
|
231
|
-
#==============================================================================
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python2
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
Created on Fri Sep 15 11:24:36 2017
|
|
5
|
-
|
|
6
|
-
@author: tomgensch
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import numba as nb
|
|
10
|
-
import time as tm
|
|
11
|
-
|
|
12
|
-
@nb.njit
|
|
13
|
-
def absASquared(N):
|
|
14
|
-
a = 42.0 + 87.0j
|
|
15
|
-
for cnt in xrange(N):
|
|
16
|
-
peter = abs(a) * abs(a)
|
|
17
|
-
return peter
|
|
18
|
-
@nb.njit
|
|
19
|
-
def aTimesAConj(N):
|
|
20
|
-
a = 42.0 + 87.0j
|
|
21
|
-
for cnt in xrange(N):
|
|
22
|
-
peter = (a * a.conjugate()).real
|
|
23
|
-
return peter
|
|
24
|
-
@nb.njit
|
|
25
|
-
def realSquaredPlusImagSquared(N):
|
|
26
|
-
a = 42.0 + 87.0j
|
|
27
|
-
for cnt in xrange(N):
|
|
28
|
-
peter = a.real * a.real + a.imag * a.imag
|
|
29
|
-
return peter
|
|
30
|
-
|
|
31
|
-
N = 3000000000
|
|
32
|
-
t0 = tm.time()
|
|
33
|
-
erg1 = absASquared(N)
|
|
34
|
-
timeAbsASquared = tm.time() - t0
|
|
35
|
-
|
|
36
|
-
t0 = tm.time()
|
|
37
|
-
erg2 = aTimesAConj(N)
|
|
38
|
-
timeATimesAConj = tm.time() - t0
|
|
39
|
-
|
|
40
|
-
t0 = tm.time()
|
|
41
|
-
erg3 = realSquaredPlusImagSquared(N)
|
|
42
|
-
timeRealSquaredPlusImagSquared = tm.time() - t0
|
|
43
|
-
|
|
44
|
-
faktorAbsSquareVstimeRealSquaredPlusImagSquared = timeAbsASquared / timeRealSquaredPlusImagSquared
|
|
45
|
-
faktortimeATimesAConjVstimeRealSquaredPlusImagSquared = timeATimesAConj / timeRealSquaredPlusImagSquared
|
|
46
|
-
|
|
47
|
-
print('abs(a)**2 / (a.real**2 + a.imag**2): %s' %(faktorAbsSquareVstimeRealSquaredPlusImagSquared))
|
|
48
|
-
print('a*a.conj / (a.real**2 + a.imag**2): %s' %(faktortimeATimesAConjVstimeRealSquaredPlusImagSquared))
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
Example 6 for acoular library
|
|
4
|
-
|
|
5
|
-
demonstrates different steering vectors in acoular,
|
|
6
|
-
and CSM diagonal removal
|
|
7
|
-
with same setup as in example 1
|
|
8
|
-
|
|
9
|
-
uses measured data in file example_data.h5
|
|
10
|
-
calibration in file example_calib.xml
|
|
11
|
-
microphone geometry in array_56.xml (part of acoular)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Copyright (c) 2006-2017 The Acoular developers.
|
|
15
|
-
All rights reserved.
|
|
16
|
-
"""
|
|
17
|
-
from __future__ import print_function
|
|
18
|
-
|
|
19
|
-
# imports from acoular
|
|
20
|
-
import acoular
|
|
21
|
-
from acoular import L_p, Calib, MicGeom, EigSpectra, \
|
|
22
|
-
RectGrid, BeamformerBase, BeamformerEig, BeamformerOrth, BeamformerCleansc, \
|
|
23
|
-
MaskedTimeSamples, BeamformerDamas, BeamformerFunctional
|
|
24
|
-
|
|
25
|
-
# other imports
|
|
26
|
-
from os import path
|
|
27
|
-
from pylab import figure, subplot, imshow, show, colorbar, title, suptitle
|
|
28
|
-
|
|
29
|
-
# files
|
|
30
|
-
datafile = 'example_data.h5'
|
|
31
|
-
calibfile = 'example_calib.xml'
|
|
32
|
-
micgeofile = path.join( path.split(acoular.__file__)[0],'xml','array_56.xml')
|
|
33
|
-
|
|
34
|
-
#octave band of interest
|
|
35
|
-
cfreq = 4000
|
|
36
|
-
|
|
37
|
-
#===============================================================================
|
|
38
|
-
# first, we define the time samples using the MaskedTimeSamples class
|
|
39
|
-
# alternatively we could use the TimeSamples class that provides no masking
|
|
40
|
-
# of channels and samples
|
|
41
|
-
#===============================================================================
|
|
42
|
-
t1 = MaskedTimeSamples(name=datafile)
|
|
43
|
-
t1.start = 0 # first sample, default
|
|
44
|
-
t1.stop = 16000 # last valid sample = 15999
|
|
45
|
-
invalid = [1,7] # list of invalid channels (unwanted microphones etc.)
|
|
46
|
-
t1.invalid_channels = invalid
|
|
47
|
-
|
|
48
|
-
#===============================================================================
|
|
49
|
-
# calibration is usually needed and can be set directly at the TimeSamples
|
|
50
|
-
# object (preferred) or for frequency domain processing at the PowerSpectra
|
|
51
|
-
# object (for backwards compatibility)
|
|
52
|
-
#===============================================================================
|
|
53
|
-
t1.calib = Calib(from_file=calibfile)
|
|
54
|
-
|
|
55
|
-
#===============================================================================
|
|
56
|
-
# the microphone geometry must have the same number of valid channels as the
|
|
57
|
-
# TimeSamples object has
|
|
58
|
-
#===============================================================================
|
|
59
|
-
m = MicGeom(from_file=micgeofile)
|
|
60
|
-
m.invalid_channels = invalid
|
|
61
|
-
|
|
62
|
-
#===============================================================================
|
|
63
|
-
# the grid for the beamforming map; a RectGrid3D class is also available
|
|
64
|
-
# (the example grid is very coarse)
|
|
65
|
-
#===============================================================================
|
|
66
|
-
g = RectGrid(x_min=-0.6, x_max=-0.0, y_min=-0.3, y_max=0.3, z=0.68,
|
|
67
|
-
increment=0.05)
|
|
68
|
-
|
|
69
|
-
#===============================================================================
|
|
70
|
-
# for frequency domain methods, this provides the cross spectral matrix and its
|
|
71
|
-
# eigenvalues and eigenvectors, if only the matrix is needed then class
|
|
72
|
-
# PowerSpectra can be used instead
|
|
73
|
-
#===============================================================================
|
|
74
|
-
f = EigSpectra(time_data=t1,
|
|
75
|
-
window='Hanning', overlap='50%', block_size=128, #FFT-parameters
|
|
76
|
-
ind_low=7, ind_high=15) #to save computational effort, only
|
|
77
|
-
# frequencies with index 1-30 are used
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
#===============================================================================
|
|
81
|
-
# beamformers in frequency domain
|
|
82
|
-
#===============================================================================
|
|
83
|
-
bb = BeamformerBase(freq_data=f, grid=g, mpos=m, r_diag=True, c=346.04)
|
|
84
|
-
bd = BeamformerDamas(beamformer=bb, n_iter=100)
|
|
85
|
-
be = BeamformerEig(freq_data=f, grid=g, mpos=m, r_diag=True, c=346.04, n=54)
|
|
86
|
-
bo = BeamformerOrth(beamformer=be, eva_list=list(range(38,54)))
|
|
87
|
-
bs = BeamformerCleansc(freq_data=f, grid=g, mpos=m, r_diag=True, c=346.04)
|
|
88
|
-
bf = BeamformerFunctional(freq_data=f, grid=g, mpos=m, r_diag=True, c=346.04, gamma = 60)
|
|
89
|
-
|
|
90
|
-
#===============================================================================
|
|
91
|
-
# plot result maps for different beamformers in frequency domain
|
|
92
|
-
#===============================================================================
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
fi = 1 #no of figure
|
|
97
|
-
for r_diag in (True,False):
|
|
98
|
-
figure(fi)
|
|
99
|
-
suptitle('Old Implementation | R_diag=' + str(r_diag))
|
|
100
|
-
fi +=1
|
|
101
|
-
bb.r_diag = r_diag
|
|
102
|
-
be.r_diag = r_diag
|
|
103
|
-
bs.r_diag = r_diag
|
|
104
|
-
bf.r_diag = r_diag
|
|
105
|
-
i1 = 1 #no of subplot
|
|
106
|
-
for steer in ('true level', 'true location', 'classic', 'inverse'):
|
|
107
|
-
bb.steer = steer
|
|
108
|
-
be.steer = steer
|
|
109
|
-
bs.steer = steer
|
|
110
|
-
bf.steer = steer
|
|
111
|
-
for b in (bb, bd, bo, bs, bf):
|
|
112
|
-
subplot(4,5,i1)
|
|
113
|
-
i1 += 1
|
|
114
|
-
map = b.synthetic(cfreq,1)
|
|
115
|
-
mx = L_p(map.max())
|
|
116
|
-
imshow(L_p(map.T), vmax=mx, vmin=mx-15,
|
|
117
|
-
interpolation='nearest', extent=g.extend())
|
|
118
|
-
print(b.steer)
|
|
119
|
-
colorbar()
|
|
120
|
-
title(b.__class__.__name__,fontsize='small')
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
show()
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
Example 6 for acoular library
|
|
4
|
-
|
|
5
|
-
demonstrates different steering vectors in acoular,
|
|
6
|
-
and CSM diagonal removal
|
|
7
|
-
with same setup as in example 1
|
|
8
|
-
|
|
9
|
-
uses measured data in file example_data.h5
|
|
10
|
-
calibration in file example_calib.xml
|
|
11
|
-
microphone geometry in array_56.xml (part of acoular)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Copyright (c) 2006-2017 The Acoular developers.
|
|
15
|
-
All rights reserved.
|
|
16
|
-
"""
|
|
17
|
-
from __future__ import print_function
|
|
18
|
-
|
|
19
|
-
# imports from acoular
|
|
20
|
-
import acoular
|
|
21
|
-
from acoular import L_p, Calib, MicGeom, EigSpectra, \
|
|
22
|
-
RectGrid, BeamformerBase, BeamformerEig, BeamformerOrth, BeamformerCleansc, \
|
|
23
|
-
MaskedTimeSamples, BeamformerDamas, BeamformerFunctional, PointSpreadFunction, BeamformerClean, BeamformerDamasPlus
|
|
24
|
-
|
|
25
|
-
# other imports
|
|
26
|
-
from os import path
|
|
27
|
-
from pylab import figure, subplot, imshow, show, colorbar, title, suptitle
|
|
28
|
-
|
|
29
|
-
# files
|
|
30
|
-
datafile = 'example_data.h5'
|
|
31
|
-
calibfile = 'example_calib.xml'
|
|
32
|
-
micgeofile = path.join( path.split(acoular.__file__)[0],'xml','array_56.xml')
|
|
33
|
-
|
|
34
|
-
#octave band of interest
|
|
35
|
-
cfreq = 4000
|
|
36
|
-
|
|
37
|
-
#===============================================================================
|
|
38
|
-
# first, we define the time samples using the MaskedTimeSamples class
|
|
39
|
-
# alternatively we could use the TimeSamples class that provides no masking
|
|
40
|
-
# of channels and samples
|
|
41
|
-
#===============================================================================
|
|
42
|
-
t1 = MaskedTimeSamples(name=datafile)
|
|
43
|
-
t1.start = 0 # first sample, default
|
|
44
|
-
t1.stop = 16000 # last valid sample = 15999
|
|
45
|
-
invalid = [1,7] # list of invalid channels (unwanted microphones etc.)
|
|
46
|
-
t1.invalid_channels = invalid
|
|
47
|
-
|
|
48
|
-
#===============================================================================
|
|
49
|
-
# calibration is usually needed and can be set directly at the TimeSamples
|
|
50
|
-
# object (preferred) or for frequency domain processing at the PowerSpectra
|
|
51
|
-
# object (for backwards compatibility)
|
|
52
|
-
#===============================================================================
|
|
53
|
-
t1.calib = Calib(from_file=calibfile)
|
|
54
|
-
|
|
55
|
-
#===============================================================================
|
|
56
|
-
# the microphone geometry must have the same number of valid channels as the
|
|
57
|
-
# TimeSamples object has
|
|
58
|
-
#===============================================================================
|
|
59
|
-
m = MicGeom(from_file=micgeofile)
|
|
60
|
-
m.invalid_channels = invalid
|
|
61
|
-
|
|
62
|
-
#===============================================================================
|
|
63
|
-
# the grid for the beamforming map; a RectGrid3D class is also available
|
|
64
|
-
# (the example grid is very coarse)
|
|
65
|
-
#===============================================================================
|
|
66
|
-
g = RectGrid(x_min=-0.6, x_max=-0.0, y_min=-0.3, y_max=0.3, z=0.68,
|
|
67
|
-
increment=0.05)
|
|
68
|
-
|
|
69
|
-
#===============================================================================
|
|
70
|
-
# for frequency domain methods, this provides the cross spectral matrix and its
|
|
71
|
-
# eigenvalues and eigenvectors, if only the matrix is needed then class
|
|
72
|
-
# PowerSpectra can be used instead
|
|
73
|
-
#===============================================================================
|
|
74
|
-
f = EigSpectra(time_data=t1,
|
|
75
|
-
window='Hanning', overlap='50%', block_size=128, #FFT-parameters
|
|
76
|
-
ind_low=7, ind_high=15, precision='complex128') #to save computational effort, only
|
|
77
|
-
# frequencies with index 1-30 are used
|
|
78
|
-
csm = f.csm[:]
|
|
79
|
-
eva = f.eva[:]
|
|
80
|
-
|
|
81
|
-
f32 = EigSpectra(time_data=t1,
|
|
82
|
-
window='Hanning', overlap='50%', block_size=128, #FFT-parameters
|
|
83
|
-
ind_low=7, ind_high=15, precision='complex64') #to save computational effort, only
|
|
84
|
-
csm32 = f32.csm[:]
|
|
85
|
-
eva32 = f32.eva[:]
|
|
86
|
-
|
|
87
|
-
psf32 = PointSpreadFunction(grid=g, mpos=m, c=346.04, precision='float32')
|
|
88
|
-
psf32Res = psf32.psf[:]
|
|
89
|
-
|
|
90
|
-
psf64 = PointSpreadFunction(grid=g, mpos=m, c=346.04, precision='float64')
|
|
91
|
-
psf64Res = psf64.psf[:]
|
|
92
|
-
|
|
93
|
-
bb32 = BeamformerBase(freq_data=f, grid=g, mpos=m, r_diag=True, c=346.04, precision='float32')
|
|
94
|
-
bb32Res = bb32.synthetic(cfreq,1)
|
|
95
|
-
|
|
96
|
-
bb64 = BeamformerBase(freq_data=f, grid=g, mpos=m, r_diag=True, c=346.04, precision='float64')
|
|
97
|
-
bb64Res = bb64.synthetic(cfreq,1)
|
|
98
|
-
|
|
99
|
-
bf = BeamformerFunctional(freq_data=f, grid=g, mpos=m, r_diag=False, c=346.04, gamma = 60, precision='float32')
|
|
100
|
-
bfRes = bf.synthetic(cfreq,1)
|
|
101
|
-
|
|
102
|
-
# 32 Bit PSF precision
|
|
103
|
-
bd3232 = BeamformerDamas(beamformer=bb32, n_iter=100, psf_precision='float32')
|
|
104
|
-
bd3232Res = bd3232.synthetic(cfreq,1)
|
|
105
|
-
bc3232 = BeamformerClean(beamformer=bb32, psf_precision='float32')
|
|
106
|
-
bc3232Res = bc3232.synthetic(cfreq,1)
|
|
107
|
-
bdp3232 = BeamformerDamasPlus(beamformer=bb32, n_iter=100, psf_precision='float32')
|
|
108
|
-
bdp3232Res = bdp3232.synthetic(cfreq,1)
|
|
109
|
-
|
|
110
|
-
#64 Bit
|
|
111
|
-
bd3264 = BeamformerDamas(beamformer=bb32, n_iter=100, psf_precision='float64')
|
|
112
|
-
bd3264Res = bd3264.synthetic(cfreq,1)
|
|
113
|
-
bc3264 = BeamformerClean(beamformer=bb32, psf_precision='float64')
|
|
114
|
-
bc3264Res = bc3264.synthetic(cfreq,1)
|
|
115
|
-
bdp3264 = BeamformerDamasPlus(beamformer=bb32, n_iter=100, psf_precision='float64')
|
|
116
|
-
bdp3264Res = bdp3264.synthetic(cfreq,1)
|
|
117
|
-
|
|
118
|
-
# 32 Bit PSF precision
|
|
119
|
-
bd6432 = BeamformerDamas(beamformer=bb64, n_iter=100, psf_precision='float32')
|
|
120
|
-
bd6432Res = bd6432.synthetic(cfreq,1)
|
|
121
|
-
bc6432 = BeamformerClean(beamformer=bb64, psf_precision='float32')
|
|
122
|
-
bc6432Res = bc6432.synthetic(cfreq,1)
|
|
123
|
-
bdp6432 = BeamformerDamasPlus(beamformer=bb64, n_iter=100, psf_precision='float32')
|
|
124
|
-
bdp6432Res = bdp6432.synthetic(cfreq,1)
|
|
125
|
-
|
|
126
|
-
#64 Bit
|
|
127
|
-
bd6464 = BeamformerDamas(beamformer=bb64, n_iter=100, psf_precision='float64')
|
|
128
|
-
bd6464Res = bd6464.synthetic(cfreq,1)
|
|
129
|
-
bc6464 = BeamformerClean(beamformer=bb64, psf_precision='float64')
|
|
130
|
-
bc6464Res = bc6464.synthetic(cfreq,1)
|
|
131
|
-
bdp6464 = BeamformerDamasPlus(beamformer=bb64, n_iter=100, psf_precision='float64')
|
|
132
|
-
bdp6464Res = bdp6464.synthetic(cfreq,1)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
#===============================================================================
|
|
137
|
-
# plot result maps for different beamformers in frequency domain
|
|
138
|
-
#===============================================================================
|
|
139
|
-
i1 = 1
|
|
140
|
-
for b in (bb32, bd3232, bc3232, bdp3232, bd3264, bc3264, bdp3264,
|
|
141
|
-
bb64, bd6432, bc6432, bdp6432, bd6464, bc6464, bdp6464):
|
|
142
|
-
subplot(2, 7, i1)
|
|
143
|
-
i1 += 1
|
|
144
|
-
res = b.synthetic(cfreq,1)
|
|
145
|
-
mx = L_p(res.max())
|
|
146
|
-
imshow(L_p(res.T), vmax=mx, vmin=mx-15,
|
|
147
|
-
interpolation='nearest', extent=g.extend())
|
|
148
|
-
print(b.steer)
|
|
149
|
-
colorbar()
|
|
150
|
-
title(b.__class__.__name__ + b.precision,fontsize='small')
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
show()
|