jamming_singal_algo.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import numpy as np
  2. from scipy.signal import chirp
  3. from typing import Union, List
  4. class JammingSignalAlgo:
  5. """
  6. 雷达干扰信号生成算法库
  7. 支持噪声干扰、欺骗干扰、智能干扰等多种模式
  8. """
  9. @staticmethod
  10. def generate_noise_jam(
  11. bandwidth: float,
  12. duration: float,
  13. sample_rate: float,
  14. jamming_type: str = "gaussian"
  15. ) -> np.ndarray:
  16. """
  17. 生成噪声干扰信号
  18. :param bandwidth: 干扰带宽(Hz)
  19. :param duration: 干扰持续时间(s)
  20. :param sample_rate: 采样率(Hz)
  21. :param jamming_type: 噪声类型(gaussian/blanket/spot)
  22. :return: 复数干扰信号
  23. """
  24. nsamples = int(duration * sample_rate)
  25. if jamming_type == "gaussian":
  26. # 高斯白噪声(全频段均匀干扰)
  27. return np.random.normal(0, 1, nsamples) + 1j * np.random.normal(0, 1, nsamples)
  28. elif jamming_type == "blanket":
  29. # 毯式噪声(带限增强)
  30. noise = np.random.normal(0, 1, nsamples)
  31. fft_sig = np.fft.fft(noise)
  32. freqs = np.fft.fftfreq(nsamples, 1 / sample_rate)
  33. mask = np.abs(freqs) <= bandwidth / 2
  34. return np.fft.ifft(fft_sig * mask).astype(np.complex64)
  35. elif jamming_type == "spot":
  36. # 点频噪声(针对特定频点)
  37. t = np.arange(nsamples) / sample_rate
  38. carrier = np.exp(1j * 2 * np.pi * bandwidth / 2 * t)
  39. return (np.random.normal(0, 1, nsamples) * carrier).astype(np.complex64)
  40. else:
  41. raise ValueError(f"未知噪声类型: {jamming_type}")
  42. @staticmethod
  43. def generate_deceptive_jam(
  44. radar_params: dict,
  45. false_targets: List[dict],
  46. sample_rate: float
  47. ) -> np.ndarray:
  48. """
  49. 生成欺骗式干扰信号(假目标)
  50. :param radar_params: 雷达参数 {
  51. "pulse_width": 脉宽(s),
  52. "bandwidth": 带宽(Hz),
  53. "prf": 脉冲重复频率(Hz)
  54. }
  55. :param false_targets: 假目标参数列表 [{
  56. "delay": 时延(s),
  57. "doppler": 多普勒频移(Hz),
  58. "amplitude": 幅度系数(0-1)
  59. }]
  60. :param sample_rate: 采样率(Hz)
  61. :return: 复数干扰信号
  62. """
  63. pw = radar_params["pulse_width"]
  64. bw = radar_params["bandwidth"]
  65. nsamples = int(pw * sample_rate)
  66. # 生成基础雷达信号(LFM)
  67. t = np.linspace(0, pw, nsamples)
  68. chirp_signal = chirp(t, f0=0, t1=pw, f1=bw, phi=90, method='linear')
  69. chirp_signal = chirp_signal.astype(np.complex64)
  70. # 合成假目标
  71. jam_signal = np.zeros_like(chirp_signal)
  72. for target in false_targets:
  73. delay_samples = int(target["delay"] * sample_rate)
  74. doppler_phase = 2 * np.pi * target["doppler"] * t
  75. shifted_sig = np.roll(chirp_signal, delay_samples) * \
  76. np.exp(1j * doppler_phase) * \
  77. target["amplitude"]
  78. jam_signal += shifted_sig[:len(chirp_signal)]
  79. return jam_signal
  80. @staticmethod
  81. def generate_drgm_jam(
  82. radar_signal: np.ndarray,
  83. memory_depth: int = 5,
  84. modulation: str = "amplitude"
  85. ) -> np.ndarray:
  86. """
  87. 数字射频存储器(DRGM)干扰
  88. :param radar_signal: 截获的雷达信号
  89. :param memory_depth: 存储深度(复制次数)
  90. :param modulation: 调制方式(amplitude/phase/frequency)
  91. :return: 干扰信号
  92. """
  93. jam_signal = np.array([])
  94. for i in range(memory_depth):
  95. if modulation == "amplitude":
  96. mod_signal = radar_signal * (0.8 + 0.2 * np.random.rand())
  97. elif modulation == "phase":
  98. mod_signal = radar_signal * np.exp(1j * np.pi / 4 * i)
  99. elif modulation == "frequency":
  100. mod_signal = radar_signal * np.exp(1j * 2 * np.pi * 0.01 * i * np.arange(len(radar_signal)))
  101. else:
  102. mod_signal = radar_signal
  103. jam_signal = np.concatenate([jam_signal, mod_signal])
  104. return jam_signal
  105. @staticmethod
  106. def generate_smart_jam(
  107. radar_signal: np.ndarray,
  108. sample_rate: float,
  109. jamming_mode: str = "repeater"
  110. ) -> np.ndarray:
  111. """
  112. 智能干扰(认知电子战)
  113. :param radar_signal: 截获的雷达信号
  114. :param sample_rate: 采样率
  115. :param jamming_mode: 干扰模式(repeater/velocity_deception/range_deception)
  116. :return: 干扰信号
  117. """
  118. if jamming_mode == "repeater":
  119. # 转发式干扰(延迟转发)
  120. return np.roll(radar_signal, int(0.1 * sample_rate))
  121. elif jamming_mode == "velocity_deception":
  122. # 速度欺骗(多普勒调制)
  123. t = np.arange(len(radar_signal)) / sample_rate
  124. return radar_signal * np.exp(1j * 2 * np.pi * 1e4 * t)
  125. elif jamming_mode == "range_deception":
  126. # 距离欺骗(时域复制)
  127. return np.concatenate([
  128. radar_signal[:len(radar_signal) // 2],
  129. radar_signal[:len(radar_signal) // 2]
  130. ])
  131. else:
  132. raise ValueError(f"未知智能干扰模式: {jamming_mode}")
  133. # ==================== 使用示例 ====================
  134. if __name__ == "__main__":
  135. # 示例1:生成噪声干扰
  136. noise_jam = JammingSignalAlgo.generate_noise_jam(
  137. bandwidth=10e6,
  138. duration=0.1,
  139. sample_rate=100e6,
  140. jamming_type="blanket"
  141. )
  142. print(f"噪声干扰信号长度:{len(noise_jam)} samples")
  143. # 示例2:生成欺骗干扰
  144. false_targets = [
  145. {"delay": 2e-6, "doppler": 1e4, "amplitude": 0.7},
  146. {"delay": 5e-6, "doppler": -5e3, "amplitude": 0.3}
  147. ]
  148. deceptive_jam = JammingSignalAlgo.generate_deceptive_jam(
  149. radar_params={"pulse_width": 50e-6, "bandwidth": 100e6, "prf": 1e3},
  150. false_targets=false_targets,
  151. sample_rate=200e6
  152. )
  153. print(f"欺骗干扰信号峰值幅度:{np.max(np.abs(deceptive_jam)):.2f}")
  154. # 示例3:DRGM干扰
  155. radar_signal = np.exp(1j * 2 * np.pi * 1e6 * np.arange(1000) / 100e6)
  156. drgm_jam = JammingSignalAlgo.generate_drgm_jam(
  157. radar_signal,
  158. memory_depth=3,
  159. modulation="phase"
  160. )
  161. print(f"DRGM干扰信号维度:{drgm_jam.shape}")
  162. # 算法 处理增益 时延 适用场景
  163. # 自适应滤波 15-25 dB O(N) 对抗噪声干扰
  164. # PCA降噪 10-20 dB O(n³) 多通道系统
  165. # CFAR检测 - O(N) 欺骗干扰抑制
  166. # 时频滤波 20-40 dB O(NlogN)点频干扰
  167. # MTI滤波 30-50 dB O(N) 动目标检测
  168. # 欺骗检测 - O(N²) DRFM干扰