我正在尝试编写一段非常简单的代码,该代码将从一组现有数据进行插值以创建值的合成分布。
到目前为止,我的代码如下所示:
import pandas as pd
import numpy as np
import scipy
from scipy.interpolate import griddata
import matplotlib
CRN_data=pd.read_table('disequilibrium data.dat',sep=',')
kzz=CRN_data['Kzz']
temperature=CRN_data['Temperature']
degree=CRN_data['Mean Degree']
points=np.ndarray(shape=(len(kzz),2),dtype='float')
for i in range(len(kzz)):
points[i][0]=kzz[i]
points[i][1]=temperature[i]
gridx,gridy= np.mgrid[0:1:100j,0:1:200j]
grid=griddata(points,degree,(gridx,gridy),method='cubic')
print grid
我插入的数据集如下所示:
Kzz,Temperature,Mean Degree,
1.00E+06,400,7.41E+18
1.00E+06,500,4.48E+23
...
1.00E+08,400,4.67E+18
1.00E+08,500,6.88E+23
1.00E+08,750,1.88E+34
...
1.00E+10,750,2.73E+33
1.00E+10,900,2.82E+37
1.00E+10,1000,1.19E+39
...
然而,当代码运行时,我得到的主要输出是
[[ nan nan nan ..., nan nan nan]
[ nan nan nan ..., nan nan nan]
[ nan nan nan ..., nan nan nan]
...,
[ nan nan nan ..., nan nan nan]
[ nan nan nan ..., nan nan nan]
[ nan nan nan ..., nan nan nan]]
这显然不是很有帮助。这是 Scipy 中的错误,还是(更有可能)我做错了什么?
相关分类