找到三维曲面BSplice Python scipy bisplrep的最大点。可以使用sproot吗?

2024-04-23 12:08:02 发布

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

我想找到用bisplrep生成的三维曲面B样条的所有局部极大值的x,y坐标。你知道吗

splder和sproot与splrep一起用于查找单变量B样条曲线。 bisplrep的最大值和最小值是如何发现的?你知道吗

我的代码如下。你知道吗

tck = interpolate.bisplrep(X, Y, sensor_counts, s=0)
xnew, ynew = np.mgrid[ min(grid_x):max(grid_x):100j, min(grid_y):max(grid_y):100j]
znew = interpolate.bisplev(xnew[:,0], ynew[0,:], tck, dx=0, dy=1)
print xnew
print ynew
fig = plt.figure()
ax = fig.gca(projection='3d')
print tck
surf = ax.plot_surface(xnew, ynew, znew, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False)
cset = ax.contour(xnew, ynew, znew, zdir='z', offset=5100, cmap=cm.coolwarm)

Tags: figcmaxminmaxgrid样条cmap
1条回答
网友
1楼 · 发布于 2024-04-23 12:08:02

我们可以用科学优化python库。你知道吗

我曾经scipy.optimize.fmin\tnc公司以下面的方式。你知道吗

def neg_bspline( x ):
global tck
f = -interpolate.bisplev( x[0], x[1], tck, dx=0, dy=0)
g = [-interpolate.bisplev( x[0], x[1], tck, dx=1, dy=0 ), -interpolate.bisplev( x[0], x[1], tck, dx=0, dy=1)]
return f, g

for i in sensor_array:
    x0 = i.get_coordinate()
    print x0
    bounds = [(0,200) , (0,200)]
    x0 = fmin_tnc(neg_bspline, x0=x0, bounds=bounds)
    print x0
    solutions.append( x0[0] )
result_plot( solutions )

相关问题 更多 >