ValueError:点不能包含NaN

2024-06-25 23:11:14 发布

您现在位置:Python中文网/ 问答频道 /正文

现在我确信这只是我在某个地方犯了一个愚蠢的错误,但我没有抓住它。有时当我运行代码时,绘图会显示出来,我不会得到这个错误。其他时候我会收到一条可爱的小错误信息:

ValueError    Traceback (most recent call last)
<ipython-input-6-acef8d8cfdfb> in <module>()
104 #now to interpolate TCSPC data
105 TCSPCdatadesiredgrid_x, TCSPCdatadesiredgrid_y = np.mgrid[10:321, 0:60.36:0.025]  #60.36 so that 
#it will get to 60.35
--> 106 grid_TCSPC = griddata(TCSPCdatapoints, TCSPCdatavalues, (TCSPCdatadesiredgrid_x, 
TCSPCdatadesiredgrid_y), method='cubic')
107 plt.figure(4)
108 plt.imshow(grid_TCSPC, extent=(0,60.35,10,320), origin='lower', aspect=0.195)


ValueError: Points cannot contain NaN

这也很奇怪,因为我在程序中还有三个类似于这个的代码,每次都运行得很好,所以我想这就是为什么我知道这只是一个愚蠢的错误:

TCSPCdatadesiredgrid_x, TCSPCdatadesiredgrid_y = np.mgrid[10:321, 0:60.36:0.025]  #60.36 so that it 
#will get to 60.35 
grid_TCSPC = griddata(TCSPCdatapoints, TCSPCdatavalues, (TCSPCdatadesiredgrid_x, 
TCSPCdatadesiredgrid_y), method='cubic')
plt.figure(4)
plt.imshow(grid_TCSPC, extent=(0,60.35,10,320), origin='lower', aspect=0.195)
plt.xlabel('Delay time (ns)')
plt.ylabel('Temperature (K)')
plt.title('TCSPC data, interpolated every 1K')
plt.show()

Tags: to代码datasothat错误npit