jamming_signal_algo.py 1.8 KB

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