用于 NumPy 的 MATLAB griddata3?
我意识到有一个用于 NumPy 通过 Matplotlib,但是有 griddata3 (同样有 griddata,但维度更高)?
换句话说,我有 (x,y,z,d(x,y,z)),其中 (x,y,z) 形成不规则网格,d(x,y,z) 是三个变量的标量函数。我需要使用某种可以处理原始 (x,y,z) 数据的不均匀性的插值来为一组新的 (xi, yi, zi) 点生成 d(xi, yi, zi) 。
最终, (xi, yi, zi, d(xi, yi, zi)) 数据必须以某种方式呈现为表面,但这是稍后的问题。我也没有 d(.) 函数的分析形式;我只有这方面的数据。
I realize that there is a griddata for NumPy via Matplotlib, but is there a griddata3 (same has griddata, but for higher dimensions)?
In other words, I have (x,y,z,d(x,y,z)) where (x,y,z) form an irregular grid and d(x,y,z) is a scalar function of three variables. I need to generate d(xi, yi, zi) for a new set of (xi, yi, zi) points using some kind of interpolation that can handle the non-uniformity of the original (x,y,z) data.
Ultimately, the (xi, yi, zi, d(xi, yi, zi)) data will have to be rendered as a surface somehow, but that's a problem for later. I also do not have an analytical form for the d(.) function; I just have data for it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SciPy 0.9(目前第一个测试版已经发布)有一个新的griddata 函数,可以处理N维数据。
SciPy 0.9 (at the moment, a first beta is out) has a new griddata function that can handle N-dimensional data.
不确定您打算如何渲染 3 个变量的标量函数的表面,除非使用切面或类似的东西。 Mayavi (真的VTK)通过
enthought.mayavi.mlab.pipeline.delaunay3d
支持高效的 Delaunay 三角剖分,这是使用的算法的核心代码>griddata3。请参阅 他们发布的 2D 示例代码,只需添加一维(并使用
delaunay3d
代替)。我不知道如何显式获取用于渲染表面的插值,但可能有一种方法可以通过 Mayavi 对其进行采样,您可以深入研究文档或在 Enthought 邮件列表之一上询问。或者,NCAR 中的 C 函数之一 natgrid 库可能有用,即 dsgrid3d。有一个部分包装器作为 matplotlib 工具包实现。
Not sure how you intend to render a surface of a scalar function of 3 variables, except perhaps using cutplanes or something similar. Mayavi (really VTK which powers Mayavi) has support for efficient Delaunay triangulation via
enthought.mayavi.mlab.pipeline.delaunay3d
, which is the core of the algorithm used bygriddata3
. See the 2D example code they have posted, just add one dimension (and usedelaunay3d
instead). I don't know of a way to explicitly get the interpolated values used to render the surface, but there might be a way to sample it through Mayavi, you could dig through the documentation or ask on one of the Enthought mailing lists.Alternatively, one of the C functions in the NCAR natgrid library may be useful i.e. dsgrid3d. There is a partial wrapper implemented as a matplotlib toolkit.
我不熟悉 griddata3,但您可能想查看 meshgrid 和此相关的帖子。
I am not familiar with griddata3, but you might want to look into meshgrid and this related post.