admin管理员组文章数量:1279144
I'm trying to perform 6th wavelet transform with python, using libraries as numpy,pandas, matplotlib, pywt (image 1). But I can't do something similar to the graph (image 2) Please, can someone help me? image 1image 2
import numpy as np
import matplotlib.pyplot as plt
import pywt
import pandas as pd
df=pd.read_csv('441664609_22_PDCSAP_SC6.dat',sep=' ',header=None).dropna()
x = df[0]
y = df[1]
def wavelet_transform(x, y):
x1 = np.linspace(min(x), max(x), len(x))
wavelet = 'cmor6-1.5'
scales = np.logspace(np.log10(2), np.log10(len(x)//2), num=50)
coefficients, freq = pywt.cwt(y, scales, wavelet, sampling_period=np.mean(np.diff(x1)))
power = np.abs(coefficients) ** 2
periods = 1 / freq
return x1, freq, power, time
time, periods, power, freq = wavelet_transform(x, y)
plt.figure(figsize=(10, 6))
plt.imshow(power, aspect='auto', extent=[time[0], time[-1], periods[-1], periods[0]], cmap='jet')
plt.colorbar(label='Power')
plt.xlabel("Time")
plt.xlabel("Time (days)")
plt.yscale('log')
plt.title("Wavelet Power Spectrum")
plt.show()
I tried everything in the code (I guess), but I never can't do it right, seems so difficult...
本文标签: pythonI can39t do wavelet transformStack Overflow
版权声明:本文标题:python - I can't do wavelet transform - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741269803a2369067.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论