Python从曲面轮廓P中提取点探针

2024-05-13 02:20:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从曲面等高线图中提取给定的点探针。因此,我使用以下代码片段创建曲面:

def createInterpolatedSurface():
  npts=1000
  xi = np.linspace(min(x), max(x),npts)
  yi = np.linspace(min(y), max(y),npts)
  xi,yi=np.meshgrid(xi,yi,indexing='xy')
  ui=scipy.interpolate.griddata((x,y),u,(xi,yi),method='linear')
return xi,yi,ui

我的下一步是设置一个点数组,使用initSensorArray作为嵌套循环函数,我感兴趣的是:

所以这是我的主要问题。我想使用点的实际物理坐标,而不是griddata插值函数的ij索引坐标。在

例如:物理空间中的Point(0.5,0.1)等于griddata ij索引中的Pointg(100125),。在

如何将物理点坐标映射到网格数据,外推这些点并将它们映射回去?在

谢谢你的帮助


Tags: 函数uinp物理minmax曲面探针
1条回答
网友
1楼 · 发布于 2024-05-13 02:20:21

你可以在2D中使用scipy'`interpolate函数

from scipy import interpolate

x,y,u = createInterpolatedSurface()

#Create an interpolation function 
f = interpolate.interp2d(x, y, u, kind='cubic')

#Use interpolation function to get results
xpoint = 0.5
ypoint = 0.1
upoint = f(xpoint, ypoint)

相关问题 更多 >