jamming_signal_algo.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import numpy as np
  2. class JammingSignalAlgo:
  3. @staticmethod
  4. def frequency_modulation(bandwidth, duration, sample_rate, modulation_index=0.5):
  5. """噪声调频干扰算法"""
  6. t = np.linspace(0, duration, 100)
  7. baseband = np.random.normal(0, 1, 100)
  8. modulated = np.sin(2 * np.pi * bandwidth * t + modulation_index * np.cumsum(baseband))
  9. return modulated, -1.0, 1.0
  10. @staticmethod
  11. def repeater_jamming(bandwidth, duration, sample_rate, delay=0.1, attenuation=0.5):
  12. """转发式干扰算法"""
  13. t = np.linspace(0, duration, 100)
  14. original_signal = np.sin(2 * np.pi * bandwidth * t)
  15. return attenuation * np.roll(original_signal, int(delay * sample_rate)), -attenuation, attenuation
  16. @staticmethod
  17. def velocity_deception(bandwidth, duration, sample_rate, doppler_shift=1000):
  18. """速度欺骗干扰算法"""
  19. t = np.linspace(0, duration, 100)
  20. return np.sin(2 * np.pi * (bandwidth + doppler_shift) * t), -1.0, 1.0
  21. @staticmethod
  22. def range_deception(bandwidth, duration, sample_rate, fake_range=500):
  23. """距离欺骗干扰算法"""
  24. t = np.linspace(0, duration, 100)
  25. fake_delay = 2 * fake_range / 3e8 # 计算双程时延
  26. return np.sin(2 * np.pi * bandwidth * (t - fake_delay)), -1.0, 1.0
  27. @staticmethod
  28. def amplitude_modulation(bandwidth, duration, sample_rate, modulation_depth=0.8):
  29. """噪声调幅干扰算法"""
  30. t = np.linspace(0, duration, 100)
  31. carrier = np.cos(2 * np.pi * bandwidth * t)
  32. noise = np.random.uniform(-1, 1, 100)
  33. modulated = (1 + modulation_depth * noise) * carrier
  34. return modulated, -(1.0 + modulation_depth), 1.0 + modulation_depth