东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 2549|回复: 0

[Python] 如何改变复信号的相位_仿真

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14418
QQ
发表于 2021-9-18 09:28:31 | 显示全部楼层 |阅读模式



如何改变复信号的相位_仿真




  1. # -*- coding: utf-8 -*-
  2. __author__ = u'东方耀 微信:dfy_88888'
  3. __date__ = '2021/9/17 上午11:41'
  4. __product__ = 'PyCharm'
  5. __filename__ = '00_重新理解一下复信号'


  6. from scipy.fftpack import fft, ifft, fftshift
  7. import numpy as np
  8. import random
  9. import matplotlib.pyplot as plt
  10. import matplotlib.ticker as mticker
  11. from matplotlib.font_manager import FontProperties

  12. font_fname = "/usr/share/fonts/wps-office/simfang.ttf"
  13. font = FontProperties(fname=font_fname)
  14. # plt.rcParams['font.sans-serif']=['simfang']#设置作图中文显示

  15. # 如何改变复信号的相位_仿真

  16. continue_time_per_freq = 1e-6
  17. fs = 400e6
  18. f = 10e6
  19. sample_num_per_freq = int(np.ceil(continue_time_per_freq * fs))
  20. print("每个子脉冲的采样点数(采样速率有关)=", sample_num_per_freq)
  21. print("一个周期的采样点数(采样速率有关)=", fs/f)
  22. print("一共多少个周期=", continue_time_per_freq * f)
  23. x_time = np.linspace(0, continue_time_per_freq, sample_num_per_freq, endpoint=True)

  24. Rx_signal = []
  25. Rx_signal_phase = []
  26. RCS = 1
  27. Rx_signal.extend(list(RCS * np.exp(1j * 2 * np.pi * f * x_time)))

  28. # phase_random_array = np.random.uniform(-np.pi, np.pi, 100)
  29. # phase_random = random.choice(phase_random_array)
  30. phase = - np.pi / 2
  31. # print("随机选择一个相位:", phase_random)
  32. # 我的:
  33. Rx_signal_phase.extend(list(RCS * np.exp(1j * (2 * np.pi * f * x_time + phase))))
  34. # 闫博:
  35. # Rx_signal_phase.extend(list(RCS * np.exp(1j * (2 * np.pi * f * x_time) + phase)))

  36. Rx_signal = np.array(Rx_signal)
  37. Rx_signal_phase = np.array(Rx_signal_phase)

  38. Rx_y_fft = fftshift(fft(Rx_signal))
  39. x_f = np.linspace(0, int(fs), len(Rx_signal), endpoint=True) - int(fs/2)
  40. Rx_abs_y = np.abs(Rx_y_fft)
  41. Rx_angle_y = np.angle(Rx_y_fft)

  42. Rx_y_fft_phase = fftshift(fft(Rx_signal_phase))
  43. Rx_abs_y_phase = np.abs(Rx_y_fft_phase)
  44. Rx_angle_y_phase = np.angle(Rx_y_fft_phase)


  45. # 画图展示
  46. plt.figure(figsize=(14, 12))
  47. # seen_point_num = 600   # 刚好是2个子脉冲的 600=2*300  sample_num_per_freq
  48. plt.figure(1)
  49. plt.subplot(4, 1, 1)
  50. x1 = np.arange(sample_num_per_freq)  # 0   299
  51. plt.plot(x1, Rx_signal.real[:sample_num_per_freq], marker='o', markersize=6, markerfacecolor='r')
  52. plt.title('信号_时域(实部)', fontproperties=font, fontsize=16)
  53. # plt.axis([0, 500, -3, 3])
  54. plt.xlabel('time/sample_num')

  55. plt.subplot(4, 1, 2)
  56. plt.plot(x1, Rx_signal.imag[:sample_num_per_freq], marker='o', markersize=6, markerfacecolor='b')
  57. plt.title('信号_时域(虚部)', fontproperties=font, fontsize=16)
  58. # plt.axis([0, 500, -3, 3])
  59. plt.xlabel('time/sample_num')

  60. plt.subplot(4, 1, 3)
  61. plt.plot(x1, Rx_signal_phase.real[:sample_num_per_freq], marker='o', markersize=6, markerfacecolor='r')
  62. plt.title('信号(phase)_时域(实部)', fontproperties=font, fontsize=16)
  63. # plt.axis([0, 500, -3, 3])
  64. plt.xlabel('time/sample_num')

  65. plt.subplot(4, 1, 4)
  66. plt.plot(x1, Rx_signal_phase.imag[:sample_num_per_freq], marker='o', markersize=6, markerfacecolor='b')
  67. plt.title('信号(phase)_时域(虚部)', fontproperties=font, fontsize=16)
  68. # plt.axis([0, 500, -3, 3])
  69. plt.xlabel('time/sample_num')


  70. plt.figure(2)
  71. plt.subplot(2, 2, 1)
  72. plt.plot(x_f, Rx_abs_y, 'blue')
  73. plt.title('信号的幅度谱(未归一化)', fontproperties=font, fontsize=16)
  74. plt.xlabel('freq')

  75. plt.subplot(2, 2, 2)
  76. plt.plot(x_f, Rx_angle_y, 'violet')
  77. plt.title('信号的相位谱', fontproperties=font, fontsize=16)
  78. plt.xlabel('freq')

  79. plt.subplot(2, 2, 3)
  80. plt.plot(x_f, Rx_abs_y_phase, 'blue')
  81. plt.title('信号_phase的幅度谱(未归一化)', fontproperties=font, fontsize=16)
  82. plt.xlabel('freq')

  83. plt.subplot(2, 2, 4)
  84. plt.plot(x_f, Rx_angle_y_phase, 'violet')
  85. plt.title('信号_phase的相位谱', fontproperties=font, fontsize=16)
  86. plt.xlabel('freq')


  87. plt.show()

复制代码


改变相位01.png
改变相位02.png
改变相位03.jpg
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-3-29 09:49 , Processed in 0.195419 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表