
https://github.com/rtlsdrblog/kerberossdr/blob/master/_signalProcessing/hydra_signal_processor.py
这部分是最重要的部分,它里面包含几个重要的算法,采样时间同步,相位同步,以及调用了空间谱估计算法。
# KerberosSDR Signal Processor
#
# Copyright (C) 2018-2019 Carl Laufer, Tamás Pető
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#
# -*
# - coding: utf-8 -*-
import sys
import os
import time
# Math support
import numpy as np
# Signal processing support
from scipy import fft,ifft
from scipy import signal
from scipy.signal import correlate #互相关函数
# Plot support
#import matplotlib.pyplot as plt
# GUI support
from PyQt4 import QtGui, QtCore
# Import the pyArgus module
#root_path = os.getcwd()
#pyargus_path = os.path.join(os.path.join(root_path, "pyArgus"), "pyArgus")
#sys.path.insert(0, pyargus_path)
#import directionEstimation_v1p15 as de
from pyargus import directionEstimation as de #测向算法
# Import APRiL module
#april_path = os.path.join(os.path.join(root_path, "_APRIL"), "APRIL")
#sys.path.insert(0, april_path)
#import channelPreparation as cp
#import clutterCancellation as cc
#import detector as det
from pyapril import channelPreparation as cp #这些都是被动雷达的
from pyapril import clutterCancellation as cc
from pyapril import detector as det
from pyapril.hitProcessor import CA_CFAR
class SignalProcessor(QtCore.QThread):
#初始化了几个信号
signal_spectrum_ready = QtCore.pyqtSignal() #频谱计算完成的信号
signal_sync_ready = QtCore.pyqtSignal() #采样延迟计算完成的信号
signal_DOA_ready = QtCore.pyqtSignal() #测向计算完成的信号
signal_overdrive = QtCore.pyqtSignal(int) #信号是否饱和的信号,但是没用到
signal_period = QtCore.pyqtSignal(float) #计算周期
signal_PR_ready = QtCore.pyqtSignal()
def __init__(self, parent=None, module_receiver=None):
"""
Description:
------------
Parameters:
-----------
Return values:
--------------
"""
super(SignalProcessor, self).__init__(parent)
self.module_receiver = module_receiver #传入接收机对象给新处理模块
self.en_spectrum = True #是否显示频谱
self.en_sync = True #这里对应的是界面上的显示同步曲线(enable sync display)
self.en_sample_offset_sync = False#这里对应的是界面上的执行同步按钮(sample sync)
self.en_record = False #是否保存数据
self.en_calib_iq = False #是否做相位差校准
self.en_calib_DOA_90 = False
self.en_DOA_estimation = False #是否要做测向
self.en_PR_processing = False
self.en_PR_autodet = False
# DOA processing options
self.en_DOA_Bartlett = False
self.en_DOA_Capon = False
self.en_DOA_MEM = False
self.en_DOA_MUSIC = False #这是选择使用哪个测向算法,一般用MUSIC
self.en_DOA_FB_avg = False #这是是否打开FB average
self.DOA_inter_elem_space = 0.5 #这是lamda
self.DOA_ant_alignment = "ULA" #这是阵型
# Passive Radar processing parameters #这都是被动雷达用的参数
self.ref_ch_id = 0
self.surv_ch_id = 1
self.en_td_filtering = False
self.td_filter_dimension = 1
self.max_Doppler = 500 # [Hz]
self.windowing_mode = 0
self.max_range = 128 # [range cell]
self.cfar_win_params = [10,10,4,4] # [Est. win length, Est. win width, Guard win length, Guard win width]
self.cfar_threshold = 13
self.RD_matrix = np.ones((10,10))
self.hit_matrix = np.ones((10,10))
self.RD_matrix_last = np.ones((10,10))
self.RD_matrix_last_2 = np.ones((10,10))
self.RD_matrix_last_3 = np.ones((10,10))
self.center_freq = 0 # TODO: Initialize this [Hz] #中心频率
self.fs = 1.024 * 10**6 # Decimated sampling frequncy - Update from GUI
#这是经过降采样的采样率
#self.sample_size = 2**15
self.channel_number = 4 #接收机通道数量
# Processing parameters
self.test = None
self.spectrum_sample_size = 2**14 #2**14 #用于频谱运算的采样点数量
self.DOA_sample_size = 2**15 # Connect to GUI value?? #用于测向运算的采样点数量
self.xcorr_sample_size = 2**18 #2**18 #用于互相关运算的采样点数量
self.spectrum = np.ones((self.channel_number+1,self.spectrum_sample_size), dtype=np.float32)
#这里存储的是频谱的数据,每个通道一行,所以行数是channel_number,
#但是第0行要存储横轴的频率值信息,所以还要+1
#列的数量就是频谱显示的采样点数量
self.xcorr = np.ones((self.channel_number-1,self.xcorr_sample_size*2), dtype=np.complex64)
#这里存储的是互相关数据,都是另3个通道与第1个通道互相关运算的结果
#这个结果只有3个,所以只有channel_number-1行,互相关是卷积,长度会补得比函数本身长
#所以是原函数的采样点数量*2 xcorr_sample_size*2
self.phasor_win = 2**10 # Phasor plot window#这个本来用来绘制相位差的但是实际没用
self.phasors = np.ones((self.channel_number-1, self.phasor_win), dtype=np.complex64)
self.run_processing = False #这是用来控制主循环的标志位
# Result vectors
self.delay_log= np.array([[0],[0],[0]])
#记录采样时间延迟的数组,另3个通道相对第1个通道的,每个结果放在一行里,所以有3行
#每一列是不同时间点求的延迟结果
self.phase_log= np.array([[0],[0],[0]])
#记录相位差的数组,类似采样时间延迟,也是另3个通道相对第一个通道的,有3行
#每一列是不同时间点求的相位差的结果
self.DOA_Bartlett_res = np.ones(181)
self.DOA_Capon_res = np.ones(181)
self.DOA_MEM_res = np.ones(181)
self.DOA_MUSIC_res = np.ones(181)
#这里存储的是MUSIC算法计算出的功率谱密度函数
self.DOA_theta = np.arange(0,181,1)
#这里存储的是DOA测出的角度
# Auto resync params #自动定期同步用的参数,实际没有实现
self.lastTime = 0
self.runningSync = 0
self.timed_sync = False
self.noise_checked = False
self.resync_time = -1
def run(self):
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
self.run_processing = True
while self.run_processing:
start_time = time.time() #记录进入循环的时间点
# Download samples

本文深入解析KerberosSDR项目中的信号处理模块,涵盖采样时间同步、相位同步及空间谱估计算法。重点介绍MUSIC算法在均匀圆阵(UCA)中的应用,包括阵列矩阵计算、协方差矩阵估计、噪声子空间确定及空间谱函数计算,最终实现信号到达角(DOA)的精确测量。
最低0.47元/天 解锁文章
3993





