对于将非结构化数据插入到结构化输出中的人们来说,有很多问题(和答案)可供选择。其解决方案包括网格网格或二元样条。然而,我正在寻找相反的结果。如何(快速)将结构化数据插值到非结构化(delaulany)三角形?
我拥有的数据是使用meshio作为pygmsh的一部分加载的。
import meshio as mio
data = mio.read(fname)
data.cells['vertex'].shape
Out[128]: (2906, 1)
data.cells['triangle'].shape
Out[129]: (213898, 3)
plt.figure()
plt.tripcolor(data.points[:, 0], data.points[:, 1], -data.points[:, 2])
plt.triplot(data.points[:, 0], data.points[:, 1], 'k.', ms=2)如下图所示

。我有新的数据要在这个三角网格上更新。我计划将规则结构化数据的值插值到空间中的相同点,然后更新三角形网格的值。
发布于 2019-05-15 08:22:34
我找到的最接近这一点的是Python: interpolating in a triangular mesh
根据这个答案工作,并通过示例进行扩展。
newBathy['lon'].shape
Out[154]: (1040, 271)
newBathy['lat'].shape
Out[155]: (1040, 271)
newBathy['elevation'].shape
Out[156]: (1040, 271)
#I have to flatten so i don't get a shape error
triObj = tri.Triangulation(newBathy['lon'].flatten(), newBathy['lat'].flatten())
ftri = tri.LinearTriInterpolator(triObj, newBathy['elevation'].flatten())
newZs = ftri(data.points[:, 0], data.points[:, 1])这使得我只在已知域的一小部分中获得了数据,但我可以从data.points([:,3])的值中更新newZ中的非屏蔽值。我还没有想出最好的方法,因为立方插值需要一段时间,让我的电脑听起来像一艘宇宙飞船。线性显然可以工作,但可以看起来更好。

https://stackoverflow.com/questions/56140254
复制相似问题