jamming_signal_algo_20250421114817.py 1.1 KB

123456789101112131415161718192021222324252627
  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))