CWsubspace.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:piradar 作者: scivision 项目源码 文件源码
def cwplot(fb_est,rx,t,fs:int,fn) -> None:
#%% time
    fg,axs = subplots(1,2,figsize=(12,6))
    ax = axs[0]
    ax.plot(t, rx.T.real)
    ax.set_xlabel('time [sec]')
    ax.set_ylabel('amplitude')
    ax.set_title('Noisy, jammed receive signal')
    #%% periodogram
    if DTPG >= (t[-1]-t[0]):
        dt = (t[-1]-t[0])/4
    else:
        dt = DTPG

    dtw = 2*dt #  seconds to window
    tstep = ceil(dt*fs)
    wind = ceil(dtw*fs);
    Nfft = zeropadfactor*wind

    f,Sraw = signal.welch(rx.ravel(), fs,
                          nperseg=wind,noverlap=tstep,nfft=Nfft,
                          return_onesided=False)

    if np.iscomplex(rx).any():
        f = np.fft.fftshift(f); Sraw = np.fft.fftshift(Sraw)

    ax=axs[1]
    ax.plot(f,Sraw,'r',label='raw signal')

    fc_est = f[Sraw.argmax()]

    #ax.set_yscale('log')
    ax.set_xlim([fc_est-200,fc_est+200])
    ax.set_xlabel('frequency [Hz]')
    ax.set_ylabel('amplitude')
    ax.legend()

    esttxt=''

    if fn is None: # simulation
        ax.axvline(ft+fb0,color='red',linestyle='--',label='true freq.')
        esttxt += f'true: {ft+fb0} Hz '

    for e in fb_est:
        ax.axvline(e,color='blue',linestyle='--',label='est. freq.')

    esttxt += ' est: ' + str(fb_est) +' Hz'

    ax.set_title(esttxt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号