0

有很多问题(和答案)可供人们将非结构化数据插入结构化输出。解决方案包括网格或双变量样条。但是我正在寻找相反的情况。如何将结构化数据内插到非结构化(delaulany)三角形(快速)?

我拥有的数据作为 pygmsh 的一部分加载了 meshio。

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)

显示下图海岸线数据。我有新数据要在这个三角形网格上更新。我计划将规则结构化数据的值插入到空间中的相同点,然后更新三角形网格的值。

4

1 回答 1

0

我发现最接近这个的是Python:在三角形网格中插值

处理该答案并通过示例进行扩展。

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]). 还没有找到最好的方法,因为三次插值需要一段时间,让我的电脑听起来像一艘宇宙飞船。线性显然有效,但可能会更好看。

在此处输入图像描述

于 2019-05-15T00:22:34.413 回答