 Timestamp:
 Oct 19, 2020 5:09:16 PM (14 months ago)
 Location:
 trunk
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIconstrGUI.py
r4606 r4608 1582 1582 UseList = newPhase['Histograms'] 1583 1583 detTrans = np.abs(nl.det(Trans)) 1584 invTrans = nl.inv(Trans)1585 1584 opId = oldPhase['pId'] 1586 1585 npId = newPhase['pId'] 1587 1586 cx,ct,cs,cia = newPhase['General']['AtomPtrs'] 1588 1587 nAtoms = newPhase['Atoms'] 1589 oSGData = oldPhase['General']['SGData']1590 1588 nSGData = newPhase['General']['SGData'] 1591 1589 #oAcof = G2lat.cell2A(oldPhase['General']['Cell'][1:7]) … … 1671 1669 # constraints on lattice parameters between phases 1672 1670 # T = nl.inv(Trans).T 1673 T = Trans.T1674 conMat = [1675 [T[0,0]**2,T[0,1]**2,T[0,2]**2,T[0,0]*T[0,1],T[0,0]*T[0,2],T[0,1]*T[0,2]],1676 [T[1,0]**2,T[1,1]**2,T[1,2]**2,T[1,0]*T[1,1],T[1,0]*T[1,2],T[1,1]*T[1,2]],1677 [T[2,0]**2,T[2,1]**2,T[2,2]**2,T[2,0]*T[2,1],T[2,0]*T[2,2],T[2,1]*T[2,2]],1678 [2.*T[0,0]*T[1,0],2.*T[0,1]*T[1,1],2.*T[0,2]*T[1,2],T[0,0]*T[1,1]+T[0,1]*T[1,0],T[0,0]*T[1,2]+T[0,2]*T[1,0],T[0,1]*T[1,2]+T[0,2]*T[1,1]],1679 [2.*T[0,0]*T[2,0],2.*T[0,1]*T[2,1],2.*T[0,2]*T[2,2],T[0,0]*T[2,1]+T[0,1]*T[2,0],T[0,0]*T[2,2]+T[0,2]*T[2,0],T[0,1]*T[2,2]+T[0,2]*T[2,1]],1680 [2.*T[1,0]*T[2,0],2.*T[1,1]*T[2,1],2.*T[1,2]*T[2,2],T[1,0]*T[2,1]+T[1,1]*T[2,0],T[1,0]*T[2,2]+T[1,2]*T[2,0],T[1,1]*T[2,2]+T[1,2]*T[2,1]]1681 ]1671 # T = Trans.T 1672 # conMat = [ 1673 # [T[0,0]**2,T[0,1]**2,T[0,2]**2,T[0,0]*T[0,1],T[0,0]*T[0,2],T[0,1]*T[0,2]], 1674 # [T[1,0]**2,T[1,1]**2,T[1,2]**2,T[1,0]*T[1,1],T[1,0]*T[1,2],T[1,1]*T[1,2]], 1675 # [T[2,0]**2,T[2,1]**2,T[2,2]**2,T[2,0]*T[2,1],T[2,0]*T[2,2],T[2,1]*T[2,2]], 1676 # [2.*T[0,0]*T[1,0],2.*T[0,1]*T[1,1],2.*T[0,2]*T[1,2],T[0,0]*T[1,1]+T[0,1]*T[1,0],T[0,0]*T[1,2]+T[0,2]*T[1,0],T[0,1]*T[1,2]+T[0,2]*T[1,1]], 1677 # [2.*T[0,0]*T[2,0],2.*T[0,1]*T[2,1],2.*T[0,2]*T[2,2],T[0,0]*T[2,1]+T[0,1]*T[2,0],T[0,0]*T[2,2]+T[0,2]*T[2,0],T[0,1]*T[2,2]+T[0,2]*T[2,1]], 1678 # [2.*T[1,0]*T[2,0],2.*T[1,1]*T[2,1],2.*T[1,2]*T[2,2],T[1,0]*T[2,1]+T[1,1]*T[2,0],T[1,0]*T[2,2]+T[1,2]*T[2,0],T[1,1]*T[2,2]+T[1,2]*T[2,1]] 1679 # ] 1682 1680 # Gnew = conMat * A: 1683 1681 # T00**2*a0 T01**2*a1 T02**2*a2 T00*T01*a3 T00*T02*a4 T01*T02*a5 … … 2040 2038 generalData['Isotope'][atom[ct]] = isotope 2041 2039 generalData['Color'].append(Info['Color']) 2042 if generalData['Type'] == 'magnetic':2043 if len(landeg) < len(generalData['AtomTypes']):2044 landeg.append(2.0)2040 # if generalData['Type'] == 'magnetic': 2041 # if len(landeg) < len(generalData['AtomTypes']): 2042 # landeg.append(2.0) 2045 2043 atmData['Drawing']['Atoms'] = [] 2046 2044 for atom in atmData['Atoms']: … … 2311 2309 if obj.ExportSelect(): # set export parameters; ask for file name 2312 2310 return 2313 fp =obj.OpenFile()2311 obj.OpenFile() 2314 2312 obj.Write(str(count)) 2315 2313 obj.Write('') … … 2338 2336 data['Vector'][rbid] = rb 2339 2337 data['RBIds']['Vector'].append(rbid) 2340 AtInfo = data['Vector']['AtInfo']2341 2338 for t in rb['rbTypes']: 2342 2339 if t in data['Vector']['AtInfo']: continue … … 2370 2367 'rbSeq':[],'SelSeq':[0,0],'useCount':0} 2371 2368 data['RBIds']['Residue'].append(rbid) 2372 AtInfo = data['Residue']['AtInfo']2373 2369 for t in rbTypes: 2374 2370 if t in data['Residue']['AtInfo']: continue … … 2386 2382 G2frame.rbBook.AddPage(RBImp,pagename) 2387 2383 G2frame.rbBook.SetSelection(G2frame.rbBook.FindPage(pagename)) 2388 generalData = rd.Phase['General']2389 2384 AtInfo = {} 2390 ct = 12391 2385 for t in rd.Phase['RBtypes']: 2392 2386 if t in AtInfo: continue … … 2512 2506 export and for plotting 2513 2507 ''' 2514 nTrans = 12515 2508 vecMag = [1.0] 2516 2509 vecRef = [False] … … 2567 2560 filename = filelist[0] 2568 2561 rd = reader 2569 with open(filename, 'Ur') as fp:2562 with open(filename, 'Ur'): 2570 2563 rd.ReInitialize() 2571 2564 rd.errors = "" … … 2580 2573 rd.objname = os.path.basename(filename) 2581 2574 try: 2582 flag =rd.Reader(filename)2575 rd.Reader(filename) 2583 2576 except Exception as msg: 2584 2577 G2fl.G2Print("Warning: read of file {} failed\n{}".format( … … 2946 2939 '''Display & edit a selected Vector RB 2947 2940 ''' 2941 global resRBsel 2948 2942 def rbNameSizer(rbid,rbData): 2949 2943 … … 2952 2946 Obj = event.GetEventObject() 2953 2947 name = Obj.GetValue() 2948 if name == rbData['RBname']: return # no change 2954 2949 namelist = [data['Vector'][key]['RBname'] for key in 2955 2950 data['Vector'] if 'RBname' in data['Vector'][key]] 2956 2951 name = G2obj.MakeUniqueLabel(name,namelist) 2957 2952 rbData['RBname'] = name 2953 wx.CallAfter(UpdateVectorRB) 2958 2954 2959 2955 def OnDelRB(event): … … 2965 2961 rbData['useCount'] = 1 2966 2962 wx.CallAfter(UpdateVectorRB) 2963 2967 2964 def OnPlotRB(event): 2968 Obj = event.GetEventObject()2969 2965 G2plt.PlotRigidBody(G2frame,'Vector',AtInfo,rbData,plotDefaults) 2970 2966 2967 # start of rbNameSizer 2971 2968 nameSizer = wx.BoxSizer(wx.HORIZONTAL) 2972 2969 nameSizer.Add(wx.StaticText(VectorRBDisplay,1,'Rigid body name: '),0,WACV) 2973 2970 RBname = wx.TextCtrl(VectorRBDisplay,1,rbData['RBname']) 2974 Indx[RBname.GetId()] = rbid2975 2971 RBname.Bind(wx.EVT_LEAVE_WINDOW, OnRBName) 2976 2972 RBname.Bind(wx.EVT_TEXT_ENTER,OnRBName) … … 3138 3134 refChoice[rbid][i].sort() 3139 3135 3136 def OnRBSelect(event): 3137 global resRBsel 3138 sel = rbSelect.GetSelection() 3139 if sel == 0: return # 1st entry is blank 3140 rbname = rbchoice[sel1] 3141 resRBsel = RBnames[rbname] 3142 wx.CallLater(100,UpdateVectorRB) 3143 3140 3144 # beginning of UpdateVectorRB 3141 3145 AtInfo = data['Vector']['AtInfo'] 3142 3146 refChoice = {} 3147 RefObjs = [] 3148 3149 GS = VectorRBDisplay.GetSizer() 3150 if GS: 3151 try: #get around a c++ error in wx 4.0; doing is again seems to be OK 3152 GS.Clear(True) 3153 except: 3154 GS.Clear(True) 3155 3156 RBnames = {} 3157 for rbid in data['RBIds']['Vector']: 3158 RBnames.update({data['Vector'][rbid]['RBname']:rbid,}) 3159 if not RBnames: 3160 return 3161 rbchoice = list(RBnames.keys()) 3162 rbchoice.sort() 3163 if GS: 3164 VectorRBSizer = GS 3165 else: 3166 VectorRBSizer = wx.BoxSizer(wx.VERTICAL) 3167 if resRBsel not in data['RBIds']['Vector']: 3168 resRBsel = RBnames[rbchoice[0]] 3169 if len(RBnames) > 1: 3170 selSizer = wx.BoxSizer(wx.HORIZONTAL) 3171 selSizer.Add(wx.StaticText(VectorRBDisplay,label=' Select rigid body to view:'),0) 3172 rbSelect = wx.ComboBox(VectorRBDisplay,choices=['']+rbchoice) 3173 name = data['Vector'][resRBsel]['RBname'] 3174 rbSelect.SetSelection(1+rbchoice.index(name)) 3175 rbSelect.Bind(wx.EVT_COMBOBOX,OnRBSelect) 3176 selSizer.Add(rbSelect,0) 3177 VectorRBSizer.Add(selSizer,0) 3178 rbData = data['Vector'][resRBsel] 3143 3179 if 'DELETED' in str(G2frame.GetStatusBar()): #seems to be no other way to do this (wx bug) 3144 3180 if GSASIIpath.GetConfigValue('debug'): … … 3146 3182 return 3147 3183 SetStatusLine(' You may use e.g. "c60" or "s60" for a vector entry') 3148 if VectorRB.GetSizer(): VectorRB.GetSizer().Clear(True) 3149 VectorRBSizer = wx.BoxSizer(wx.VERTICAL) 3150 first = True 3151 for rbid in data['RBIds']['Vector']: 3152 if rbid == 'AtInfo': continue 3153 rbData = data['Vector'][rbid] 3154 FillRefChoice(rbid,rbData) 3155 if not first: 3156 G2G.HorizontalLine(VectorRBSizer,VectorRBDisplay) 3157 VectorRBSizer.Add(rbNameSizer(rbid,rbData),0) 3158 VectorRBSizer.Add(rbRefAtmSizer(rbid,rbData),0) 3159 XYZ = np.array([[0.,0.,0.] for Ty in rbData['rbTypes']]) 3160 for imag,mag in enumerate(rbData['VectMag']): 3161 XYZ += mag*rbData['rbVect'][imag] 3162 VectorRBSizer.Add(rbVectMag(rbid,imag,rbData),0) 3163 VectorRBSizer.Add(rbVectors(rbid,imag,mag,XYZ,rbData),0) 3164 VectorRBSizer.Add((5,5),0) 3165 data['Vector'][rbid]['rbXYZ'] = XYZ 3166 first = False 3184 FillRefChoice(resRBsel,rbData) 3185 VectorRBSizer.Add(rbNameSizer(resRBsel,rbData),0) 3186 VectorRBSizer.Add(rbRefAtmSizer(resRBsel,rbData),0) 3187 XYZ = np.array([[0.,0.,0.] for Ty in rbData['rbTypes']]) 3188 for imag,mag in enumerate(rbData['VectMag']): 3189 XYZ += mag*rbData['rbVect'][imag] 3190 VectorRBSizer.Add(rbVectMag(rbid,imag,rbData),0) 3191 VectorRBSizer.Add(rbVectors(rbid,imag,mag,XYZ,rbData),0) 3192 VectorRBSizer.Add((5,5),0) 3193 data['Vector'][rbid]['rbXYZ'] = XYZ 3194 3195 VectorRBSizer.Add((5,25),) 3167 3196 VectorRBSizer.Layout() 3168 3197 VectorRBDisplay.SetSizer(VectorRBSizer,True) 3198 VectorRBDisplay.SetAutoLayout(True) 3169 3199 Size = VectorRBSizer.GetMinSize() 3200 VectorRBDisplay.SetSize(Size) 3201 3170 3202 Size[0] += 40 3171 3203 Size[1] = max(Size[1],450) + 20 3172 VectorRB Display.SetSize(Size)3204 VectorRB.SetSize(Size) 3173 3205 VectorRB.SetScrollbars(10,10,Size[0]/104,Size[1]/101) 3174 VectorRB.Scroll(0,Scroll) 3206 G2frame.dataWindow.SendSizeEvent() 3207 3208 VectorRBDisplay.Show() 3209 3175 3210 3176 3211 def UpdateResidueRB(): … … 3179 3214 global resRBsel 3180 3215 def rbNameSizer(rbid,rbData): 3216 3181 3217 def OnRBName(event): 3182 3218 event.Skip() … … 3217 3253 3218 3254 def OnPlotRB(event): 3219 Obj = event.GetEventObject()3220 3255 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) 3221 3256 3222 3257 # start of rbNameSizer 3223 3258 nameSizer = wx.BoxSizer(wx.HORIZONTAL) 3224 nameSizer.Add(wx.StaticText(ResidueRBDisplay,1,'Residue name: '), 3225 0,WACV) 3259 nameSizer.Add(wx.StaticText(ResidueRBDisplay,1,'Residue name: '),0,WACV) 3226 3260 RBname = wx.TextCtrl(ResidueRBDisplay,1,rbData['RBname']) 3227 3261 RBname.Bind(wx.EVT_LEAVE_WINDOW, OnRBName) … … 3236 3270 nameSizer.Add((5,0),) 3237 3271 if not rbData['useCount']: 3238 delRB = wx.Button(ResidueRBDisplay,wx.ID_ANY,"Delete", 3239 style=wx.BU_EXACTFIT) 3272 delRB = wx.Button(ResidueRBDisplay,wx.ID_ANY,"Delete",style=wx.BU_EXACTFIT) 3240 3273 delRB.Bind(wx.EVT_BUTTON, OnDelRB) 3241 3274 Indx[delRB.GetId()] = rbid 3242 3275 nameSizer.Add(delRB,0,WACV) 3243 3276 if 'H' in rbData['rbTypes']: 3244 stripH = wx.Button(ResidueRBDisplay,wx.ID_ANY, 3245 "Strip Hatoms", 3246 style=wx.BU_EXACTFIT) 3277 stripH = wx.Button(ResidueRBDisplay,wx.ID_ANY,"Strip Hatoms",style=wx.BU_EXACTFIT) 3247 3278 stripH.Bind(wx.EVT_BUTTON, OnStripH) 3248 3279 Indx[stripH.GetId()] = rbid … … 3277 3308 except ValueError: 3278 3309 pass 3310 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) 3279 3311 3280 3312 def OnRefSel(event): … … 3293 3325 if not iref: #origin change 3294 3326 rbXYZ = rbXYZ[ind] 3295 #TODO  transform all atom XYZ by axis choices3296 3327 Xxyz = rbXYZ[rbData['rbRef'][1]] 3297 3328 X = Xxyz/np.sqrt(np.sum(Xxyz**2)) … … 3510 3541 rbname = rbchoice[sel1] 3511 3542 resRBsel = RBnames[rbname] 3543 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) 3512 3544 wx.CallLater(100,UpdateResidueRB) 3513 3545 
trunk/GSASIIphsGUI.py
r4605 r4608 10106 10106 return vecrbSizer 10107 10107 10108 def On Select(event):10108 def OnVecSelect(event): 10109 10109 rbId = select.GetSelection() 10110 wx.CallLater(100,RepaintRBInfo, rbId)10110 wx.CallLater(100,RepaintRBInfo,'Vector',rbId) 10111 10111 10112 def RepaintRBInfo(rbId,Scroll=0): 10112 def OnResSelect(event): 10113 rbId = select.GetSelection() 10114 wx.CallLater(100,RepaintRBInfo,'Residue',rbId) 10115 10116 def RepaintRBInfo(rbType,rbId,Scroll=0): 10113 10117 oldFocus = wx.Window.FindFocus() 10114 10118 if 'phoenix' in wx.version(): … … 10117 10121 G2frame.bottomSizer.DeleteWindows() 10118 10122 Indx.clear() 10119 rbObj = data['RBModels'][ 'Residue'][rbId]10123 rbObj = data['RBModels'][rbType][rbId] 10120 10124 data['Drawing']['viewPoint'][0] = rbObj['Orig'][0] 10121 10125 Quad = rbObj['Orient'][0] … … 10161 10165 RBnames = [] 10162 10166 for RBObj in data['RBModels']['Residue']: 10163 # RBnames.append(RBObj['RBname'].split(':')[0]+RBObj['numChain'])10164 10167 RBnames.append(RBObj['RBname']+RBObj['numChain']) 10165 10168 rbName = RBnames[0] … … 10170 10173 select.SetSelection(RBnames.index(rbName)) 10171 10174 select.SetFirstItem(RBnames.index(rbName)) 10172 select.Bind(wx.EVT_LISTBOX,On Select)10175 select.Bind(wx.EVT_LISTBOX,OnResSelect) 10173 10176 mainSizer.Add(select,0) 10174 10177 G2frame.bottomSizer = wx.BoxSizer(wx.VERTICAL) … … 10182 10185 mainSizer.Add(wx.StaticText(RigidBodies,1,'Vector rigid bodies:'),0,WACV) 10183 10186 mainSizer.Add((5,5),0) 10187 RBnames = [] 10184 10188 for RBObj in data['RBModels']['Vector']: 10185 mainSizer.Add(VecrbSizer(RBObj)) 10189 RBnames.append(RBObj['RBname']) 10190 rbName = RBnames[0] 10191 rbObj = data['RBModels']['Vector'][0] 10192 data['Drawing']['viewPoint'][0] = rbObj['Orig'][0] 10193 data['Drawing']['Quaternion'] = rbObj['Orient'][0] 10194 select = wx.ListBox(RigidBodies,choices=RBnames,style=wx.LB_SINGLE,size=(1,120)) 10195 select.SetSelection(RBnames.index(rbName)) 10196 select.SetFirstItem(RBnames.index(rbName)) 10197 select.Bind(wx.EVT_LISTBOX,OnVecSelect) 10198 mainSizer.Add(select,0) 10199 G2frame.bottomSizer = wx.BoxSizer(wx.VERTICAL) 10200 G2frame.bottomSizer.Add(VecrbSizer(rbObj)) 10201 mainSizer.Add(G2frame.bottomSizer) 10202 G2plt.PlotStructure(G2frame,data) 10203 G2plt.PlotStructure(G2frame,data) # draw twice initially for mac 10186 10204 if nobody: 10187 10205 mainSizer.Add((5,5),0) … … 10247 10265 10248 10266 newXYZ = G2mth.UpdateRBXYZ(Bmat,rbObj,RBData,rbType)[0] 10267 rbUsedIds = [] # Ids of atoms in current phase used inside RBs 10268 for i in data['RBModels']: 10269 for j in data['RBModels'][i]: 10270 rbUsedIds += j['Ids'] 10249 10271 # categorize atoms by type, omitting any that are already assigned 10250 10272 # in a rigid body 10251 atmTypes = [None if atomData[i][1] in rbUsedIds 10252 else atomData[i][ct] 10253 for i in range(len(atomData))] 10273 atmTypes = [None if atomData[i][1] in rbUsedIds else atomData[i][ct] for i in range(len(atomData))] 10254 10274 # remove assigned atoms from search groups 10255 10275 for i in selDict: … … 10529 10549 return 10530 10550 selDict = getSelectedAtoms() 10531 if len(selDict) < 1:10551 if selDict and len(selDict) < 1: 10532 10552 wx.MessageBox('No existing atoms were selected',caption='Select Atom(s)', 10533 10553 style=wx.ICON_EXCLAMATION) … … 10921 10941 data['testRBObj']['rbAtTypes'] = RBData[rbType][rbId]['rbTypes'] 10922 10942 data['testRBObj']['AtInfo'] = RBData[rbType]['AtInfo'] 10923 data['testRBObj']['NameLookup'] = RBData[rbType][rbId] ['atNames']10943 data['testRBObj']['NameLookup'] = RBData[rbType][rbId].get('atNames',[]) #only for residues 10924 10944 data['testRBObj']['rbType'] = rbType 10925 10945 data['testRBObj']['rbData'] = RBData 
trunk/GSASIIplot.py
r4595 r4608 9350 9350 for ind,[x,y,z] in enumerate(XYZ): 9351 9351 aType = testRBObj['rbAtTypes'][ind] 9352 if testRBObj['NameLookup'][ind]:9352 if ind in testRBObj['NameLookup']: 9353 9353 name = testRBObj['NameLookup'][ind]+' ' 9354 9354 else:
Note: See TracChangeset
for help on using the changeset viewer.