简体   繁体   English

Function scipy.interpolate.interpn() 太慢了

[英]Function scipy.interpolate.interpn() much too slow

I am using scipy.interpolate.interpn() to interpolate a value at a single point on a 2D grid.我正在使用scipy.interpolate.interpn()在 2D 网格上的单个点插入一个值。 The catch is that for this single point and for the 2D grid, I have to perform many evaluations of the interpn function:问题是对于这个单点和二维网格,我必须对interpn function 执行许多评估:

interpolatedValue = []
for i in range(300000):
  interpolatedValue.append(scipy.interpolate.interpn(points, valueList[i], point)[0])

The code works as expected, but is far too slow.该代码按预期工作,但速度太慢。 For each of these calls, the parameters point and points are the same.对于这些调用中的每一个,参数pointpoints都是相同的。 Consequently the interpolation weights determined for each call must be identical.因此,为每个调用确定的插值权重必须相同。 Since the weights are the same, it is inefficient to compute them over and over again.由于权重相同,因此一遍又一遍地计算它们是低效的。

Can it really be that there is no faster way to do this with scipy? scipy 真的没有更快的方法吗?

interpolatedValue = [ scipy.interpolate.interpn( points, value, point)[0] for value in valueList ] interpolatedValue = [scipy.interpolate.interpn(points, value, point)[0] for valueList ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM