def callShapeGen_offsetsOnly(r,L_o,l_o,A_o,L_s,l_s,a_s,sampleResolution,vertices,vertIndices,imData): global steps (x,y)=r steps+=1 if abs(x)>60. or abs(y)>60. or x==num.inf or x==-num.inf or x==num.inf or y==-num.inf or L_o>360. or L_o<0. or l_o>90. or l_o<-90. or a_o>360. or a_o<0. or l_s>90. or l_s<-90. or L_s>360. or L_s<0. or a_s>360. or a_s<0.: return -num.inf print steps,L_o,l_o,A_o,L_s,l_s,a_s,x,y, offsets=num.array([x,y]) (rot_vertices,p3d,c3d,m2d,c2d,a2d,n,m,n_obs,rot_n_sun,angs_s,angs_o,chi,image)=shapeGen_ISS(vertices,vertIndices, long_o=L_o,lat_o=l_o,az_o=A_o, long_s=L_s,lat_s=l_s,az_s=a_s, offsets=offsets,sampleResolution=sampleResolution, imData=imData) print chi return 0.5*chi
def event_handler(event): global vertics,vertIndices,showSurface,showNormals,showSources global long_o,lat_o,a_o,long_s,lat_s,a_s global sampleResolution global offsets global imData global plotUpdate global alpha global azim,elev print event.key if event.key in ['shift','ctrl+','ctrl+shift','control']: return None elif event.key=='q': sys.exit() if event.key=='z':long_o+=15.0 elif event.key=='Z':long_o-=15.0 if event.key=='x':lat_o+=15.0 elif event.key=='X':lat_o-=15.0 if event.key=='c':a_o+=15.0 elif event.key=='C':a_o-=15.0 if event.key=='ctrl+z':long_s+=5.0 elif event.key=='ctrl+Z':long_s-=5.0 if event.key=='ctrl+x':lat_s+=5.0 elif event.key=='ctrl+X':lat_s-=5.0 if event.key=='right': offsets[0]+=1 elif event.key=='left': offsets[0]-=1 elif event.key=='up': offsets[1]+=1 elif event.key=='down': offsets[1]-=1 print long_o%360,lat_o,a_o print long_s%360.,lat_s,a_s print offsets if event.key=='r': long_s+=5.*(random.random()-0.5) lat_s+=5.*(random.random()-0.5) long_o+=5.*(random.random()-0.5) lat_o+=5.*(random.random()-0.5) a_o+=5.*(random.random()-0.5) #offsets+=(num.array([random.random(),random.random(),random.random()])-0.5)*30. (rot_vertices,p3d,c3d,m2d,c2d,a2d,n,m,n_obs,rot_n_sun,angs_s,angs_o,chi,image)=shapeGen_ISS(vertices,vertIndices, long_o=long_o,lat_o=lat_o,az_o=a_o, long_s=long_s,lat_s=lat_s,az_s=a_s, offsets=offsets,sampleResolution=sampleResolution, imData=imData*1.0) collection=Poly3DCollection(p3d,linewidths=0.0,facecolors=c3d) collection.set_alpha(alpha) ax1.cla() ax2.cla() ax3.cla() ax4.cla() if showSurface: ax1.set_axis_bgcolor('0.0') ax1.set_axis_off() ax1.set_aspect('equal') ax2.set_aspect('equal') ax3.set_aspect('equal') ax1.set_xlim(-120,120) ax1.set_ylim(-120,120) ax1.set_zlim(-120,120) ax2.set_xlim(-120,120) ax2.set_ylim(-120,120) ax2.set_zlim(-120,120) imgPlot=ax3.imshow(256.-image,aspect='equal',interpolation='nearest') imgPlot.set_cmap('Greys') oImData=imData*0.7 oImData+=image*0.3 imgDataPlot=ax4.imshow(256.-oImData,aspect='equal',interpolation='nearest') imgDataPlot.set_cmap('Greys') fig.canvas.set_window_title(chi) #w=num.where(c2d==0) #ax3.scatter(m2d[w,1],m2d[w,2],marker='.') #w=num.where(c2d>0) #ax3.scatter(m2d[w,1],m2d[w,2],marker='.',c='r') if showSurface: pylCollection=ax1.add_collection3d(collection) if showSurface: vertSpacing=1#0 else: vertSpacing=1 ax2.scatter(rot_vertices[:,0][::vertSpacing], rot_vertices[:,1][::vertSpacing], rot_vertices[:,2][::vertSpacing], marker='.',s=2,c='k',alpha=0.5) if showSources: sunSpot=rot_n_sun/num.sum(rot_n_sun**2)**0.5 ax2.scatter(sunSpot[0]*150.,sunSpot[1]*150.,sunSpot[2]*150.,marker=(5,0,0),c='y',s=70,zorder=0) ax2.scatter(n_obs[0]*200.,n_obs[1]*200.,n_obs[2]*200.,marker=(10,0,0),c='g',s=70,zorder=0) #ax2.scatter(0.0,0.0,0.0,marker=(10,0,0),c='r',s=50,zorder=0) if showNormals: for i in range(567,568):#0,len(n),45): #if angs_s[i]<=num.pi/2.: Y=num.concatenate([m[i],m[i]+n[i]*50.]).reshape(2,3) ax2.plot(Y[:,0],Y[:,1],Y[:,2],c='r',lw=3) ax1.view_init(azim=azim, elev=elev) ax2.view_init(azim=azim, elev=elev) ax2.set_xlabel('x') ax2.set_ylabel('y') ax2.set_zlabel('z') ax3.set_xlabel('Simulated Image') ax4.set_xlabel('VIMS Image') pyl.draw()