Changeset 757
- Timestamp:
- Sep 13, 2012 8:53:46 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r755 r757 934 934 rho[rMM[0]:rMP[0],rMM[1]:rMP[1],rMM[2]:rMP[2]] = peakFunc(x1,rX,rY,rZ,rhoPeak,res,SGData['SGLaue']) 935 935 rho = np.roll(np.roll(np.roll(rho,-rMI[2],axis=2),-rMI[1],axis=1),-rMI[0],axis=0) 936 if SGData['SGInv']: #check origin location & fix it if needed - centrosymmetric only937 Ocheck = np.zeros_like(rho)938 for ipeak in peaks:939 for opeak in peaks:940 dx = ((opeak-ipeak)*incre)%incre941 if np.any(dx): #avoid self vector942 Ocheck[dx[0],dx[1],dx[2]] += 1943 dxMax = np.unravel_index(np.argmax(Ocheck),rho.shape)944 print ' Inversion at:',dxMax,' shift by ;',dxMax-mapHalf945 rho = np.roll(np.roll(np.roll(rho,dxMax[2],axis=2),dxMax[1],axis=1),dxMax[0],axis=0)946 for peak in peaks:947 peak = (peak-(dxMax+mapHalf)/incre)%1.0936 # if SGData['SGInv']: #check origin location & fix it if needed - centrosymmetric only 937 # Ocheck = np.zeros_like(rho) 938 # for ipeak in peaks: 939 # for opeak in peaks: 940 # dx = ((opeak-ipeak)*incre)%incre 941 # if np.any(dx): #avoid self vector 942 # Ocheck[dx[0],dx[1],dx[2]] += 1 943 # dxMax = np.unravel_index(np.argmax(Ocheck),rho.shape) 944 # print ' Inversion at:',dxMax,' shift by ;',dxMax-mapHalf 945 # rho = np.roll(np.roll(np.roll(rho,dxMax[2],axis=2),dxMax[1],axis=1),dxMax[0],axis=0) 946 # for peak in peaks: 947 # peak = (peak-(dxMax+mapHalf)/incre)%1.0 948 948 949 949 return np.array(peaks),np.array([mags,]).T,np.array([dzeros,]).T -
trunk/GSASIIphsGUI.py
r756 r757 1555 1555 def SetupDrawingData(): 1556 1556 generalData = data['General'] 1557 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 1557 1558 atomData = data['Atoms'] 1558 1559 AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE', … … 1561 1562 'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' '] 1562 1563 defaultDrawing = {'Atoms':[],'viewPoint':[[0.5,0.5,0.5],[]],'showHydrogen':True, 1563 'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50., 1564 'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50.,'Zstep':0.5, 1564 1565 'radiusFactor':0.85,'contourLevel':1.,'bondRadius':0.1,'ballScale':0.33, 1565 1566 'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':False, 1566 1567 'showABC':True,'selectedAtoms':[],'Atoms':[],'oldxy':[], 1567 'Quaternion':[1.0,0.0,0.0,0.0],'bondList':{},'viewDir':[0,0,1]} 1568 'bondList':{},'viewDir':[0,0,1]} 1569 defaultDrawing['Quaternion'] = G2mth.AV2Q(2*np.pi,np.inner(Amat,[0,0,1])) 1568 1570 try: 1569 1571 drawingData = data['Drawing'] … … 1573 1575 if not drawingData: #fill with defaults if empty 1574 1576 drawingData.update(defaultDrawing) 1577 if 'Zstep' not in drawingData: 1578 drawingData['Zstep'] = 0.5 1575 1579 if 'contourLevel' not in drawingData: 1576 1580 drawingData['contourLevel'] = 1. … … 1578 1582 drawingData['viewDir'] = [0,0,1] 1579 1583 if 'Quaternion' not in drawingData: 1580 drawingData['Quaternion'] = [1.0,0.0,0.0,0.0]1584 drawingData['Quaternion'] = G2mth.AV2Q(2*np.pi,np.inner(Amat,[0,0,1])) 1581 1585 cx,ct,cs,ci = [0,0,0,0] 1582 1586 if generalData['Type'] == 'nuclear': … … 2436 2440 import wx.lib.colourselect as wcs 2437 2441 generalData = data['General'] 2442 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 2438 2443 SetupDrawingData() 2439 2444 drawingData = data['Drawing'] … … 2454 2459 drawingData['Zclip'] = Zclip.GetValue() 2455 2460 ZclipTxt.SetLabel(' Z clipping: '+'%.2fA'%(drawingData['Zclip']*drawingData['cameraPos']/100.)) 2461 G2plt.PlotStructure(G2frame,data) 2462 2463 def OnZstep(event): 2464 try: 2465 step = float(Zstep.GetValue()) 2466 if not (0.01 <= step <= 1.0): 2467 raise ValueError 2468 except ValueError: 2469 step = drawingData['Zstep'] 2470 drawingData['Zstep'] = step 2471 Zstep.SetValue('%.2fA'%(drawingData['Zstep'])) 2472 2473 def OnMoveZ(event): 2474 move = MoveZ.GetValue()*drawingData['Zstep'] 2475 MoveZ.SetValue(0) 2476 VP = np.inner(Amat,np.array(drawingData['viewPoint'][0])) 2477 VD = np.inner(Amat,np.array(drawingData['viewDir'])) 2478 VD /= np.sqrt(np.sum(VD**2)) 2479 VP += move*VD 2480 VP = np.inner(Bmat,VP) 2481 drawingData['viewPoint'][0] = VP 2482 panel = dataDisplay.GetChildren() 2483 names = [child.GetName() for child in panel] 2484 panel[names.index('viewPoint')].SetValue('%.3f %.3f %.3f'%(VP[0],VP[1],VP[2])) 2456 2485 G2plt.PlotStructure(G2frame,data) 2457 2486 … … 2505 2534 Zclip.Bind(wx.EVT_SLIDER, OnZclip) 2506 2535 slideSizer.Add(Zclip,1,wx.EXPAND|wx.RIGHT) 2536 2537 ZstepSizer = wx.BoxSizer(wx.HORIZONTAL) 2538 ZstepSizer.Add(wx.StaticText(dataDisplay,-1,' Z step:'),0,wx.ALIGN_CENTER_VERTICAL) 2539 Zstep = wx.TextCtrl(dataDisplay,value='%.2f'%(drawingData['Zstep']), 2540 style=wx.TE_PROCESS_ENTER) 2541 Zstep.Bind(wx.EVT_TEXT_ENTER,OnZstep) 2542 Zstep.Bind(wx.EVT_KILL_FOCUS,OnZstep) 2543 ZstepSizer.Add(Zstep,0,wx.ALIGN_CENTER_VERTICAL) 2544 slideSizer.Add(ZstepSizer) 2545 MoveSizer = wx.BoxSizer(wx.HORIZONTAL) 2546 MoveSizer.Add(wx.StaticText(dataDisplay,-1,' Press to step:'),0,wx.ALIGN_CENTER_VERTICAL) 2547 MoveZ = wx.SpinButton(dataDisplay,style=wx.SP_HORIZONTAL,size=wx.Size(100,20)) 2548 MoveZ.SetValue(0) 2549 MoveZ.SetRange(-1,1) 2550 MoveZ.Bind(wx.EVT_SPIN, OnMoveZ) 2551 MoveSizer.Add(MoveZ) 2552 slideSizer.Add(MoveSizer,1,wx.EXPAND|wx.RIGHT) 2507 2553 2508 2554 vdwScaleTxt = wx.StaticText(dataDisplay,-1,' van der Waals scale: '+'%.2f'%(drawingData['vdwScale'])) … … 2582 2628 2583 2629 def OnViewDir(event): 2584 event.Skip()2585 2630 Obj = event.GetEventObject() 2586 2631 viewDir = Obj.GetValue().split() … … 2588 2633 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 2589 2634 VD = np.array([float(viewDir[i]) for i in range(3)]) 2590 # VD= np.inner(Amat,VD)2591 V D /= np.sqrt(np.sum(VD**2))2635 VC = np.inner(Amat,VD) 2636 VC /= np.sqrt(np.sum(VC**2)) 2592 2637 V = np.array(drawingData['viewDir']) 2593 # V= np.inner(Amat,V)2594 V /= np.sqrt(np.sum(V**2))2595 A = acosd(np.sum(V*VD))2596 VX = np.cross(V,VD)2638 VB = np.inner(Amat,V) 2639 VB /= np.sqrt(np.sum(VB**2)) 2640 VX = np.cross(VC,VB) 2641 A = acosd(max((2.-np.sum((VB-VC)**2))/2.,-1.)) 2597 2642 QV = G2mth.AVdeg2Q(A,VX) 2598 2643 Q = drawingData['Quaternion'] -
trunk/GSASIIplot.py
r756 r757 2536 2536 panel = G2frame.dataDisplay.GetPage(page).GetChildren()[0].GetChildren() 2537 2537 names = [child.GetName() for child in panel] 2538 panel[names.index('viewPoint')].SetValue('%.3f , %.3f,%.3f'%(VP[0],VP[1],VP[2]))2538 panel[names.index('viewPoint')].SetValue('%.3f %.3f %.3f'%(VP[0],VP[1],VP[2])) 2539 2539 2540 2540 def SetViewDirText(VD): … … 2544 2544 panel = G2frame.dataDisplay.GetPage(page).GetChildren()[0].GetChildren() 2545 2545 names = [child.GetName() for child in panel] 2546 panel[names.index('viewDir')].SetValue('%.3f , %.3f,%.3f'%(VD[0],VD[1],VD[2]))2546 panel[names.index('viewDir')].SetValue('%.3f %.3f %.3f'%(VD[0],VD[1],VD[2])) 2547 2547 2548 2548 def SetMapPeaksText(mapPeaks):
Note: See TracChangeset
for help on using the changeset viewer.