#integrate SPL values from beamforming results using the shapes levels_circ = acoular.integrate(bf.result, rg, circle) levels_rect = acoular.integrate(bf.result, rg, rect) levels_poly = acoular.integrate(bf.result, rg, poly) #integrate SPL values from beamforming results using sector classes levels_circ_sector = acoular.integrate(bf.result, rg, circle_sector) levels_rekt_sector = acoular.integrate(bf.result, rg, rect_sector) levels_poly_sector = acoular.integrate(bf.result, rg, poly_sector) levels_multi_sector = acoular.integrate(bf.result, rg, multi_sector) #plot map and sectors figure() map = bf.synthetic(2000,1) mx = acoular.L_p(map.max()) imshow(acoular.L_p(map.T), origin='lower', vmin=mx-15,interpolation='nearest', extent=rg.extend(),cmap=cm.hot_r) colorbar() circle1 = plt.Circle((-0.3,0.1), 0.05, color='k', fill=False) plt.gcf().gca().add_artist(circle1) polygon = Polygon(poly.reshape(-1,2), color='k', fill=False) plt.gcf().gca().add_artist(polygon) rect = Rectangle((-0.5,-0.15),0.1,0.3,linewidth=1,edgecolor='k',facecolor='none') plt.gcf().gca().add_artist(rect) #plot from shapes figure() plot(fftfreqs,acoular.L_p(levels_circ)) plot(fftfreqs,acoular.L_p(levels_rect)) plot(fftfreqs,acoular.L_p(levels_poly))
#integrate SPL values from beamforming results using the shapes levels_circ = bf.integrate(circle) levels_rect = bf.integrate(rect) levels_poly = bf.integrate(poly) #integrate SPL values from beamforming results using sector classes levels_circ_sector = bf.integrate(circle_sector) levels_rect_sector = bf.integrate(rect_sector) levels_poly_sector = bf.integrate(poly_sector) levels_multi_sector = bf.integrate(multi_sector) #plot map and sectors figure() map = bf.synthetic(2000, 1) mx = acoular.L_p(map.max()) imshow(acoular.L_p(map.T), origin='lower', vmin=mx - 15, interpolation='nearest', extent=rg.extend(), cmap=cm.hot_r) colorbar() circle1 = plt.Circle((-0.3, 0.1), 0.05, color='k', fill=False) plt.gcf().gca().add_artist(circle1) polygon = Polygon(poly.reshape(-1, 2), color='k', fill=False) plt.gcf().gca().add_artist(polygon) rect = Rectangle((-0.5, -0.15), 0.1, 0.3, linewidth=1,
# plot result maps for different beamformers in time domain #=============================================================================== i2 = 1 # no of figure i1 = 1 #no of subplot for b in (cacht, cachts, cachct, cachcts): # first, plot time-dependent result (block-wise) figure(i2,(7,7)) i2 += 1 res = zeros(rg.size) # init accumulator for average i3 = 1 # no of subplot for r in b.result(1): #one single block subplot(4,4,i3) i3 += 1 res += r[0] # average accum. map = r[0].reshape(rg.shape) mx = acoular.L_p(map.max()) imshow(acoular.L_p(map.T), vmax=mx, vmin=mx-15, origin='lower', interpolation='nearest', extent=rg.extend()) title('%i' % ((i3-1)*1024)) res /= i3-1 # average tight_layout() # second, plot overall result (average over all blocks) figure(10) subplot(4,4,i1) i1 += 1 map = res.reshape(rg.shape) mx = acoular.L_p(map.max()) imshow(acoular.L_p(map.T), vmax=mx, vmin=mx-15, origin='lower', interpolation='nearest', extent=rg.extend()) colorbar()
#------------------------------------------------------------------------------ """ Loads the three sources test data set, analyzes them and generates a map of the three sources. """ from os import path import acoular from pylab import figure, plot, axis, imshow, colorbar, show micgeofile = path.join(path.split(acoular.__file__)[0], 'xml', 'array_64.xml') datafile = 'three_sources.h5' mg = acoular.MicGeom(from_file=micgeofile) ts = acoular.TimeSamples(name='three_sources.h5') ps = acoular.PowerSpectra(time_data=ts, block_size=128, window='Hanning') rg = acoular.RectGrid( x_min=-0.2, x_max=0.2, y_min=-0.2, y_max=0.2, z=0.3, \ increment=0.01 ) bb = acoular.BeamformerBase(freq_data=ps, grid=rg, mpos=mg) pm = bb.synthetic(8000, 3) Lm = acoular.L_p(pm) imshow( Lm.T, origin='lower', vmin=Lm.max()-10, extent=rg.extend(), \ interpolation='bicubic') colorbar() figure(2) plot(mg.mpos[0], mg.mpos[1], 'o') axis('equal') show()
sol2 = "sol_ust_ses_20_01.h5" sag2 = "sag_alt_ses_20_01.h5" micgeofile = path.join(path.split(ac.__file__)[0], 'xml', 'array_4_2.xml') m = ac.MicGeom(from_file=micgeofile) g = ac.RectGrid(x_min=-4, x_max=4, y_min=-2, y_max=2, z=0.3, increment=0.01) t1 = ac.TimeSamples(name=sag2) cal = ac.Calib(from_file='calibration.xml') es = ac.EigSpectra(time_data=t1, block_size=512, window="Hanning", overlap='50%', calib=cal) bb = ac.BeamformerBase(freq_data=es, grid=g, mpos=m, r_diag=False) Lm = ac.L_p(bb.synthetic(500, 0)) """ plt.figure() plt.imshow( Lm.T, origin='lower', vmin=Lm.max()-10, extent=g.extend(), interpolation='bicubic') """ img = plt.imshow(Lm.T, origin='lower', vmin=Lm.max() - 10, extent=g.extend(), interpolation='bicubic') plt.axis('off') #plt.savefig("test.png", bbox_inches='tight')
# ww = ac.WriteWAV(source = t) # ww.channels = [0,32] # ww.save ##################### Frequency beamforming fixed focus ###################### fi = ac.PowerSpectra(time_data=t, window='Hanning', overlap='50%', block_size=128, \ ind_low=1,ind_high=15) # CSM calculation g = ac.RectGrid(x_min=-2, x_max=+2, y_min=0, y_max=+4, z=5, increment=0.1) st = ac.SteeringVector(grid=g, mics=m) b = ac.BeamformerBase(freq_data=fi, steer=st) map1 = b.synthetic(f,3) mx = ac.L_p(map1.max()) plot.figure() plot.imshow(ac.L_p(np.transpose(map1)), vmax=mx, vmin=mx-5, interpolation='bilinear',\ extent=g.extend(), origin='lower') plot.colorbar() ##################### Time beamforming moving focus ########################## fi = ac.FiltFiltOctave(source=t, band=f, fraction='Third octave') g = ac.RectGrid(x_min=-2.0, x_max=+2.0, y_min=0.0, y_max=+4.0, z=0.0, \ increment=0.1)# grid point of origin is at trajectory (thus z=0) st = ac.SteeringVector(grid=g, mics=m) # beamforming with trajectory (rvec axis perpendicular to trajectory) bts = ac.BeamformerTimeSqTraj(source=fi, steer=st, trajectory=tr_beam, \ rvec = np.array((0,0,0))) avgts = ac.TimeAverage(source=bts, naverage=int(fs*tmax/2))