最适合矩形网格到光滑的3D表面

时间:2015-01-16 01:16:17

标签: python visualization mesh data-fitting

G'day,我正在努力寻找一种方法来创建一个最适合光滑3D表面的矩形网格。特别是我有this图中显示的地震断层模型。

这些是故障的深度轮廓。我想找到一个最适合表面的定义尺寸(比如10x10km)的矩形网格。它不必(并且它不能)精确地在表面上,只是最接近的可能并且它必须是矩形,而不仅仅是四边形。我有定义表面的节点,我可以很容易地插入它们。

欢迎使用Python解决方案,或者对我解决的开源代码提出建议。我尝试过商业网格游戏(ABAQUS),但他们总是返回四边形。我无法弄清楚这一点,所以任何提示都会受到赞赏。

1 个答案:

答案 0 :(得分:2)

如果您有定义曲面的节点,则意味着您有一个不规则的坐标网格和相应的值。因此,您可以从中生成三角测量(很可能是您用来显示这些填充轮廓的工具在屏幕后面使用相同的颜色)。

Matplotlib有两个非常有用的类,可以将三角测量转换为rectilinear grid(矩形网格的更通用形式):LinearTriInterpolatorCubicTriInterpolator。它们正在this matplotlib example中使用。

这些是来自同一个例子的基本步骤,由我注释,但是归功于matplotlib贡献者:

import matplotlib.pyplot as plt
import matplotlib.tri as mtri
import numpy as np

# Create triangulation.
coords, earthquake_fault = get_coordinate_data() # to be filled in by you
x = coords['x']
y = coords['y']
triang = mtri.Triangulation(x, y)

# Interpolate to regularly-spaced quad grid.
z = earthquake_fault # the "height" data
xi, yi = np.meshgrid(np.linspace(x.min(), x.max() 20), np.linspace(y.min(), y.max(), 20))

interp_lin = mtri.LinearTriInterpolator(triang, z)
zi_lin = interp_lin(xi, yi)

# Plot the triangulation.
plt.subplot(121)
plt.tricontourf(triang, z)
plt.triplot(triang, 'ko-')
plt.title('Triangular grid')

# Plot linear interpolation to quad grid.
plt.subplot(122)
plt.contourf(xi, yi, zi_lin)
plt.title('Rectangular grid')
相关问题