小编Ski*_*ony的帖子

当x-array的前2个值相同时,为什么scipy中的interp1d会给出NaN?(fill_value = 0)

import numpy as np
from scipy.interpolate import interp1d

x = np.array([ 0,  0,   0,  0,   0,  30])
time = np.array([ 5,  5,  10,  10,  10,  20])

intx = interp1d(time,x,'linear', 0, True, False, 0)
print intx([4,5,5,6,10,11,20, 20.0001])

>>> [  0.  nan  nan   0.   0.   3.  30.   0.]
Run Code Online (Sandbox Code Playgroud)

如您所见,除了时间值==第一对值之外的所有情况下,插值返回实数.

我知道numpy.unique(),这只是一个学术问题.这是在iPython中运行的Anaconda Python 2.7.

谢谢!

python interpolation numpy scipy

5
推荐指数
1
解决办法
2685
查看次数

标签 统计

interpolation ×1

numpy ×1

python ×1

scipy ×1