MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   大矩阵的SciPy插值 (https://www.labfans.com/bbs/showthread.php?t=26614)

poster 2019-12-14 20:13

大矩阵的SciPy插值
 
我有一个ndarray(Z)在矩形网格(X,Y)上有一些500000个元素。

现在,我想在x,y的约100个位置插值,这些值不一定在网格上。

我有一些在Matlab中工作的代码:

data = interp2(X,Y,Z, x,y); 但是,当我尝试对scipy.interpolate使用相同的方法时,根据方法的不同会出现各种错误。例如,如果我指定kind = 'linear' ,则interp2d失败,并出现MemoryError;如果我指定kind = 'linear' cubic kind = 'linear' ,则“ OverflowError:要插入的数据点太多kind='cubic' 。我也尝试了Rbf和bisplev但它们也失败了。

所以问题是:是否有一个插值函数可以对大矩阵进行插值?有其他解决方法吗? (或者我是否必须编写一个函数来选择要插入点周围的适当区域然后调用interp2d的函数?)

另外:如何处理复数?



[B]回答:[/B]

由于数据在网格上,因此可以使用[URL="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.RectBivariateSpline.html#scipy.interpolate.RectBivariateSpline"]RectBivariateSpline[/URL] 。

要使用复数,可以分别插值data.real和data.imag (FITPACK例程IIRC不处理复数数据)。



[url=https://stackoverflow.com/questions/5328128]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 22:43

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.