手动生成ifft曲线以将其用于预测
fft_tr = np.fft.fft(demand)
psd = (fft_tr * np.conj(fft_tr))/len(fft_tr)
ampl = (np.sqrt(fft_tr * np.conj(fft_tr))/(len(fft_tr)/2)).real
freq = 1/(1*len(train_df.demand)) * np.arange(len(train_df.demand))
l = np.arange(0, np.floor(len(freq)/2), dtype = "int")
df = pd.DataFrame(zip(freq,psd.real[l],fft_tr.real[l], fft_tr.imag[l],fft_tr[l],ampl[l]),columns = ["freq","PSD_r","fft_real","fft_imag","fft_tr","ampl"])
df["Theta"] = (df["fft_real"]/df["fft_imag"]).apply(lambda x : math.atan(x))
df1 = df.loc[df.PSD_r > 15000,["freq","Theta","ampl"]].reset_index().reset_index(drop = True, inplace=False)
def construct_Waves(time_series, v):
''' this function will construct the waves given a time series
along with the list of freq and phase which is theta'''
return v[2] * np.sin(2*np.pi*time_series*v[0]-v[1])
v = np.zeros(len(time))
for i in range(1,len(df1)):
x = list(df1.loc[i,["freq","Theta","ampl"]])
x1 = np.array(construct_Waves(time+1,x))
v = v+x1
plt.figure(figsize=(20,4))
plt.plot(v)
usp = sharing?手动ifft。从FFT结果。
可以帮助我手动获取实际曲线,以便我可以将其扩展到将来的时间段。
fft_tr = np.fft.fft(demand)
psd = (fft_tr * np.conj(fft_tr))/len(fft_tr)
ampl = (np.sqrt(fft_tr * np.conj(fft_tr))/(len(fft_tr)/2)).real
freq = 1/(1*len(train_df.demand)) * np.arange(len(train_df.demand))
l = np.arange(0, np.floor(len(freq)/2), dtype = "int")
df = pd.DataFrame(zip(freq,psd.real[l],fft_tr.real[l], fft_tr.imag[l],fft_tr[l],ampl[l]),columns = ["freq","PSD_r","fft_real","fft_imag","fft_tr","ampl"])
df["Theta"] = (df["fft_real"]/df["fft_imag"]).apply(lambda x : math.atan(x))
df1 = df.loc[df.PSD_r > 15000,["freq","Theta","ampl"]].reset_index().reset_index(drop = True, inplace=False)
def construct_Waves(time_series, v):
''' this function will construct the waves given a time series
along with the list of freq and phase which is theta'''
return v[2] * np.sin(2*np.pi*time_series*v[0]-v[1])
v = np.zeros(len(time))
for i in range(1,len(df1)):
x = list(df1.loc[i,["freq","Theta","ampl"]])
x1 = np.array(construct_Waves(time+1,x))
v = v+x1
plt.figure(figsize=(20,4))
plt.plot(v)
i have written the above code in order to create the ifft manually. from fft result.
this is the graph I am getting. Where the actual ifft curve is like this.
can some one help me in getting the actual curve manually such that i can extend it to future time periods.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论