如何将IDFT和噪声应用于python中的信号阵列



所以我目前正在制作一个python程序,该程序涉及制作合成心电图信号,首先我们必须制作一个rr速度图,这是我所做的,代码

#import necessary modules to start the program
import matplotlib.pyplot as plt
import numpy as np
#Create standard deviation variables, which are c1 and c2, t1 and t2 have the same value as hf and lf
c1 = 0.01
c2 = 0.01
#N = NRR which is 256, and is the total amount of data
tau1 = np.sqrt(0.056)
tau2 = np.sqrt(0.076)
N = 256
f1 = 0.1
f2 = 0.25
Nrr= 256
lf = 0.056
hf = 0.076
#ratio also has the equation of  lf/hf
ratio = lf/hf
#declare imaginary numbers
S_real = np.zeros(1000)
S_imaj = np.zeros(1000)
MagIDFT = np.zeros(1000)
#the arrays(lists) that will be used for plotting the signal
S = []
F = []
#we make this into a gauss series function
def SF_gauss_series():
#The main S(F) series that is according to the bimodal spectrum equation
for i in range(N):
f = i/Nrr
#In the mirroring part, we use the signal mirroring equation, x(t) -> x(t+1) -> x(-t+1)
s = (tau1**2/(np.sqrt(2*np.pi*c1**2)))*np.exp(-(f-f1)**2/(2*c1**2)) + 
(tau2**2/(np.sqrt(2*np.pi*c2**2)))*np.exp(-(f-f2)**2/(2*c2**2))     + 
(tau1**2/(np.sqrt(2*np.pi*c1**2)))*np.exp(-(f-1+f1)**2/(2*c1**2))   + 
(tau2**2/(np.sqrt(2*np.pi*c2**2)))*np.exp(-(f-1+f2)**2/(2*c2**2))
#As you can see we have 4 signals, we the the last 2 signals, inverted.
#After sequencing the f and s variables, 
#We use the append() function and move it the F and S array
F.append(f)
S.append(s)
SF_gauss_series()
#Here, we utilize matplotlib as plt, and start plotting the current RSA and Mayer Signals
plt.figure(figsize=(8,4))
#this part to plot the array
plt.plot(F,S, color='orange')
#labeling and naming code
plt.xlabel('Freq. (Hz)')
plt.ylabel('power (sec*2/Hz)')
plt.title("Post-Mirrored Mayer and RSA Waves")
#final show() function to display the graph
plt.show()

现在的问题是,如何将IDFT应用于它?(离散傅立叶逆变换(并给信号带来噪声?我知道应用噪声是可以使用np.random((函数,但我不知道如何对其进行IDFT

如果要将逆DFT应用于某些信号S(作为阵列(,可以应用

FS = np.fft.ifft(S)

np.fft.ifft对此进行了记录。

如果你对纯实信号感兴趣,你可以应用,例如使用np.real提取实部或使用上述值np.abs,但如果你将信号构造为实部,而虚部只是浮点数学的伪像,您还可以考虑使用numpy.real_if_close来避免意外丢弃大的虚值,如果输入实际上可能不代表真实信号,则可能会出现这些虚值。

最新更新