Changeset 4479
- Timestamp:
- Jun 10, 2020 9:10:31 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r4431 r4479 3934 3934 3935 3935 def PeaksUnique(data,Ind): 3936 '''Finds the symmetry unique set of peaks from those selected. Works on the 3937 contents of data['Map Peaks']. 3936 '''Finds the symmetry unique set of peaks from those selected. Selects 3937 the one closest to the center of the unit cell. 3938 Works on the contents of data['Map Peaks']. Called from OnPeaksUnique in 3939 GSASIIphsGUI.py, 3938 3940 3939 3941 :param data: the phase data structure 3940 3942 :param list Ind: list of selected peak indices 3943 3941 3944 :returns: the list of symmetry unique peaks from among those given in Ind 3942 3943 3945 ''' 3944 3946 # XYZE = np.array([[equiv[0] for equiv in G2spc.GenAtom(xyz[1:4],SGData,Move=True)] for xyz in mapPeaks]) #keep this!! … … 3953 3955 SGData = generalData['SGData'] 3954 3956 mapPeaks = data['Map Peaks'] 3955 Indx = {} 3956 XYZ = {} 3957 for ind in Ind: 3958 XYZ[ind] = np.array(mapPeaks[ind][1:4]) 3959 Indx[ind] = True 3957 XYZ = {ind:np.array(mapPeaks[ind][1:4]) for ind in Ind} 3958 Indx = [True for ind in Ind] 3959 Unique = [] 3960 # scan through peaks, finding all peaks equivalent to peak ind 3960 3961 for ind in Ind: 3961 3962 if Indx[ind]: 3962 3963 xyz = XYZ[ind] 3964 dups = [] 3963 3965 for jnd in Ind: 3964 if ind != jnd and Indx[jnd]: 3966 # only consider peaks we have not looked at before 3967 # and were not already found to be equivalent 3968 if jnd > ind and Indx[jnd]: 3965 3969 Equiv = G2spc.GenAtom(XYZ[jnd],SGData,Move=True) 3966 3970 xyzs = np.array([equiv[0] for equiv in Equiv]) 3967 Indx[jnd] = noDuplicate(xyz,xyzs,Amat) 3968 Ind = [] 3969 for ind in Indx: 3970 if Indx[ind]: 3971 Ind.append(ind) 3972 return Ind 3971 if not noDuplicate(xyz,xyzs,Amat): 3972 Indx[jnd] = False 3973 dups.append(jnd) 3974 # select the unique peak closest to cell center 3975 cntr = mapPeaks[ind][-1] 3976 icntr = ind 3977 for jnd in dups: 3978 if mapPeaks[jnd][-1] < cntr: 3979 cntr = mapPeaks[jnd][-1] 3980 icntr = jnd 3981 Unique.append(icntr) 3982 return Unique 3973 3983 3974 3984 ################################################################################ -
trunk/GSASIIphsGUI.py
r4476 r4479 1403 1403 'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':True, 1404 1404 'showABC':True,'selectedAtoms':[],'Atoms':[],'oldxy':[],'magMult':1.0, 1405 'bondList':{},'viewDir':[1,0,0],'Plane':[[0,0,1],False,False,0.0,[255,255,0]]} 1405 'bondList':{},'viewDir':[1,0,0],'Plane':[[0,0,1],False,False,0.0,[255,255,0]], 1406 'peakMoveView':True,'PeakDistRadius':0.0, 1407 'atomsExpandRadius':5.,'atomsDistRadius':2.5, 1408 } 1406 1409 for key in defaultDrawing: 1407 1410 if key not in drawingData: drawingData[key] = defaultDrawing[key] … … 8727 8730 drawOptions.GetSizer().Clear(True) 8728 8731 mainSizer = wx.BoxSizer(wx.VERTICAL) 8729 mainSizer.Add((5,5),0)8730 mainSizer.Add(wx.StaticText(drawOptions,-1,' Drawing controls:'),0,WACV)8731 mainSizer.Add((5,5),0)8732 #mainSizer.Add(wx.StaticText(drawOptions,-1,' Drawing controls'),0, 8733 # wx.ALL|wx.CENTER) 8734 #G2G.HorizontalLine(mainSizer,drawOptions) 8732 8735 mainSizer.Add(SlopSizer(),0) 8733 mainSizer.Add((5,5),0)8736 G2G.HorizontalLine(mainSizer,drawOptions) 8734 8737 mainSizer.Add(ShowSizer(),0,) 8735 mainSizer.Add((5,5),0)8738 G2G.HorizontalLine(mainSizer,drawOptions) 8736 8739 mainSizer.Add(RadSizer(),0,) 8737 mainSizer.Add((5,5),0)8740 G2G.HorizontalLine(mainSizer,drawOptions) 8738 8741 mainSizer.Add(PlaneSizer(),0,) 8742 G2G.HorizontalLine(mainSizer,drawOptions) 8743 mainSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY, 8744 'On map peak selection:'),0,WACV) 8745 mainSizer.Add(G2G.G2CheckBox(drawOptions,'Move view point', 8746 drawingData,'peakMoveView')) 8747 mapSizer = wx.FlexGridSizer(0,3,5,5) 8748 mapSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY,'Show Map points within:'),0,WACV) 8749 mapSizer.Add(G2G.ValidatedTxtCtrl(drawOptions,drawingData,'PeakDistRadius', 8750 min=0.0,max=5.0,nDig=(10,1),size=(50,-1))) 8751 mapSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY,u"\u212B"),0,WACV) 8752 mapSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY,'Show atoms within:'),0,WACV) 8753 mapSizer.Add(G2G.ValidatedTxtCtrl(drawOptions,drawingData,'atomsExpandRadius', 8754 min=0.0,max=15.0,nDig=(10,1),size=(50,-1))) 8755 mapSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY,u"\u212B"),0,WACV) 8756 mapSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY,'Label distance to atoms within:'),0,WACV) 8757 mapSizer.Add(G2G.ValidatedTxtCtrl(drawOptions,drawingData,'atomsDistRadius', 8758 min=0.0,max=15.0,nDig=(10,1),size=(50,-1))) 8759 mapSizer.Add(wx.StaticText(drawOptions,wx.ID_ANY,u"\u212B"),0,WACV) 8760 mainSizer.Add(mapSizer) 8739 8761 SetPhaseWindow(drawOptions,mainSizer) 8740 8762 … … 11470 11492 elif c < 0: #only row clicks 11471 11493 if event.ControlDown(): 11472 if r in MapPeaks.GetSelectedRows():11494 if r in getAtomSelections(MapPeaks): 11473 11495 MapPeaks.DeselectRow(r) 11474 11496 else: 11475 11497 MapPeaks.SelectRow(r,True) 11476 11498 elif event.ShiftDown(): 11477 indxs = MapPeaks.GetSelectedRows()11499 indxs = getAtomSelections(MapPeaks) 11478 11500 MapPeaks.ClearSelection() 11479 11501 ibeg = 0 … … 11498 11520 G2plt.PlotStructure(G2frame,data) 11499 11521 11522 # beginning of FillMapPeaksGrid() 11523 #import imp # debug code 11524 #imp.reload(G2plt) # debug code 11500 11525 G2frame.GetStatusBar().SetStatusText('',1) 11501 11526 if 'Map Peaks' in data: … … 11520 11545 mapPeaks = np.array(data['Map Peaks']) 11521 11546 peakMax = np.amax(mapPeaks.T[0]) 11522 Ind = MapPeaks.GetSelectedRows()11547 Ind = getAtomSelections(MapPeaks) 11523 11548 for ind in Ind: 11524 11549 mag,x,y,z = mapPeaks[ind][:4] … … 11556 11581 if 'Map Peaks' in data: 11557 11582 mapPeaks = data['Map Peaks'] 11558 Ind = MapPeaks.GetSelectedRows()11583 Ind = getAtomSelections(MapPeaks) 11559 11584 Ind.sort() 11560 11585 Ind.reverse() … … 11581 11606 def OnPeaksEquiv(event): 11582 11607 if 'Map Peaks' in data: 11583 Ind = MapPeaks.GetSelectedRows()11608 Ind = getAtomSelections(MapPeaks) 11584 11609 if Ind: 11585 11610 wx.BeginBusyCursor() … … 11609 11634 if 'Map Peaks' in data: 11610 11635 mapPeaks = data['Map Peaks'] 11611 Ind = MapPeaks.GetSelectedRows()11636 Ind = getAtomSelections(MapPeaks) 11612 11637 if Ind: 11613 11638 wx.BeginBusyCursor() … … 11615 11640 Ind = G2mth.PeaksUnique(data,Ind) 11616 11641 print (' No. unique peaks: %d Unique peak fraction: %.3f'%(len(Ind),float(len(Ind))/len(mapPeaks))) 11642 tbl = MapPeaks.GetTable().data 11643 tbl[:] = [t for i,t in enumerate(tbl) if i in Ind] + [ 11644 t for i,t in enumerate(tbl) if i not in Ind] 11617 11645 for r in range(MapPeaks.GetNumberRows()): 11618 if r in Ind:11646 if r < len(Ind): 11619 11647 MapPeaks.SelectRow(r,addToSelected=True) 11620 11648 else: … … 11622 11650 finally: 11623 11651 wx.EndBusyCursor() 11652 MapPeaks.ForceRefresh() 11624 11653 G2plt.PlotStructure(G2frame,data) 11625 11654 11626 11655 def OnPeaksViewPoint(event): 11627 11656 # set view point 11628 indx = MapPeaks.GetSelectedRows()11657 indx = getAtomSelections(MapPeaks) 11629 11658 if not indx: 11630 11659 G2frame.ErrorDialog('Set viewpoint','No peaks selected') … … 11637 11666 def OnPeaksDistVP(event): 11638 11667 # distance to view point 11639 indx = MapPeaks.GetSelectedRows()11668 indx = getAtomSelections(MapPeaks) 11640 11669 if not indx: 11641 11670 G2frame.ErrorDialog('Peak distance','No peaks selected') … … 11658 11687 def OnPeaksDA(event): 11659 11688 #distance, angle 11660 indx = MapPeaks.GetSelectedRows()11689 indx = getAtomSelections(MapPeaks) 11661 11690 if len(indx) not in [2,3]: 11662 11691 G2frame.ErrorDialog('Peak distance/angle','Wrong number of atoms for distance or angle calculation') -
trunk/GSASIIplot.py
r4470 r4479 8928 8928 Zclip = drawingData['Zclip']*cPos/200. 8929 8929 Q = drawingData['Quaternion'] 8930 # Move view point on selection of a single peak, if enabled 8931 if pageName == 'Map peaks' and len(Ind) == 1 and drawingData['peakMoveView']: 8932 ind = Ind[0] 8933 mag,x,y,z = mapPeaks[:,:4][ind] 8934 drawingData['viewPoint'][0][:] = [x,y,z] 8930 8935 Tx,Ty,Tz = drawingData['viewPoint'][0] 8931 8936 cx,ct,cs,ci = drawingData['atomPtrs'] … … 9078 9083 if not FourD and len(rhoXYZ): #no green dot map for 4D - it's wrong! 9079 9084 RenderMap(rho,rhoXYZ,indx,Rok) 9080 if len(mapPeaks): 9085 if len(Ind) == 1 and pageName == 'Map peaks': 9086 # one peak has been selected, show as selected by draw options 9087 PeakDistRadius = drawingData['PeakDistRadius'] 9088 atomsExpandRadius = drawingData['atomsExpandRadius'] 9089 atomsdistRadius = drawingData['atomsDistRadius'] 9090 ind = Ind[0] 9091 mag,x,y,z = mapPeaks[:,:4][ind] 9092 RenderMapPeak(x,y,z,Gr,1.0) 9093 # distances to other peaks within PeakDistRadius A 9094 if PeakDistRadius > 0: 9095 XYZ = mapPeaks.T[1:4].T 9096 Dx = XYZ-(x,y,z) 9097 dist = np.sqrt(np.sum(np.inner(Dx,Amat)**2,axis=1)) 9098 for i in ma.nonzero(ma.masked_greater(dist,PeakDistRadius))[0]: 9099 lbl = '{:.2f}'.format(dist[i]) 9100 RenderLines(x,y,z,[Dx[i]],Gr) 9101 lx,ly,lz = (x,y,z)+(Dx[i]/2) 9102 RenderLabel(lx,ly,lz,lbl,radius,wxGreen,matRot) 9103 [mag,x1,y1,z1] = mapPeaks[:,:4][i] 9104 if mag > 0.: 9105 RenderMapPeak(x1,y1,z1,Wt,mag/peakMax) 9106 else: 9107 RenderMapPeak(x1,y1,z1,Or,-2*mag/peakMax) 9108 # find and display atoms within atomsExpandRadius A 9109 if atomsExpandRadius > 0: 9110 xyzA = np.array((x,y,z)) 9111 cx,ct,cs,ci = G2phG.getAtomPtrs(data) 9112 cellArray = G2lat.CellBlock(1) 9113 radDict = dict(zip(*G2phG.getAtomRadii(data))) 9114 Names = [] 9115 Atoms = [] 9116 Radii = [] 9117 Color = [] 9118 for atomB in data['Atoms']: 9119 xyzB = np.array(atomB[cx:cx+3]) 9120 color = np.array(generalData['Color'][generalData['AtomTypes'].index(atomB[ct])])/255. 9121 result = G2spc.GenAtom(xyzB,SGData,False,6*[0.],True) 9122 for item in result: 9123 for xyz in cellArray+np.array(item[0]): 9124 dist = np.sqrt(np.sum(np.inner(Amat,xyz-xyzA)**2)) 9125 if 0 < dist <= max(atomsdistRadius,atomsExpandRadius): 9126 ax,ay,az = xyz 9127 RenderSphere(ax,ay,az,radius,color) 9128 Atoms.append(xyz) 9129 Radii.append(radDict[atomB[ct]]) 9130 Names.append(atomB[0]) 9131 Color.append(color) 9132 if dist < atomsdistRadius: 9133 RenderLines(x,y,z,[xyz-xyzA],Gr) 9134 lx,ly,lz = (xyzA+xyz)/2 9135 lbl = '{:.2f}'.format(dist) 9136 RenderLabel(lx,ly,lz,lbl,radius,wxGreen,matRot) 9137 ax,ay,az = xyz 9138 RenderLabel(ax,ay,az,' '+atomB[0],radius,wxGreen,matRot) 9139 # find bonds 9140 bondData = [[] for i in range(len(Atoms))] 9141 Atoms = np.array(Atoms) 9142 Radii = np.array(Radii) 9143 for i,atom in enumerate(Atoms): 9144 Dx = Atoms-atom 9145 sumR = Radii + Radii[i] 9146 dist = ma.masked_less(np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0)),0.5) 9147 IndB = ma.nonzero(ma.masked_greater(dist-data['Drawing']['radiusFactor']*sumR,0.)) #get indices of bonded atoms 9148 for j in IndB[0]: 9149 bondData[i].append(Dx[j]*Radii[i]/sumR[j]) 9150 bondData[j].append(-Dx[j]*Radii[j]/sumR[j]) 9151 # draw bonds 9152 bondR = drawingData['bondRadius'] 9153 for i,xyz in enumerate(Atoms): 9154 ax,ay,az = xyz 9155 RenderBonds(ax,ay,az,bondData[i],bondR,Color[i]) 9156 elif len(mapPeaks): 9081 9157 XYZ = mapPeaks.T[1:4].T 9082 9158 mapBonds = FindPeaksBonds(XYZ)
Note: See TracChangeset
for help on using the changeset viewer.