python - 如何对 22 行 546304 列的数组应用连续小波变换?
问题描述
我想对 22 行和 546304 列的数组(时间序列信号)应用连续小波变换,以将尺度图提供给 CNN。我收到错误Traceback (most recent call last): File "E:/physionet/wavelet.py", line 144, in create_cwt_image
sig = data[ii, :, jj] IndexError: too many indices for array
我不知道我是否以正确的方式使用 CWT 以及我的代码是否正确。
任何可以提供一些见解的人将不胜感激。
def create_cwt_image(data):
scales = range(1,128)
wavelet_name = 'morl'
#n_samples = data.shape[0]
#n_signals = data.shape[0]
scales = range(1,128)
data_cwt = np.ndarray(shape=(22,127,127, 9))
for ii in range(0,22):
if ii % 1000 == 0:
print(ii)
for jj in range(0,9):
sig = data[ii, :, jj]
coeffs, freqs = pywt.cwt(sig, scales, wavelet_name)
rescale_coeffs = resize(coeffs, (128, 128), mode = 'constant')
data_cwt[ii,:,:,jj] = rescale_coeffs
return data_cwt
解决方案
推荐阅读
- splunk - Splunk:发生此错误时需要帮助使用事务来获取 pcode
- xpath - 如果可用,则将嵌套兄弟中的文本与父节点中的文本连接起来
- google-apps-script - 有没有办法通过脚本编辑器动态引用 google sheet 脚本中的单元格以在另一个单元格上创建注释?
- mysql - 如何设置与关键字相同的列名?
- python - 如何输出以显示 $00.00 到小数点后第二位。代码当前生成 $00.0 或/和 $00.000000000000000
- python - 如何安全地“反复卸载 numpy”?为什么这是必要的?
- fortran - 对 nlopt_... 符号的未定义引用
- lotus-notes - 复制文档已保存,但原始文档未使用 lotusscript 更改状态
- python - 如何打印带有数字的矩形?
- java - 程序崩溃时如何保存“Java 控制台”日志?