123456789101112131415161718192021222324252627282930313233 |
- import numpy as np
- from scipy import signal, fft, linalg
- from typing import Tuple, List
- class AntiJammingSignalAlgo:
- @staticmethod
- def time_frequency_filter(rx_signal, sample_rate):
- """时频域联合滤波算法"""
- # 实现频域滤波与时域平滑的组合处理
- spectrum = np.fft.fft(signal)
- filtered_spectrum = spectrum * np.hamming(len(spectrum))
- return np.fft.ifft(filtered_spectrum).real
- @staticmethod
- def adaptive_filter(rx_signal, reference_signal):
- """自适应滤波算法"""
- # 实现基于LMS的自适应滤波
- lms_step = 0.01
- weights = np.zeros(10)
- for i in range(len(rx_signal)-10):
- x = rx_signal[i:i+10]
- error = reference_signal[i] - np.dot(weights, x)
- weights += lms_step * error * x
- return np.convolve(weights, rx_signal, mode='valid')
- @staticmethod
- def polarization_filter(signal, polarization_params):
- """极化滤波算法"""
- # 实现极化域滤波处理
- covariance = np.cov(signal.reshape(2, -1))
- eig_vals, eig_vecs = np.linalg.eig(covariance)
- return eig_vecs[:, np.argmax(eig_vals)] @ signal.reshape(2, -1)
|