不挂在对齐点上的scipy.interpolate.griddata的替代方法 [英] Alternatives to scipy.interpolate.griddata that don't hang on aligned points

查看:287
本文介绍了不挂在对齐点上的scipy.interpolate.griddata的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要在网格上插值的点数据集.这些点以网格方式对齐,缺少一些点,请参见下文:

为了使其复杂化,其他输入点集可能无法在网格上对齐,因此我试图使用scipy.interpolate.griddata将这些值插值到常规网格上.但是,有时我的基础网格与输入点数据集的采样率完全一致,并且griddata挂起.根据此问题,如果样本出现在3个完全对齐的点上,则scipy.interpolate.griddata的运行效果会很差,这有时对我来说是发生的.

在Python中将点数据插值到常规网格上是否有一种高性能的选择?

解决方案

我的解决方案是通过1e-6 * grid_cell_size之间的随机因子随机扰动每个输入点的x和y坐标.我选择1e-6作为经验法则,它比32位浮点数中的最小增量差大几个数量级,但又小到足以使它所引入的误差仍被插值方案所引入的误差所掩盖. >

我仍然对其他想法持开放态度,但是通过引入很小的数值误差,我可以使用scipy提供的股票插值函数.

I have a point dataset that I'm trying to interpolate on a grid. These points are aligned in grid fashion with some points missing see below:

To complicate it, it's possible that other input pointsets may not align on a grid, so I'm trying to use scipy.interpolate.griddata to interpolate these values onto a regular grid. However, sometimes my underlying grid aligns perfectly with the sampling rate of the input point dataset and griddata hangs. According to this question scipy.interpolate.griddata operates poorly if the sample occurs across 3 points that are perfectly aligned which sometimes happens for me.

Is there a high performance alternative for interpolation of point data onto a regular grid in Python?

解决方案

My solution has been to stochastically perturb the x and y coordinates of each input point by a random factor between 1e-6 * grid_cell_size. I choose 1e-6 as a rule of thumb of several orders of magnitude greater than the minimum delta difference in a 32 bit float, yet small enough that the error introduced by it is still shadowed by the error introduced by the interpolation scheme.

I'm still open to other ideas, but this way I can use the stock interpolation functions provided by scipy by introducing a very small numerical error.

这篇关于不挂在对齐点上的scipy.interpolate.griddata的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆