【发布时间】:2018-06-21 12:58:48
【问题描述】:
下面是我的代码 我想在 -50Mhz 和 50Mhz 之间扫描 400MHz 音调。意思是 扫描范围应在 350MHz 和 450MHz 之间。但事实并非如此。别 了解这是什么原因。有人认为这是因为频率是相位的导数。我在“sweep_sine”函数的注释行中也给出了一个镜头,但这似乎也无济于事。任何帮助,将不胜感激。
添加了意外程序输出的图像。如您所见,我能够将我的 400MHz 音调转换为 300MHz。当我尝试以类似于 shift 的方式进行扫描时;输出不正确,因为它没有从 350MHz 扫描到 450MHz,中间是 400MHz 音调。
我现在可以正确扫描信号,如图 2 所示。当信号为 e^i2*pift 形式时,时域信号看起来也很好。但是,当我使用 sin(2*pift) 形式的真实信号时,时域版本看起来已损坏(图 3)。这可能是什么原因?谢谢。
https://i.stack.imgur.com/9H1Dk.png
https://i.stack.imgur.com/Ey3tQ.png
https://i.stack.imgur.com/FzmDS.png
import numpy as np
import matplotlib.pyplot as plt
def gen_sig(freq=380e6, fs=6080e6, n_samp=6400):
ts = 1/fs
t_arr = np.arange(0, n_samp)*ts
sig = np.exp(2 * 1j * np.pi * freq * t_arr)
#sig = np.sin(2 * np.pi * freq * t_arr)
return sig,ts
def freq_shift_sine(sine, ts, shift_freq = 50e6):
tx_sig_t = np.linspace(0, ts*sine.shape[-1], num=sine.shape[-1])
#tx_sig_sqrd = np.square(tx_sig_t)
#hift the sine
freq_shftd_sig = sine * np.exp(1.0j * 2 * np.pi * (shift_freq * tx_sig_t))
#freq_shftd_sig = sine * np.exp(1.0j * np.pi * (shift_freq * tx_sig_sqrd))
return freq_shftd_sig
def sweep_sine(sine, ts, up_lim = 50e6, low_lim = -50e6):
tx_sig_t = np.arange(0, sine.shape[-1])*ts
tx_sig_sqrd = np.square(tx_sig_t)
phi = low_lim*tx_sig_t + (up_lim-low_lim)*(tx_sig_sqrd/(2*ts*sine.shape[-1]))
dopp_shftd_sig = sine * np.exp(1.0j* 2 *np.pi * phi)
return dopp_shftd_sig
if __name__=='__main__':
#generate a sine wave 16 times over sampled
tx_sig, t_samp = gen_sig(freq=400e6, fs=6400e6, n_samp=6400)
#do an fft
tx_sig_fft = np.fft.fft(tx_sig)
#generate freqency axis for fft
freq_arr = np.fft.fftfreq(tx_sig.shape[-1], t_samp)
#shift sine wave
tx_sig_shifted = freq_shift_sine(tx_sig, t_samp, shift_freq = -100e6)
#fft the shifted sine
tx_sig_shftd_fft = np.fft.fft(tx_sig_shifted)
#sweep sine wave by up_lim+low_lim Hz
tx_sig_swept = sweep_sine(tx_sig, t_samp, up_lim = 50e6, low_lim = -50e6)
#fft the swept sine
tx_sig_swept_fft = np.fft.fft(tx_sig_swept)
plt.figure()
plt.plot(freq_arr, abs(tx_sig_fft))
plt.plot(freq_arr, abs(tx_sig_shftd_fft))
plt.plot(freq_arr, abs(tx_sig_swept_fft))
plt.axis([0,1e9, 0, 2e3])
plt.figure()
plt.plot(tx_sig)
plt.plot(tx_sig_shifted)
plt.plot(tx_sig_swept)
plt.axis([0,100, -1.2, 1.2])
【问题讨论】:
-
我不清楚你想达到什么目标。只从
dopp这个名字我终于意识到你想要一个音调的转变。转换应该模仿多普勒效应。对吗? -
我会有一个循环,我在其中合成曲线但是为了实现逐渐的频移,我会改变我应用到 theta 的 delta 的大小,这是我输入 sin 函数的值跨度>
-
对缺乏清晰表示歉意,简单地说,我乘 sine_sig = np.sin(2 * np.pi * freq * t_arr) 将 sine_sig 从 freq - sweep_start 扫描到频率 + sweep_finish
-
@rth 是正确的。在原始帖子中的图像中,我可以看到扫描,但开始和结束频率与我在程序的主要功能中提供的频率不正确。
-
@zoulzubazz 请尝试绘制信号与时间的关系。你会发现,在你的两个函数之后:常数位移和多普勒变换,信号看起来不像一个正弦波。
标签: python numpy signal-processing fft complex-numbers