谱峰搜索传播算子(python)

使用谱峰搜索传播算子的方法进行DOA估计

关键在于构造矩阵Q

import numpy as np
import scipy.signal as ss
import scipy.linalg as LA
import matplotlib.pyplot as plt

def awgn(x, snr):
    spower = np.sum((np.abs(x) ** 2)) / x.size
    x = x + np.sqrt(spower / snr) * (np.random.randn(x.shape[0], x.shape[1]) + 1j * np.random.randn(x.shape[0], x.shape[1]))
    return x

derad = np.pi / 180
radeg = 180 / np.pi
d = np.arange(0,4,0.5)
theta = np.array([0,30,60]).reshape(1,-1)
n=500
snr = 10
iwave = theta.size

A = np.exp(-1j*2*np.pi*d.reshape(-1,1)@np.sin(theta*derad))
S = np.random.randn(iwave,n)
X = A@S
X = awgn(X,snr)
Rxx = X@(X.conj().T)/n

K = Rxx.shape[0]
G = Rxx[:,0:iwave]
H = Rxx[:,iwave:K]
P = LA.pinv((G.conj().T)@G)@(G.conj().T)@H

Im = -np.diag(np.ones(K-iwave))
Q = np.concatenate((P.conj().T,Im),axis=1)

Angles = np.linspace(-np.pi / 2, np.pi / 2, 360)
numAngles = Angles.size
SP = np.empty(numAngles, dtype=complex)

for i in range(numAngles):
    a = np.exp(-1j*2*np.pi*d.reshape(-1,1)*np.sin(Angles[i]))
    SP[i] = (1/(a.conj().T@Q.conj().T@Q@a))[0,0]

SP = np.abs(SP)
SPmax = np.max(SP)
SP = 10 * np.log10(SP / SPmax)
x = Angles * radeg


plt.plot(x, SP)
plt.show()

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值