def beamformer(fileName,figNum=1): param=param_read(fileName) navg=param['Navg'] ts=TS.Sim_ts(param) kw=KW.Kw(param) kw.zero() dtaIn=ts.instance() gramOut=kw.instance() for i in range(navg): ts.zero() ts.nb_sim() ts.noise_sim() kw.kw(dtaIn) for i in range(vsip.getrowlength(gramOut)): v=vsip.colview(gramOut,i) vsip.freqswap(v) vsip.destroy(v) max = vsip.maxval(gramOut,None) avg = vsip.meanval(gramOut) vsip.clip(gramOut,0.0,max,avg/100000.0,max,gramOut) vsip.log10(gramOut,gramOut) min = vsip.minval(gramOut,None) vsip.add(-min,gramOut,gramOut) max=vsip.maxval(gramOut,None) vsip.mul(1.0/max,gramOut,gramOut) fig = plt.figure(figNum,figsize=(10,4)) ax = fig.add_axes([0.10,0.10,0.85,0.80]) ax.set_yticklabels(['0','0','30','60','90','120','150','180']) ax.yaxis.set_ticks_position('right') im=mToA(gramOut) plt.imshow(im) plt.title('K-Omega Beamformer Output') plt.xlabel('Frequency') plt.ylabel(r'$\frac{cos(\theta)}{\lambda}$',fontsize=16,rotation='horizontal') plt.colorbar()
def noise_sim(self): from numpy import pi, cos d_t=self.d_t * self.Fs #sensor-to-sensor travel time at end-fire in samples o_0 = d_t * self.Nsens + 1 # array travel time at end-fire in samples a_stp = pi/self.Nsim_noise # angle step bl_attr = vsip.getattrib(self.bl_noise) for j in range(self.Nsim_noise): a_crct = cos(float(j) * a_stp) vsip.randn(self.rand,self.noise) vsip.firfilt(self.fir,self.noise,self.bl_noise) vsip.mul(12.0/float(self.Nsim_noise),self.bl_noise,self.bl_noise) vsip.putlength(self.bl_noise,self.Nts); for i in range(self.Nsens): vsip.putoffset(self.bl_noise,int(o_0 + i * d_t * a_crct)) VU_rowview(self.v_data,self.m_data,i) vsip.add(self.bl_noise,self.v_data,self.v_data) vsip.putattrib(self.bl_noise,bl_attr); vsip.add(-vsip.meanval(self.m_data),self.m_data,self.m_data);