jamming_signal_algo_20250421173511.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import numpy as np
  2. class JammingSignalAlgo:
  3. @staticmethod
  4. def generate_noise_jam(bandwidth, duration, sample_rate):
  5. num_samples = int(duration * sample_rate)
  6. return np.random.normal(0, 1, num_samples)
  7. @staticmethod
  8. def generate_amplitude_noise_jam(bandwidth, duration, sample_rate):
  9. t = np.arange(0, duration, 1/sample_rate)
  10. carrier = np.sin(2 * np.pi * bandwidth * t)
  11. noise = 0.5 * np.random.normal(0, 1, len(t))
  12. return carrier * noise
  13. @staticmethod
  14. def generate_velocity_deceptive_jam(bandwidth, duration, sample_rate):
  15. t = np.arange(0, duration, 1/sample_rate)
  16. phase_shift = np.cumsum(np.random.uniform(-0.1, 0.1, len(t)))
  17. return np.sin(2 * np.pi * bandwidth * t + phase_shift)
  18. @staticmethod
  19. def generate_deceptive_jam(bandwidth, duration, sample_rate):
  20. t = np.arange(0, duration, 1/sample_rate)
  21. delay = np.random.uniform(0.1, 0.5) # 随机延迟0.1-0.5秒
  22. amplitude = np.random.uniform(0.5, 2.0) # 随机幅度调制
  23. return amplitude * np.sin(2 * np.pi * bandwidth * (t - delay))
  24. @staticmethod
  25. def frequency_modulation(bandwidth, duration, sample_rate, modulation_index=0.5):
  26. """噪声调频干扰算法"""
  27. t = np.arange(0, duration, 1/sample_rate)
  28. baseband = np.random.normal(0, 1, len(t))
  29. modulated = np.sin(2 * np.pi * bandwidth * t + modulation_index * np.cumsum(baseband))
  30. return modulated