#=============================================================================== # delay and sum beamformer in time domain # processing chain: beamforming, filtering, power, average #=============================================================================== bt = BeamformerTime(source=t1, grid=g, mpos=m, c=346.04) ft = FiltFiltOctave(source=bt, band=cfreq) pt = TimePower(source=ft) avgt = TimeAverage(source=pt, naverage=1024) cacht = TimeCache(source=avgt) # cache to prevent recalculation #=============================================================================== # delay and sum beamformer in time domain with autocorrelation removal # processing chain: zero-phase filtering, beamforming+power, average #=============================================================================== fi = FiltFiltOctave(source=t1, band=cfreq) bts = BeamformerTimeSq(source=fi, grid=g, mpos=m, r_diag=True, c=346.04) avgts = TimeAverage(source=bts, naverage=1024) cachts = TimeCache(source=avgts) # cache to prevent recalculation #=============================================================================== # plot result maps for different beamformers in time domain #=============================================================================== i2 = 2 # no of figure for b in (cacht, cachts): # first, plot time-dependent result (block-wise) figure(i2, (7, 7)) i2 += 1 res = zeros(g.size) # init accumulator for average i3 = 1 # no of subplot for r in b.result(1): #one single block subplot(4, 4, i3)
steer=st, method='LassoLars', n=2, cached=False) bbase = BeamformerBase(freq_data=f, steer=st, r_diag=True, cached=False) beig = BeamformerEig(freq_data=f, steer=st, r_diag=True, n=54, cached=False) #timebeamformer test bt = BeamformerTime(source=t1, steer=st) ft = FiltFiltOctave(source=bt, band=1000) pt = TimePower(source=ft) avgt = TimeAverage(source=pt, naverage=1024) res = next(avgt.result(1)) #squared fi = FiltFiltOctave(source=t1, band=4000) bts = BeamformerTimeSq(source=fi, steer=st, r_diag=True) avgts = TimeAverage(source=bts, naverage=1024) resq = next(avgts.result(1)) class acoular_beamformer_test(unittest.TestCase): #@unittest.skip('test time bf first') def test_beamformer_freq_results(self): #test all fbeamformers for 1000 and 8000 hertz for cfreq in cfreqs: for beam, bfname in zip( (bbase, bc, beig, bm, bl, bo, bs, bd, bcmf, bf, bdp, bgib), ('bb', 'bc', 'be', 'bm', 'bl', 'bo', 'bs', 'bd', 'bcmf', 'bf', 'bdp', 'bgib')): for i in range(len(beam.synthetic(cfreq, 1).flatten())):
h5f1 = WriteH5(name='ps', source=ps).save() #============================================================================== #load H5 File #============================================================================== #load from h5 File mt1 = MaskedTimeSamples(name='ps') #============================================================================== #fixed focus time domain beamforming point source #============================================================================== bt_ps = BeamformerTime(source=ps, grid=g, mpos=m, c=c0) bt_ps_h5 = BeamformerTime(source=mt1, grid=g, mpos=m, c=c0) btSq_ps = BeamformerTimeSq(source=ps, grid=g, mpos=m, r_diag=True, c=c0) btSq_ps_h5 = BeamformerTimeSq(source=mt1, grid=g, mpos=m, r_diag=True, c=c0) avgt_ps = TimeAverage(source=bt_ps, naverage=int(sfreq * tmax / 2)) avgt_psSq = TimeAverage(source=btSq_ps, naverage=int(sfreq * tmax / 2)) avgt_ps_h5 = TimeAverage(source=bt_ps_h5, naverage=int(sfreq * tmax / 2)) avgt_psSq_h5 = TimeAverage(source=btSq_ps_h5, naverage=int(sfreq * tmax / 2)) #============================================================================== #plot point source #============================================================================== figure(1) for res in avgt_ps.result(1): res_ps = res[0].reshape(g.shape) subplot(2, 2, 1)
ind_low=1,ind_high=30) # CSM calculation g = RectGrid(x_min=-3.0, x_max=+3.0, y_min=-3.0, y_max=+3.0, z=Z, increment=0.3) b = BeamformerBase(freq_data=f, grid=g, mpos=m, r_diag=True, c=c0) map1 = b.synthetic(freq, 3) #=============================================================================== # fixed focus time domain beamforming #=============================================================================== fi = FiltFiltOctave(source=t, band=freq, fraction='Third octave') bt = BeamformerTimeSq(source=fi, grid=g, mpos=m, r_diag=True, c=c0) avgt = TimeAverage(source=bt, naverage=int(sfreq * tmax / 16)) # 16 single images cacht = TimeCache(source=avgt) # cache to prevent recalculation map2 = zeros(g.shape) # accumulator for average # plot single frames figure(1, (8, 7)) i = 1 for res in cacht.result(1): res0 = res[0].reshape(g.shape) map2 += res0 # average i += 1 subplot(4, 4, i) mx = L_p(res0.max()) imshow(L_p(transpose(res0)), vmax=mx, vmin=mx-10, interpolation='nearest',\ extent=g.extend(), origin='lower')
g = RectGrid(x_min=-3.0, x_max=+3.0, y_min=-3.0, y_max=+3.0, z=Z, increment=0.3) #=============================================================================== # fixed focus time domain beamforming #=============================================================================== fi = FiltFiltOctave(source=t, band=freq, fraction='Third octave') bt = BeamformerTimeSq(source=fi, grid=g, mpos=m, r_diag=True, c=c0, weights='none') avgt = TimeAverage(source=bt, naverage=int(sfreq * tmax / 16)) # 16 single images cacht = TimeCache(source=avgt) # cache to prevent recalculation map2 = zeros(g.shape) # accumulator for average # plot single frames figure(1) i = 0 for res in avgt.result(1): res0 = res[0].reshape(g.shape) map2 += res0 # average i += 1 subplot(4, 4, i) mx = L_p(res0.max())