- Timestamp:
- Mar 3, 2021 6:17:59 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r4823 r4838 260 260 self.onChange() 261 261 262 def MakeDrawAtom(data,atom):263 'Convert atom to format needed to draw it'264 generalData = data['General']265 deftype = G2obj.validateAtomDrawType(266 GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)267 if generalData['Type'] in ['nuclear','faulted',]:268 atomInfo = [atom[:2]+atom[3:6]+['1']+[deftype]+269 ['']+[[255,255,255]]+atom[9:]+[[],[]]][0]270 ct,cs = [1,8] #type & color271 atNum = generalData['AtomTypes'].index(atom[ct])272 atomInfo[cs] = list(generalData['Color'][atNum])273 return atomInfo262 # def MakeDrawAtom(data,atom): 263 # 'Convert atom to format needed to draw it' 264 # generalData = data['General'] 265 # deftype = G2obj.validateAtomDrawType( 266 # GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData) 267 # if generalData['Type'] in ['nuclear','faulted',]: 268 # atomInfo = [atom[:2]+atom[3:6]+['1']+[deftype]+ 269 # ['']+[[255,255,255]]+atom[9:]+[[],[]]][0] 270 # ct,cs = [1,8] #type & color 271 # atNum = generalData['AtomTypes'].index(atom[ct]) 272 # atomInfo[cs] = list(generalData['Color'][atNum]) 273 # return atomInfo 274 274 275 275 class ConstraintDialog(wx.Dialog): … … 2061 2061 atmData['Drawing']['Atoms'] = [] 2062 2062 for atom in atmData['Atoms']: 2063 atmData['Drawing']['Atoms'].append( MakeDrawAtom(atmData,atom))2063 atmData['Drawing']['Atoms'].append(G2mth.MakeDrawAtom(atmData,atom)) 2064 2064 2065 2065 def onCancel(event,page=0): -
trunk/GSASIImath.py
r4830 r4838 29 29 import GSASIIspc as G2spc 30 30 import GSASIIpwd as G2pwd 31 import GSASIIobj as G2obj 31 32 import GSASIIfiles as G2fil 32 33 import numpy.fft as fft … … 698 699 return {atom[indx]:iatm for iatm,atom in enumerate(atomData)} 699 700 701 def DrawAtomsReplaceByID(data,loc,atom,ID): 702 '''Replace all atoms in drawing array with an ID matching the specified value''' 703 atomData = data['Drawing']['Atoms'] 704 indx = FindAtomIndexByIDs(atomData,loc,[ID,]) 705 for ind in indx: 706 atomData[ind] = MakeDrawAtom(data,atom,atomData[ind]) 707 708 def MakeDrawAtom(data,atom,oldatom=None): 709 'needs a description' 710 AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE', 711 'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK'] 712 AA1letter = ['A','R','N','D','C','Q','E','G','H','I', 713 'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' '] 714 generalData = data['General'] 715 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 716 SGData = generalData['SGData'] 717 deftype = G2obj.validateAtomDrawType(GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData) 718 if generalData['Type'] in ['nuclear','faulted',]: 719 if oldatom: 720 opr = oldatom[5] 721 if atom[9] == 'A': 722 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17]) 723 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0] 724 else: 725 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6]) 726 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0] 727 else: 728 atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+ 729 ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0] 730 ct,cs = [1,8] #type & color 731 elif generalData['Type'] == 'magnetic': 732 if oldatom: 733 opr = oldatom[8] 734 mom = np.array(atom[7:10]) 735 if generalData['Super']: 736 SSGData = generalData['SSGData'] 737 Mom = G2spc.ApplyStringOpsMom(opr,SGData,SSGData,mom) 738 else: 739 Mom = G2spc.ApplyStringOpsMom(opr,SGData,None,mom) 740 if atom[12] == 'A': 741 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[14:20]) 742 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:14]+list(U)+oldatom[20:]][0] 743 else: 744 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6]) 745 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0] 746 else: 747 atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+ 748 ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0] 749 ct,cs = [1,11] #type & color 750 elif generalData['Type'] == 'macromolecular': 751 try: 752 oneLetter = AA3letter.index(atom[1]) 753 except ValueError: 754 oneLetter = -1 755 atomInfo = [[atom[1].strip()+atom[0],]+ 756 [AA1letter[oneLetter]+atom[0],]+atom[2:5]+ 757 atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0] 758 ct,cs = [4,11] #type & color 759 atNum = generalData['AtomTypes'].index(atom[ct]) 760 atomInfo[cs] = list(generalData['Color'][atNum]) 761 return atomInfo 762 700 763 def GetAtomsById(atomData,atomLookUp,IdList): 701 764 '''gets a list of atoms from Atom table that match a set of atom IDs … … 4124 4187 return Ind 4125 4188 4126 def PeaksUnique(data,Ind,Sel ):4189 def PeaksUnique(data,Ind,Sel,dlg): 4127 4190 '''Finds the symmetry unique set of peaks from those selected. Selects 4128 4191 the one closest to the center of the unit cell. … … 4133 4196 :param list Ind: list of selected peak indices 4134 4197 :param int Sel: selected column to find peaks closest to 4198 :param wx object dlg: progress bar dialog box 4135 4199 4136 4200 :returns: the list of symmetry unique peaks from among those given in Ind … … 4164 4228 Indx[jnd] = False 4165 4229 dups.append(jnd) 4166 # select the unique peak closest to cell center4167 4230 cntr = mapPeaks[ind][Sel] 4168 4231 icntr = ind … … 4172 4235 icntr = jnd 4173 4236 Unique.append(icntr) 4237 dlg.Update(ind,newmsg='Map peak no. %d processed'%ind) 4174 4238 return Unique 4175 4239 -
trunk/GSASIIphsGUI.py
r4836 r4838 1103 1103 1104 1104 #### Phase editing routines ################################################################################ 1105 def DrawAtomsReplaceByID(data,loc,atom,ID):1106 '''Replace all atoms in drawing array with an ID matching the specified value'''1107 atomData = data['Drawing']['Atoms']1108 indx = G2mth.FindAtomIndexByIDs(atomData,loc,[ID,])1109 for ind in indx:1110 atomData[ind] = MakeDrawAtom(data,atom,atomData[ind])1111 1112 def MakeDrawAtom(data,atom,oldatom=None):1113 'needs a description'1114 AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',1115 'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK']1116 AA1letter = ['A','R','N','D','C','Q','E','G','H','I',1117 'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' ']1118 generalData = data['General']1119 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])1120 SGData = generalData['SGData']1121 deftype = G2obj.validateAtomDrawType(GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)1122 if generalData['Type'] in ['nuclear','faulted',]:1123 if oldatom:1124 opr = oldatom[5]1125 if atom[9] == 'A':1126 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17])1127 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0]1128 else:1129 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])1130 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0]1131 else:1132 atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+1133 ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0]1134 ct,cs = [1,8] #type & color1135 elif generalData['Type'] == 'magnetic':1136 if oldatom:1137 opr = oldatom[8]1138 mom = np.array(atom[7:10])1139 if generalData['Super']:1140 SSGData = generalData['SSGData']1141 Mom = G2spc.ApplyStringOpsMom(opr,SGData,SSGData,mom)1142 else:1143 Mom = G2spc.ApplyStringOpsMom(opr,SGData,None,mom)1144 if atom[12] == 'A':1145 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[14:20])1146 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:14]+list(U)+oldatom[20:]][0]1147 else:1148 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])1149 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0]1150 else:1151 atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+1152 ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]1153 ct,cs = [1,11] #type & color1154 elif generalData['Type'] == 'macromolecular':1155 try:1156 oneLetter = AA3letter.index(atom[1])1157 except ValueError:1158 oneLetter = -11159 atomInfo = [[atom[1].strip()+atom[0],]+1160 [AA1letter[oneLetter]+atom[0],]+atom[2:5]+1161 atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]1162 ct,cs = [4,11] #type & color1163 atNum = generalData['AtomTypes'].index(atom[ct])1164 atomInfo[cs] = list(generalData['Color'][atNum])1165 return atomInfo1105 # def DrawAtomsReplaceByID(data,loc,atom,ID): 1106 # '''Replace all atoms in drawing array with an ID matching the specified value''' 1107 # atomData = data['Drawing']['Atoms'] 1108 # indx = G2mth.FindAtomIndexByIDs(atomData,loc,[ID,]) 1109 # for ind in indx: 1110 # atomData[ind] = MakeDrawAtom(data,atom,atomData[ind]) 1111 1112 # def MakeDrawAtom(data,atom,oldatom=None): 1113 # 'needs a description' 1114 # AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE', 1115 # 'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK'] 1116 # AA1letter = ['A','R','N','D','C','Q','E','G','H','I', 1117 # 'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' '] 1118 # generalData = data['General'] 1119 # Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 1120 # SGData = generalData['SGData'] 1121 # deftype = G2obj.validateAtomDrawType(GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData) 1122 # if generalData['Type'] in ['nuclear','faulted',]: 1123 # if oldatom: 1124 # opr = oldatom[5] 1125 # if atom[9] == 'A': 1126 # X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17]) 1127 # atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0] 1128 # else: 1129 # X = G2spc.ApplyStringOps(opr,SGData,atom[3:6]) 1130 # atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0] 1131 # else: 1132 # atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+ 1133 # ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0] 1134 # ct,cs = [1,8] #type & color 1135 # elif generalData['Type'] == 'magnetic': 1136 # if oldatom: 1137 # opr = oldatom[8] 1138 # mom = np.array(atom[7:10]) 1139 # if generalData['Super']: 1140 # SSGData = generalData['SSGData'] 1141 # Mom = G2spc.ApplyStringOpsMom(opr,SGData,SSGData,mom) 1142 # else: 1143 # Mom = G2spc.ApplyStringOpsMom(opr,SGData,None,mom) 1144 # if atom[12] == 'A': 1145 # X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[14:20]) 1146 # atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:14]+list(U)+oldatom[20:]][0] 1147 # else: 1148 # X = G2spc.ApplyStringOps(opr,SGData,atom[3:6]) 1149 # atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0] 1150 # else: 1151 # atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+ 1152 # ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0] 1153 # ct,cs = [1,11] #type & color 1154 # elif generalData['Type'] == 'macromolecular': 1155 # try: 1156 # oneLetter = AA3letter.index(atom[1]) 1157 # except ValueError: 1158 # oneLetter = -1 1159 # atomInfo = [[atom[1].strip()+atom[0],]+ 1160 # [AA1letter[oneLetter]+atom[0],]+atom[2:5]+ 1161 # atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0] 1162 # ct,cs = [4,11] #type & color 1163 # atNum = generalData['AtomTypes'].index(atom[ct]) 1164 # atomInfo[cs] = list(generalData['Color'][atNum]) 1165 # return atomInfo 1166 1166 1167 1167 def getAtomSelections(AtmTbl,cn=0,action='action',includeView=False,ask=True): … … 3318 3318 if 'Atoms' in data['Drawing'] and replot: 3319 3319 ci = colLabels.index('I/A') 3320 DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)3320 G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[r],ID) 3321 3321 G2plt.PlotStructure(G2frame,data) 3322 3322 if SGData['SpGrp'] != 'P 1': #no need to update P 1 structures! … … 3343 3343 ID = atomData[r][ci+8] 3344 3344 if 'Atoms' in data['Drawing']: 3345 DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)3345 G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[r],ID) 3346 3346 G2plt.PlotStructure(G2frame,data) 3347 3347 SetupGeneral() … … 3507 3507 SetPhaseWindow(Atoms,Scroll=Atoms.GetScrollPos(wx.VERTICAL)) 3508 3508 3509 #### onSetOrigin.3509 #### FillAtomsGrid main code 3510 3510 if not data['Drawing']: #if new drawing - no drawing data! 3511 3511 SetupDrawingData() … … 3809 3809 FillAtomsGrid(Atoms) 3810 3810 ID = atomData[indx[0]][ci+8] 3811 DrawAtomsReplaceByID(data,ci+8,atomData[indx[0]],ID)3811 G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[indx[0]],ID) 3812 3812 G2plt.PlotStructure(G2frame,data) 3813 3813 event.StopPropagation() … … 3949 3949 for r in indx: 3950 3950 ID = atomData[r][ci+8] 3951 DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)3951 G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[r],ID) 3952 3952 FillAtomsGrid(Atoms) 3953 3953 dlg.Destroy() … … 7518 7518 7519 7519 def DrawAtomAdd(drawingData,atom): 7520 drawingData['Atoms'].append( MakeDrawAtom(data,atom))7520 drawingData['Atoms'].append(G2mth.MakeDrawAtom(data,atom)) 7521 7521 7522 7522 def OnRestraint(event): … … 8520 8520 for atom in atomData: 8521 8521 ID = atom[ci+8] 8522 DrawAtomsReplaceByID(data,ci+8,atom,ID)8522 G2mth.DrawAtomsReplaceByID(data,ci+8,atom,ID) 8523 8523 UpdateDrawAtoms() 8524 8524 drawAtoms.ClearSelection() … … 10570 10570 for atom in atomData: 10571 10571 ID = atom[cia+8] 10572 DrawAtomsReplaceByID(data,cia+8,atom,ID)10572 G2mth.DrawAtomsReplaceByID(data,cia+8,atom,ID) 10573 10573 FindBondsDraw(data) 10574 10574 G2plt.PlotStructure(G2frame,data,False) … … 12491 12491 return 12492 12492 wx.BeginBusyCursor() 12493 pgbar = wx.ProgressDialog('Unique peaks','Map peak no. 0 processed',len(Ind)+1, 12494 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 12495 12493 12496 try: 12494 Ind = G2mth.PeaksUnique(data,Ind,sel )12497 Ind = G2mth.PeaksUnique(data,Ind,sel,pgbar) 12495 12498 print (' No. unique peaks: %d Unique peak fraction: %.3f'%(len(Ind),float(len(Ind))/len(mapPeaks))) 12496 12499 tbl = MapPeaks.GetTable().data
Note: See TracChangeset
for help on using the changeset viewer.