def plotLikelihoodXY(): fig = plt.figure() ax = fig.gca(projection='3d') # 1024*0.8 y = np.linspace(100, 924.0+512, 30) x = np.linspace(100, 924.0+512, 30) # print x x,y = np.meshgrid(x,y) #x,y = 1.268,-3.197 curvature = 0 hs=5.19 D2=78.48 hr=14.72 crater = Crater(x,y,hs,D2,hr,3.14/6,0) #crater = CreaterParams(0,0,sediment,curvature,w,h,sigma) lTheta = 0.64 lInt=1.91 lDiff=0.57 sc = Scene(lTheta,lInt,lDiff) craterRequest.loadSceneProperties(sc) # print x z = [] for j in range(len(y)): arr = [] for i in range(len(x)): # print str(x[0][i])+", "+str(y[j][0]) crater.x = x[0][i] crater.y = y[j][0] err = craterRequest.requestLikelihood(crater)# lnlikefn(crater) if(err== -np.inf): err = -8 #print err arr.append(err) z.append(arr) M = max(max(z)) m = min(min(z)) print m print M z = (np.array(z)+np.abs(m)) # /(M-m) # return #print z # ax.plot_surface(x, y, z, label='parametric curve') surf = ax.plot_surface(x,y,z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False) # ax.set_zlim(-1.01, 7000) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) # ax.legend() plt.show() return x,y,z
def getCrater(self): buf = self.buf buf.seek(0) typeCraterId = 66 s = struct.pack('i',typeCraterId) self.send(s) self.wait() c,x,y,D,hs,h,hr,xs,ys,err,lemp,lema=struct.unpack('c'+'f'*11,buf[0:4*12]) # c,x,y,D,hs,h,hr,xs,ys,err,lemp,lema=struct.unpack('c'+'f'*9,buf[0:4*10]) # print c,x,y,D,hs,h,hr,xs,ys,err #D2,hr,repose,a5 # arr=struct.unpack('cfff',buf[0:16]) crater = Crater(x,y,hs,D/2.0,hr,35,lemp,lema) crater.calcARepose(xs,ys) return crater