Alternatives to scipy.interpolate.griddata that don't hang on aligned points

柔情痞子 提交于 2019-12-07 21:24:49

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/10886971/alternatives-to-scipy-interpolate-griddata-that-dont-hang-on-aligned-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!