def test_lebedev_grid_0_order_fallback(): lebedev_grid_1 = io.SphericalGrid( azimuth=np.array([0., 0., 0., 1.5707963267948966, 3.1415926535897931, 4.7123889803846897]), colatitude=np.array([0., 1.5707963267948966, 3.1415926535897931, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966]), radius=np.array([1., 1., 1., 1., 1., 1.]), weight=np.array([0.1666666666666667, 0.1666666666666667, 0.1666666666666667, 0.1666666666666667, 0.1666666666666667, 0.1666666666666667]) ) np.testing.assert_allclose(gen.lebedev(max_order=0), lebedev_grid_1)
def test_lebedev_grid_194(): lebedev_grid_194 = io.SphericalGrid( azimuth=np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.1314224389344013, 0.1314224389344013, 0.1879869008650734, 0.1879869008650734, 0.2940860780003485, 0.2940860780003485, 0.3069605019034988, 0.3069605019034988, 0.3530595115392992, 0.4377579511459067, 0.4377579511459067, 0.5195449866495595, 0.5195449866495595, 0.5608291557018665, 0.5608291557018665, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 1.00996717109303, 1.00996717109303, 1.0512513401453372, 1.0512513401453372, 1.1330383756489899, 1.1330383756489899, 1.2177368152555974, 1.2638358248913979, 1.2638358248913979, 1.2767102487945481, 1.2767102487945481, 1.3828094259298231, 1.3828094259298231, 1.4393738878604954, 1.4393738878604954, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.702218765729298, 1.702218765729298, 1.75878322765997, 1.75878322765997, 1.864882404795245, 1.864882404795245, 1.8777568286983954, 1.8777568286983954, 1.9238558383341959, 2.0085542779408034, 2.0085542779408034, 2.0903413134444562, 2.0903413134444562, 2.1316254824967631, 2.1316254824967631, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.5807634978879266, 2.5807634978879266, 2.6220476669402339, 2.6220476669402339, 2.7038347024438867, 2.7038347024438867, 2.7885331420504942, 2.8346321516862942, 2.8346321516862942, 2.8475065755894446, 2.8475065755894446, 2.9536057527247199, 2.9536057527247199, 3.0101702146553921, 3.0101702146553921, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.2730150925241941, 3.2730150925241941, 3.3295795544548663, 3.3295795544548663, 3.4356787315901416, 3.4356787315901416, 3.448553155493292, 3.448553155493292, 3.494652165129092, 3.5793506047356995, 3.5793506047356995, 3.6611376402393523, 3.6611376402393523, 3.7024218092916596, 3.7024218092916596, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 4.1515598246828231, 4.1515598246828231, 4.1928439937351296, 4.1928439937351296, 4.2746310292387832, 4.2746310292387832, 4.3593294688453899, 4.4054284784811912, 4.4054284784811912, 4.4183029023843412, 4.4183029023843412, 4.524402079519616, 4.524402079519616, 4.5809665414502883, 4.5809665414502883, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.8438114193190911, 4.8438114193190911, 4.9003758812497633, 4.9003758812497633, 5.0064750583850381, 5.0064750583850381, 5.0193494822881881, 5.0193494822881881, 5.0654484919239886, 5.1501469315305961, 5.1501469315305961, 5.2319339670342488, 5.2319339670342488, 5.2732181360865562, 5.2732181360865562, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.7223561514777197, 5.7223561514777197, 5.7636403205300271, 5.7636403205300271, 5.8454273560336798, 5.8454273560336798, 5.9301257956402873, 5.9762248052760878, 5.9762248052760878, 5.9890992291792378, 5.9890992291792378, 6.0951984063145126, 6.0951984063145126, 6.1517628682451848, 6.1517628682451848]), colatitude=np.array([0., 2.7885331420504942, 2.3561944901923448, 1.9238558383341957, 1.5707963267948966, 1.2177368152555974, 0.7853981633974483, 3.1415926535897931, 0.3530595115392992, 1.4404943707983893, 1.7010982827914038, 2.1236507622147109, 1.0179418913750822, 0.5807780340897879, 2.5608146195000052, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 2.3067540874479739, 0.8348385661418192, 2.0316281581750033, 1.1099644954147898, 1.7305162597466104, 1.4110763938431827, 1.5707963267948966, 1.2511856323329762, 0.9553166181245093, 0.4214197634066907, 2.4614662316678615, 2.9567887484826221, 0.6801264219219316, 1.8904070212568169, 0.1848039051071708, 2.7201728901831022, 2.1862760354652839, 1.7305162597466104, 1.4110763938431827, 2.0316281581750033, 1.1099644954147898, 2.3067540874479739, 0.8348385661418192, 1.5707963267948966, 1.8642359895206648, 1.2773566640691283, 2.5608146195000052, 0.5807780340897879, 1.0179418913750822, 2.1236507622147109, 1.7010982827914038, 1.4404943707983893, 1.9238558383341957, 1.2177368152555974, 1.5707963267948966, 0.3530595115392992, 2.3561944901923448, 2.7885331420504942, 0.7853981633974483, 1.7010982827914038, 1.4404943707983893, 2.1236507622147109, 1.0179418913750822, 2.5608146195000052, 0.5807780340897879, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 2.3067540874479739, 0.8348385661418192, 1.1099644954147898, 2.0316281581750033, 1.7305162597466104, 1.4110763938431827, 1.5707963267948966, 0.6801264219219316, 2.7201728901831022, 2.9567887484826221, 0.4214197634066907, 1.8904070212568169, 1.2511856323329762, 0.9553166181245093, 2.1862760354652839, 0.1848039051071708, 2.4614662316678615, 1.7305162597466104, 1.4110763938431827, 2.0316281581750033, 1.1099644954147898, 0.8348385661418192, 2.3067540874479739, 1.5707963267948966, 1.8642359895206648, 1.2773566640691283, 0.5807780340897879, 2.5608146195000052, 2.1236507622147109, 1.0179418913750822, 1.4404943707983893, 1.7010982827914038, 1.5707963267948966, 1.2177368152555974, 0.7853981633974483, 2.3561944901923448, 1.9238558383341957, 0.3530595115392992, 2.7885331420504942, 1.7010982827914038, 1.4404943707983893, 1.0179418913750822, 2.1236507622147109, 2.5608146195000052, 0.5807780340897879, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 2.3067540874479739, 0.8348385661418192, 2.0316281581750033, 1.1099644954147898, 1.7305162597466104, 1.4110763938431827, 1.8904070212568169, 0.4214197634066907, 2.9567887484826221, 1.2511856323329762, 0.6801264219219316, 0.1848039051071708, 2.4614662316678615, 2.7201728901831022, 1.5707963267948966, 2.1862760354652839, 0.9553166181245093, 1.7305162597466104, 1.4110763938431827, 2.0316281581750033, 1.1099644954147898, 2.3067540874479739, 0.8348385661418192, 1.5707963267948966, 1.2773566640691283, 1.8642359895206648, 2.5608146195000052, 0.5807780340897879, 1.0179418913750822, 2.1236507622147109, 1.7010982827914038, 1.4404943707983893, 1.9238558383341957, 2.3561944901923448, 0.7853981633974483, 1.2177368152555974, 0.3530595115392992, 1.5707963267948966, 2.7885331420504942, 1.4404943707983893, 1.7010982827914038, 2.1236507622147109, 1.0179418913750822, 2.5608146195000052, 0.5807780340897879, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 0.8348385661418192, 2.3067540874479739, 2.0316281581750033, 1.1099644954147898, 1.4110763938431827, 1.7305162597466104, 0.6801264219219316, 1.5707963267948966, 2.7201728901831022, 2.9567887484826221, 0.4214197634066907, 0.1848039051071708, 2.4614662316678615, 1.8904070212568169, 2.1862760354652839, 0.9553166181245093, 1.2511856323329762, 1.4110763938431827, 1.7305162597466104, 2.0316281581750033, 1.1099644954147898, 2.3067540874479739, 0.8348385661418192, 1.5707963267948966, 1.2773566640691283, 1.8642359895206648, 2.5608146195000052, 0.5807780340897879, 2.1236507622147109, 1.0179418913750822, 1.7010982827914038, 1.4404943707983893]), radius=np.ones(194), weight=np.array([0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0050518460646148, 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0017823404472446, 0.0050518460646148, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0057169059499771, 0.005608704082588, 0.0055733831788487, 0.0051582377118054, 0.0055187714672736, 0.0041067770281694, 0.0055187714672736, 0.005608704082588, 0.0041067770281694, 0.0051582377118054, 0.0055733831788487, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694, 0.0050518460646148, 0.0050518460646148, 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0050518460646148, 0.0057169059499771, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0057169059499771, 0.0055187714672736, 0.0051582377118054, 0.0041067770281694, 0.0051582377118054, 0.005608704082588, 0.005608704082588, 0.0055733831788487, 0.0055733831788487, 0.0041067770281694, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694, 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0057169059499771, 0.0050518460646148, 0.0050518460646148, 0.0050518460646148, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.005608704082588, 0.0051582377118054, 0.0041067770281694, 0.005608704082588, 0.0055187714672736, 0.0041067770281694, 0.0055187714672736, 0.0051582377118054, 0.0057169059499771, 0.0055733831788487, 0.0055733831788487, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694, 0.0050518460646148, 0.0057169059499771, 0.0057169059499771, 0.0050518460646148, 0.0050518460646148, 0.0017823404472446, 0.0050518460646148, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0057169059499771, 0.0051582377118054, 0.0041067770281694, 0.0051582377118054, 0.0041067770281694, 0.0055187714672736, 0.005608704082588, 0.0055733831788487, 0.0055733831788487, 0.005608704082588, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694]) ) np.testing.assert_allclose(gen.lebedev(degree=194), lebedev_grid_194)
def test_sampled_wave_rigid_cardioid(): array_configuration = io.ArrayConfiguration( array_radius=0.09, array_type="rigid", transducer_type="cardioid", scatter_radius=0.03, ) # fmt: off results_rigid_cardioid = np.array([[ -0.6028519679960 + 0.7669321885739j, -0.6028519679960 + 0.7669321885739j, -0.6309703729264 - 0.118525523167j, 0.5051010853392 - 0.9241602374611j, -1.9734139441889 + 1.3279590179038j ], [ -1.4798350447341 + 1.4311552084547j, -1.4798350447341 + 1.4311552084547j, -2.4363413945739 - 0.9481818498745j, 0.2425901521620 - 0.7852102296214j, 0.4098504468155 + 1.3042452522818j ], [ 0.6945400983242 + 1.2385466804706j, 0.6945400983242 + 1.2385466804706j, -0.2614760811439 - 1.9436454222383j, -0.2776623725191 + 1.9303607155363j, 0.7109138718829 - 1.1523060702016j ], [ 0.6345515953532 + 1.2573361420525j, 0.6345515953532 + 1.2573361420525j, 0.4413875163426 - 0.9350494243153j, 2.0392805712585 - 0.5951475909762j, -0.0200635317571 + 1.5561501103273j ]]) # fmt: on np.testing.assert_allclose( gen.sampled_wave( order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=0.1, wave_colatitude=2, ), results_rigid_cardioid, atol=1e-12, )
def test_sampled_wave_rigid_omni(): array_configuration = io.ArrayConfiguration( array_radius=0.02, array_type="rigid", transducer_type="omni", scatter_radius=0.02, ) # fmt: off results_rigid_omni = np.array([[ 0.9472960355177 + 1.239732059493j, 0.9472960355177 + 1.239732059493j, -0.7902248094539 + 0.4226175305586j, 0.8286396985424 - 0.9508074768159j, 1.7529564648366 + 0.0437757668065j ], [ 0.3549788246869 + 1.3371731078613j, 0.3549788246869 + 1.3371731078613j, -0.3947603076913 - 0.8852152143603j, 1.1641716344906 - 1.0195528191828j, 2.6296097316976 + 0.9851546185098j ], [ 0.0655088575950 + 2.1549809558741j, 0.0655088575950 + 2.1549809558741j, -0.4997132416047 + 1.5918051665416j, -0.9420263643131 - 0.9580586241078j, -0.4901197584785 - 2.4850108102247j ], [ -0.2830619780170 + 1.3565859759891j, -0.2830619780170 + 1.3565859759891j, -1.6824181809209 - 0.8893273205157j, -0.7414617411157 - 1.0455863226985j, 0.1632355365807 + 0.9376936227764j ]]) # fmt: on np.testing.assert_allclose( gen.sampled_wave( order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=-0.1, wave_colatitude=1, ), results_rigid_omni, atol=1e-12, )
def test_lebedev_grid_0_order_fallback(): # fmt: off lebedev_grid_1 = io.SphericalGrid( azimuth=np.array([ 0., 0., 0., 1.5707963267948966, 3.1415926535897931, 4.7123889803846897 ]), colatitude=np.array([ 0., 1.5707963267948966, 3.1415926535897931, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966 ]), radius=np.array([1., 1., 1., 1., 1., 1.]), weight=np.array([ 0.1666666666666667, 0.1666666666666667, 0.1666666666666667, 0.1666666666666667, 0.1666666666666667, 0.1666666666666667 ])) # fmt: on np.testing.assert_allclose(gen.lebedev(max_order=0), lebedev_grid_1)
def test_sampled_wave_open_cardioid(): array_configuration = io.ArrayConfiguration(array_radius=0.01, array_type="open", transducer_type="cardioid") # fmt: off results_open_cardioid = np.array( [[ 1.7724538509055e+00, 1.4967049769369e+00 + 4.9979728197650e-01j, 9.2685600388710e-01 + 5.3305766228400e-01j, 5.9485301572270e-01 + 6.8667687465800e-02j, 8.1088542184460e-01 - 4.6048110907780e-01j ], [ 7.2360125455830e-01, 3.8587923539310e-01 + 6.1212416373860e-01j, -3.1204034948190e-01 + 6.5286244731520e-01j, -7.1865788302760e-01 + 8.4195921629000e-02j, -4.5404623356140e-01 - 5.6290300056530e-01j ], [ -2.0990000000000e-10, -2.0990000000000e-10 - 2.1160000000000e-10j, -2.0990000000000e-10 - 4.2330000000000e-10j, -2.0990000000000e-10 - 6.3490000000000e-10j, -2.0950000000000e-10 - 8.4640000000000e-10j ], [ 7.2360125455830e-01, 3.8587923539310e-01 + 6.1212416373860e-01j, -3.1204034948190e-01 + 6.5286244731520e-01j, -7.1865788302760e-01 + 8.4195921629000e-02j, -4.5404623356140e-01 - 5.6290300056530e-01j ]]) # fmt: on np.testing.assert_allclose( gen.sampled_wave( order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=0, wave_colatitude=1.570796327, ), results_open_cardioid, atol=1e-12, )
def test_sampled_wave_open_omni(): array_configuration = io.ArrayConfiguration(array_radius=0.1, array_type="open", transducer_type="omni") # fmt: off results_open_omni = np.array( [[ 3.5449077018110, 1.4287027823479, 2.6599580310768, 2.8285359206193, 1.3306204041198 ], [ 0, -8.8558806782570e-01j, 1.4008429690376e+00j, -1.3302966027074e+00j, 7.0344988487660e-01j ], [ 0, -4.2327000000000e-09j, -8.4654000000000e-09j, -1.2698100000000e-08j, -1.6930900000000e-08j ], [ 0, -8.8558806782570e-01j, 1.4008429690376e+00j, -1.3302966027074e+00j, 7.0344988487660e-01j ]]) # fmt: on np.testing.assert_allclose( gen.sampled_wave( order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=0, wave_colatitude=1.570796327, ), results_open_omni, atol=1e-12, )
def test_lebedev_grid_NA_degree(): with pytest.raises(ValueError): gen.lebedev(degree=1)
sys.path.insert(0, '../') from sound_field_analysis import gen, process, plot pi = np.pi r = 0.1 # Array radius ac = 0 # Rigid Sphere FS = 48000 # Sampling Frequency NFFT = 128 # FFT-Bin AZ = 0 # Azimuth angle EL = pi / 2 # Elevation angle Nsft = 5 # Transform order Nrf = Nsft # Radial filter order Nviz = Nsft # Visualization order krIDX = [15, 23, 29, 39] # kr-bin for subfigures quadrature_grid, _ = gen.lebedev(110) fftData, kr = gen.sampledWave(r=r, gridData=quadrature_grid, ac=ac, FS=FS, NFFT=NFFT, AZ=AZ, EL=EL) # Spatial Fourier Transform Pnm = process.spatFT(Nsft, fftData, quadrature_grid) # Make radial filters dn, _ = gen.radFilter(Nrf, kr, ac)
def test_lebedev_grid_NA_degree(): with pytest.raises(ValueError): gen.lebedev(degree=1)
def test_lebedev_grid_194(): # fmt: off lebedev_grid_194 = io.SphericalGrid( azimuth=np.array( [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.1314224389344013, 0.1314224389344013, 0.1879869008650734, 0.1879869008650734, 0.2940860780003485, 0.2940860780003485, 0.3069605019034988, 0.3069605019034988, 0.3530595115392992, 0.4377579511459067, 0.4377579511459067, 0.5195449866495595, 0.5195449866495595, 0.5608291557018665, 0.5608291557018665, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 0.7853981633974483, 1.00996717109303, 1.00996717109303, 1.0512513401453372, 1.0512513401453372, 1.1330383756489899, 1.1330383756489899, 1.2177368152555974, 1.2638358248913979, 1.2638358248913979, 1.2767102487945481, 1.2767102487945481, 1.3828094259298231, 1.3828094259298231, 1.4393738878604954, 1.4393738878604954, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.5707963267948966, 1.702218765729298, 1.702218765729298, 1.75878322765997, 1.75878322765997, 1.864882404795245, 1.864882404795245, 1.8777568286983954, 1.8777568286983954, 1.9238558383341959, 2.0085542779408034, 2.0085542779408034, 2.0903413134444562, 2.0903413134444562, 2.1316254824967631, 2.1316254824967631, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.3561944901923448, 2.5807634978879266, 2.5807634978879266, 2.6220476669402339, 2.6220476669402339, 2.7038347024438867, 2.7038347024438867, 2.7885331420504942, 2.8346321516862942, 2.8346321516862942, 2.8475065755894446, 2.8475065755894446, 2.9536057527247199, 2.9536057527247199, 3.0101702146553921, 3.0101702146553921, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931, 3.2730150925241941, 3.2730150925241941, 3.3295795544548663, 3.3295795544548663, 3.4356787315901416, 3.4356787315901416, 3.448553155493292, 3.448553155493292, 3.494652165129092, 3.5793506047356995, 3.5793506047356995, 3.6611376402393523, 3.6611376402393523, 3.7024218092916596, 3.7024218092916596, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 3.9269908169872414, 4.1515598246828231, 4.1515598246828231, 4.1928439937351296, 4.1928439937351296, 4.2746310292387832, 4.2746310292387832, 4.3593294688453899, 4.4054284784811912, 4.4054284784811912, 4.4183029023843412, 4.4183029023843412, 4.524402079519616, 4.524402079519616, 4.5809665414502883, 4.5809665414502883, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.7123889803846897, 4.8438114193190911, 4.8438114193190911, 4.9003758812497633, 4.9003758812497633, 5.0064750583850381, 5.0064750583850381, 5.0193494822881881, 5.0193494822881881, 5.0654484919239886, 5.1501469315305961, 5.1501469315305961, 5.2319339670342488, 5.2319339670342488, 5.2732181360865562, 5.2732181360865562, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.497787143782138, 5.7223561514777197, 5.7223561514777197, 5.7636403205300271, 5.7636403205300271, 5.8454273560336798, 5.8454273560336798, 5.9301257956402873, 5.9762248052760878, 5.9762248052760878, 5.9890992291792378, 5.9890992291792378, 6.0951984063145126, 6.0951984063145126, 6.1517628682451848, 6.1517628682451848 ]), colatitude=np.array([ 0., 2.7885331420504942, 2.3561944901923448, 1.9238558383341957, 1.5707963267948966, 1.2177368152555974, 0.7853981633974483, 3.1415926535897931, 0.3530595115392992, 1.4404943707983893, 1.7010982827914038, 2.1236507622147109, 1.0179418913750822, 0.5807780340897879, 2.5608146195000052, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 2.3067540874479739, 0.8348385661418192, 2.0316281581750033, 1.1099644954147898, 1.7305162597466104, 1.4110763938431827, 1.5707963267948966, 1.2511856323329762, 0.9553166181245093, 0.4214197634066907, 2.4614662316678615, 2.9567887484826221, 0.6801264219219316, 1.8904070212568169, 0.1848039051071708, 2.7201728901831022, 2.1862760354652839, 1.7305162597466104, 1.4110763938431827, 2.0316281581750033, 1.1099644954147898, 2.3067540874479739, 0.8348385661418192, 1.5707963267948966, 1.8642359895206648, 1.2773566640691283, 2.5608146195000052, 0.5807780340897879, 1.0179418913750822, 2.1236507622147109, 1.7010982827914038, 1.4404943707983893, 1.9238558383341957, 1.2177368152555974, 1.5707963267948966, 0.3530595115392992, 2.3561944901923448, 2.7885331420504942, 0.7853981633974483, 1.7010982827914038, 1.4404943707983893, 2.1236507622147109, 1.0179418913750822, 2.5608146195000052, 0.5807780340897879, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 2.3067540874479739, 0.8348385661418192, 1.1099644954147898, 2.0316281581750033, 1.7305162597466104, 1.4110763938431827, 1.5707963267948966, 0.6801264219219316, 2.7201728901831022, 2.9567887484826221, 0.4214197634066907, 1.8904070212568169, 1.2511856323329762, 0.9553166181245093, 2.1862760354652839, 0.1848039051071708, 2.4614662316678615, 1.7305162597466104, 1.4110763938431827, 2.0316281581750033, 1.1099644954147898, 0.8348385661418192, 2.3067540874479739, 1.5707963267948966, 1.8642359895206648, 1.2773566640691283, 0.5807780340897879, 2.5608146195000052, 2.1236507622147109, 1.0179418913750822, 1.4404943707983893, 1.7010982827914038, 1.5707963267948966, 1.2177368152555974, 0.7853981633974483, 2.3561944901923448, 1.9238558383341957, 0.3530595115392992, 2.7885331420504942, 1.7010982827914038, 1.4404943707983893, 1.0179418913750822, 2.1236507622147109, 2.5608146195000052, 0.5807780340897879, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 2.3067540874479739, 0.8348385661418192, 2.0316281581750033, 1.1099644954147898, 1.7305162597466104, 1.4110763938431827, 1.8904070212568169, 0.4214197634066907, 2.9567887484826221, 1.2511856323329762, 0.6801264219219316, 0.1848039051071708, 2.4614662316678615, 2.7201728901831022, 1.5707963267948966, 2.1862760354652839, 0.9553166181245093, 1.7305162597466104, 1.4110763938431827, 2.0316281581750033, 1.1099644954147898, 2.3067540874479739, 0.8348385661418192, 1.5707963267948966, 1.2773566640691283, 1.8642359895206648, 2.5608146195000052, 0.5807780340897879, 1.0179418913750822, 2.1236507622147109, 1.7010982827914038, 1.4404943707983893, 1.9238558383341957, 2.3561944901923448, 0.7853981633974483, 1.2177368152555974, 0.3530595115392992, 1.5707963267948966, 2.7885331420504942, 1.4404943707983893, 1.7010982827914038, 2.1236507622147109, 1.0179418913750822, 2.5608146195000052, 0.5807780340897879, 1.2773566640691283, 1.8642359895206648, 1.5707963267948966, 0.8348385661418192, 2.3067540874479739, 2.0316281581750033, 1.1099644954147898, 1.4110763938431827, 1.7305162597466104, 0.6801264219219316, 1.5707963267948966, 2.7201728901831022, 2.9567887484826221, 0.4214197634066907, 0.1848039051071708, 2.4614662316678615, 1.8904070212568169, 2.1862760354652839, 0.9553166181245093, 1.2511856323329762, 1.4110763938431827, 1.7305162597466104, 2.0316281581750033, 1.1099644954147898, 2.3067540874479739, 0.8348385661418192, 1.5707963267948966, 1.2773566640691283, 1.8642359895206648, 2.5608146195000052, 0.5807780340897879, 2.1236507622147109, 1.0179418913750822, 1.7010982827914038, 1.4404943707983893 ]), radius=np.ones(194), weight=np.array([ 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0050518460646148, 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0017823404472446, 0.0050518460646148, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0057169059499771, 0.005608704082588, 0.0055733831788487, 0.0051582377118054, 0.0055187714672736, 0.0041067770281694, 0.0055187714672736, 0.005608704082588, 0.0041067770281694, 0.0051582377118054, 0.0055733831788487, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694, 0.0050518460646148, 0.0050518460646148, 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0050518460646148, 0.0057169059499771, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0057169059499771, 0.0055187714672736, 0.0051582377118054, 0.0041067770281694, 0.0051582377118054, 0.005608704082588, 0.005608704082588, 0.0055733831788487, 0.0055733831788487, 0.0041067770281694, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694, 0.0017823404472446, 0.0050518460646148, 0.0057169059499771, 0.0057169059499771, 0.0050518460646148, 0.0050518460646148, 0.0050518460646148, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.005608704082588, 0.0051582377118054, 0.0041067770281694, 0.005608704082588, 0.0055187714672736, 0.0041067770281694, 0.0055187714672736, 0.0051582377118054, 0.0057169059499771, 0.0055733831788487, 0.0055733831788487, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694, 0.0050518460646148, 0.0057169059499771, 0.0057169059499771, 0.0050518460646148, 0.0050518460646148, 0.0017823404472446, 0.0050518460646148, 0.0041067770281694, 0.0041067770281694, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0051582377118054, 0.0051582377118054, 0.0050518460646148, 0.005608704082588, 0.005608704082588, 0.0055187714672736, 0.0055187714672736, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0057169059499771, 0.0051582377118054, 0.0041067770281694, 0.0051582377118054, 0.0041067770281694, 0.0055187714672736, 0.005608704082588, 0.0055733831788487, 0.0055733831788487, 0.005608704082588, 0.0055302489162331, 0.0055302489162331, 0.0055187714672736, 0.0055187714672736, 0.005608704082588, 0.005608704082588, 0.0050518460646148, 0.0051582377118054, 0.0051582377118054, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0055302489162331, 0.0041067770281694, 0.0041067770281694 ])) # fmt: on np.testing.assert_allclose(gen.lebedev(degree=194), lebedev_grid_194)
def test_sampled_wave_open_cardioid(): array_configuration = io.ArrayConfiguration(array_radius=0.01, array_type='open', transducer_type='cardioid') results_open_cardioid = np.array([[1.7724538509055e+00, 1.4967049769369e+00 + 4.9979728197650e-01j, 9.2685600388710e-01 + 5.3305766228400e-01j, 5.9485301572270e-01 + 6.8667687465800e-02j, 8.1088542184460e-01 - 4.6048110907780e-01j], [7.2360125455830e-01, 3.8587923539310e-01 + 6.1212416373860e-01j, -3.1204034948190e-01 + 6.5286244731520e-01j, -7.1865788302760e-01 + 8.4195921629000e-02j, -4.5404623356140e-01 - 5.6290300056530e-01j], [-2.0990000000000e-10, -2.0990000000000e-10 - 2.1160000000000e-10j, -2.0990000000000e-10 - 4.2330000000000e-10j, -2.0990000000000e-10 - 6.3490000000000e-10j, -2.0950000000000e-10 - 8.4640000000000e-10j], [7.2360125455830e-01, 3.8587923539310e-01 + 6.1212416373860e-01j, -3.1204034948190e-01 + 6.5286244731520e-01j, -7.1865788302760e-01 + 8.4195921629000e-02j, -4.5404623356140e-01 - 5.6290300056530e-01j]]) np.testing.assert_allclose(gen.sampled_wave(order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=0, wave_colatitude=1.570796327), results_open_cardioid, atol=1e-12)
# # Then, a virtual microphone array that is to be simulated is configured by using three parameters: # - radius of the array # - sphere configuration (open, rigid or dual) # - transducers type (omni or cardioid) # # For the spatial sampling, a quadrature grid is be generated using the gen.lebedev() module, which returnes a object holding the positions and weights of a specific Lebedev configuration. # # Lastly, the wavetype ('plane') and the direction of the wave are defined. NFFT denotes the number of the FFT bins and fs the sampling frequency used for the simulation. # In[2]: order = 10 array_configuration = [0.5, 'rigid', 'cardioid'] quadrature_grid = gen.lebedev(max_order=order) wavetype = 'plane' azimuth = utils.deg2rad(0) colatitude = utils.deg2rad(90) NFFT = 128 fs = 48000 # ## Simulated array data and radial filters # `gen.ideal_wave()` returns the spherical fourier coefficiens of a ideal plane wave as captured by an ideal array of the provided configuration. # `gen.sampled_wave()` returns the spherical fourier coefficiens as captured by an simulated real array. # # `gen.radial_filter()` returns the radial filters for the current array configuration, which is identical for both cases.
def test_sampled_wave_rigid_cardioid(): array_configuration = io.ArrayConfiguration(array_radius=0.09, array_type='rigid', transducer_type='cardioid', scatter_radius=0.03) results_rigid_cardioid = np.array([[-0.6028519679960 + 0.7669321885739j, -0.6028519679960 + 0.7669321885739j, -0.6309703729264 - 0.118525523167j, 0.5051010853392 - 0.9241602374611j, -1.9734139441889 + 1.3279590179038j], [-1.4798350447341 + 1.4311552084547j, -1.4798350447341 + 1.4311552084547j, -2.4363413945739 - 0.9481818498745j, 0.2425901521620 - 0.7852102296214j, 0.4098504468155 + 1.3042452522818j], [0.6945400983242 + 1.2385466804706j, 0.6945400983242 + 1.2385466804706j, -0.2614760811439 - 1.9436454222383j, -0.2776623725191 + 1.9303607155363j, 0.7109138718829 - 1.1523060702016j], [0.6345515953532 + 1.2573361420525j, 0.6345515953532 + 1.2573361420525j, 0.4413875163426 - 0.9350494243153j, 2.0392805712585 - 0.5951475909762j, -0.0200635317571 + 1.5561501103273j]]) np.testing.assert_allclose(gen.sampled_wave(order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=0.1, wave_colatitude=2), results_rigid_cardioid, atol=1e-12)
def test_sampled_wave_rigid_omni(): array_configuration = io.ArrayConfiguration(array_radius=0.02, array_type='rigid', transducer_type='omni', scatter_radius=0.02) results_rigid_omni = np.array([[0.9472960355177 + 1.239732059493j, 0.9472960355177 + 1.239732059493j, -0.7902248094539 + 0.4226175305586j, 0.8286396985424 - 0.9508074768159j, 1.7529564648366 + 0.0437757668065j], [0.3549788246869 + 1.3371731078613j, 0.3549788246869 + 1.3371731078613j, -0.3947603076913 - 0.8852152143603j, 1.1641716344906 - 1.0195528191828j, 2.6296097316976 + 0.9851546185098j], [0.0655088575950 + 2.1549809558741j, 0.0655088575950 + 2.1549809558741j, -0.4997132416047 + 1.5918051665416j, -0.9420263643131 - 0.9580586241078j, -0.4901197584785 - 2.4850108102247j], [-0.2830619780170 + 1.3565859759891j, -0.2830619780170 + 1.3565859759891j, -1.6824181809209 - 0.8893273205157j, -0.7414617411157 - 1.0455863226985j, 0.1632355365807 + 0.9376936227764j]]) np.testing.assert_allclose(gen.sampled_wave(order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=-0.1, wave_colatitude=1), results_rigid_omni, atol=1e-12)
def test_lebedev_grid_NA_order(): with pytest.raises(ValueError): gen.lebedev(max_order=12)
def test_lebedev_grid_NA(): with pytest.raises(ValueError): gen.lebedev()
def test_lebedev_grid_NA_order(): with pytest.raises(ValueError): gen.lebedev(max_order=12)
def test_lebedev_grid_NA(): with pytest.raises(ValueError): gen.lebedev()
def test_sampled_wave_open_omni(): array_configuration = io.ArrayConfiguration(array_radius=0.1, array_type='open', transducer_type='omni') results_open_omni = np.array([[3.5449077018110, 1.4287027823479, 2.6599580310768, 2.8285359206193, 1.3306204041198], [0, -8.8558806782570e-01j, 1.4008429690376e+00j, -1.3302966027074e+00j, 7.0344988487660e-01j], [0, -4.2327000000000e-09j, -8.4654000000000e-09j, -1.2698100000000e-08j, -1.6930900000000e-08j], [0, -8.8558806782570e-01j, 1.4008429690376e+00j, -1.3302966027074e+00j, 7.0344988487660e-01j]]) np.testing.assert_allclose(gen.sampled_wave(order=1, fs=44100, NFFT=8, array_configuration=array_configuration, gridData=gen.lebedev(1), wave_azimuth=0, wave_colatitude=1.570796327), results_open_omni, atol=1e-12)