123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- import numpy as np
- from scipy.signal import chirp
- from typing import Union, List
- class JammingSignalAlgo:
- """
- 雷达干扰信号生成算法库
- 支持噪声干扰、欺骗干扰、智能干扰等多种模式
- """
- @staticmethod
- def generate_noise_jam(
- bandwidth: float,
- duration: float,
- sample_rate: float,
- jamming_type: str = "gaussian"
- ) -> np.ndarray:
- """
- 生成噪声干扰信号
- :param bandwidth: 干扰带宽(Hz)
- :param duration: 干扰持续时间(s)
- :param sample_rate: 采样率(Hz)
- :param jamming_type: 噪声类型(gaussian/blanket/spot)
- :return: 复数干扰信号
- """
- nsamples = int(duration * sample_rate)
- if jamming_type == "gaussian":
- # 高斯白噪声(全频段均匀干扰)
- return np.random.normal(0, 1, nsamples) + 1j * np.random.normal(0, 1, nsamples)
- elif jamming_type == "blanket":
- # 毯式噪声(带限增强)
- noise = np.random.normal(0, 1, nsamples)
- fft_sig = np.fft.fft(noise)
- freqs = np.fft.fftfreq(nsamples, 1 / sample_rate)
- mask = np.abs(freqs) <= bandwidth / 2
- return np.fft.ifft(fft_sig * mask).astype(np.complex64)
- elif jamming_type == "spot":
- # 点频噪声(针对特定频点)
- t = np.arange(nsamples) / sample_rate
- carrier = np.exp(1j * 2 * np.pi * bandwidth / 2 * t)
- return (np.random.normal(0, 1, nsamples) * carrier).astype(np.complex64)
- else:
- raise ValueError(f"未知噪声类型: {jamming_type}")
- @staticmethod
- def generate_deceptive_jam(
- radar_params: dict,
- false_targets: List[dict],
- sample_rate: float
- ) -> np.ndarray:
- """
- 生成欺骗式干扰信号(假目标)
- :param radar_params: 雷达参数 {
- "pulse_width": 脉宽(s),
- "bandwidth": 带宽(Hz),
- "prf": 脉冲重复频率(Hz)
- }
- :param false_targets: 假目标参数列表 [{
- "delay": 时延(s),
- "doppler": 多普勒频移(Hz),
- "amplitude": 幅度系数(0-1)
- }]
- :param sample_rate: 采样率(Hz)
- :return: 复数干扰信号
- """
- pw = radar_params["pulse_width"]
- bw = radar_params["bandwidth"]
- nsamples = int(pw * sample_rate)
- # 生成基础雷达信号(LFM)
- t = np.linspace(0, pw, nsamples)
- chirp_signal = chirp(t, f0=0, t1=pw, f1=bw, phi=90, method='linear')
- chirp_signal = chirp_signal.astype(np.complex64)
- # 合成假目标
- jam_signal = np.zeros_like(chirp_signal)
- for target in false_targets:
- delay_samples = int(target["delay"] * sample_rate)
- doppler_phase = 2 * np.pi * target["doppler"] * t
- shifted_sig = np.roll(chirp_signal, delay_samples) * \
- np.exp(1j * doppler_phase) * \
- target["amplitude"]
- jam_signal += shifted_sig[:len(chirp_signal)]
- return jam_signal
- @staticmethod
- def generate_drgm_jam(
- radar_signal: np.ndarray,
- memory_depth: int = 5,
- modulation: str = "amplitude"
- ) -> np.ndarray:
- """
- 数字射频存储器(DRGM)干扰
- :param radar_signal: 截获的雷达信号
- :param memory_depth: 存储深度(复制次数)
- :param modulation: 调制方式(amplitude/phase/frequency)
- :return: 干扰信号
- """
- jam_signal = np.array([])
- for i in range(memory_depth):
- if modulation == "amplitude":
- mod_signal = radar_signal * (0.8 + 0.2 * np.random.rand())
- elif modulation == "phase":
- mod_signal = radar_signal * np.exp(1j * np.pi / 4 * i)
- elif modulation == "frequency":
- mod_signal = radar_signal * np.exp(1j * 2 * np.pi * 0.01 * i * np.arange(len(radar_signal)))
- else:
- mod_signal = radar_signal
- jam_signal = np.concatenate([jam_signal, mod_signal])
- return jam_signal
- @staticmethod
- def generate_smart_jam(
- radar_signal: np.ndarray,
- sample_rate: float,
- jamming_mode: str = "repeater"
- ) -> np.ndarray:
- """
- 智能干扰(认知电子战)
- :param radar_signal: 截获的雷达信号
- :param sample_rate: 采样率
- :param jamming_mode: 干扰模式(repeater/velocity_deception/range_deception)
- :return: 干扰信号
- """
- if jamming_mode == "repeater":
- # 转发式干扰(延迟转发)
- return np.roll(radar_signal, int(0.1 * sample_rate))
- elif jamming_mode == "velocity_deception":
- # 速度欺骗(多普勒调制)
- t = np.arange(len(radar_signal)) / sample_rate
- return radar_signal * np.exp(1j * 2 * np.pi * 1e4 * t)
- elif jamming_mode == "range_deception":
- # 距离欺骗(时域复制)
- return np.concatenate([
- radar_signal[:len(radar_signal) // 2],
- radar_signal[:len(radar_signal) // 2]
- ])
- else:
- raise ValueError(f"未知智能干扰模式: {jamming_mode}")
- # ==================== 使用示例 ====================
- if __name__ == "__main__":
- # 示例1:生成噪声干扰
- noise_jam = JammingSignalAlgo.generate_noise_jam(
- bandwidth=10e6,
- duration=0.1,
- sample_rate=100e6,
- jamming_type="blanket"
- )
- print(f"噪声干扰信号长度:{len(noise_jam)} samples")
- # 示例2:生成欺骗干扰
- false_targets = [
- {"delay": 2e-6, "doppler": 1e4, "amplitude": 0.7},
- {"delay": 5e-6, "doppler": -5e3, "amplitude": 0.3}
- ]
- deceptive_jam = JammingSignalAlgo.generate_deceptive_jam(
- radar_params={"pulse_width": 50e-6, "bandwidth": 100e6, "prf": 1e3},
- false_targets=false_targets,
- sample_rate=200e6
- )
- print(f"欺骗干扰信号峰值幅度:{np.max(np.abs(deceptive_jam)):.2f}")
- # 示例3:DRGM干扰
- radar_signal = np.exp(1j * 2 * np.pi * 1e6 * np.arange(1000) / 100e6)
- drgm_jam = JammingSignalAlgo.generate_drgm_jam(
- radar_signal,
- memory_depth=3,
- modulation="phase"
- )
- print(f"DRGM干扰信号维度:{drgm_jam.shape}")
- # 算法 处理增益 时延 适用场景
- # 自适应滤波 15-25 dB O(N) 对抗噪声干扰
- # PCA降噪 10-20 dB O(n³) 多通道系统
- # CFAR检测 - O(N) 欺骗干扰抑制
- # 时频滤波 20-40 dB O(NlogN)点频干扰
- # MTI滤波 30-50 dB O(N) 动目标检测
- # 欺骗检测 - O(N²) DRFM干扰
|