エラーが出ていますが,どこへのエラーなのか見当がつきません・・・.
アドバイスいただけませんか?
エラーは
ValueError: operands could not be broadcast together with shapes (16386,) (16384,)
です.
2つのファイルは数値が各行にあり,数値の個数は同じです
python
1 2import matplotlib.pyplot as plt 3import numpy as np 4 5x = [float(s) for s in open('./test1.txt')] 6y = [float(s) for s in open('./test2.txt')] 7 8 9from swan import pycwt 10 11Fs = 1/0.01 12omega0 = 6 13 14freqs=np.arange(0.1,20,0.025) 15r=pycwt.cwt_f(y,freqs,Fs,pycwt.Morlet(omega0)) 16rr=np.abs(r) 17 18plt.rcParams['figure.figsize'] = (20,6) 19fig = plt.figure() 20ax1 = fig.add_axes([0.1,0.75,0.7,0.2]) 21ax2 = fig.add_axes([0.1,0.1,0.7,0.60],sharex=ax1) 22ax3 = fig.add_axes([0.83,0.1,0.03,0.6]) 23 24ax1.plot(x,y,'k') 25 26img = ax2.imshow(np.flipud(rr),extent=[0,20,freqs[0],freqs[-1]], 27 aspect='auto',interpolation='nearest') 28twin_ax = ax2 29#logスケールにする 30#twin_ax.set_yscale('log') 31twin_ax.set_xlim(0, 20) 32twin_ax.set_ylim(0.1, 20) 33ax2.tick_params(which='both', labelleft=False, left=False) 34twin_ax.tick_params(which='both', labelleft=True, left=True, labelright=False) 35 36fig.colorbar(img,cax=ax3) 37 38plt.show () 39 40