0

我想找到使用 bisplrep 制作的 3D 曲面 B-Spline 的所有局部最大值的 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)
4

1 回答 1

0

We can use scipy.optimize library of python.

I used scipy.optimize.fmin_tnc in the following way.

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 )
于 2017-11-22T04:50:46.787 回答