Changeset 860
- Timestamp:
- Mar 1, 2013 2:14:21 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r859 r860 630 630 Indx = {} 631 631 resList = [] 632 plotDefaults = {'oldxy':[0.,0.],'Quaternion':[ 1.,0.,0.,0.],'cameraPos':30.,'viewDir':[0,0,1],}632 plotDefaults = {'oldxy':[0.,0.],'Quaternion':[0.,0.,0.,1.],'cameraPos':30.,'viewDir':[0,0,1],} 633 633 634 634 def OnPageChanged(event): -
trunk/GSASIImath.py
r859 r860 244 244 def UpdateResRBAtoms(Bmat,RBObj,RBData): 245 245 RBIds = GetResRBIds(RBData) 246 RBRes = RBData[RBIds[RBObj['RBname']]] 246 RBname = RBObj['RBname'].split(':')[0] 247 RBRes = RBData[RBIds[RBname]] 247 248 XYZ = np.array(RBRes['rbXYZ']) 248 249 for tor,seq in zip(RBObj['Torsions'],RBRes['rbSeq']): … … 259 260 def UpdateRBAtoms(Bmat,RBObj,RBData,RBType): 260 261 RBIds = GetResRBIds(RBData[RBType]) 261 RBRes = RBData[RBType][RBIds[RBObj['RBname']]] 262 RBname = RBObj['RBname'].split(':')[0] 263 RBRes = RBData[RBType][RBIds[RBname]] 262 264 if RBType == 'Vector': 263 265 vecs = RBRes['rbVect'] … … 1380 1382 V /= d 1381 1383 else: 1382 return [ 1.,0.,0.,0.] #identity1384 return [0.,0.,0.,1.] #identity 1383 1385 p = A/2. 1384 1386 Q[0] = cosd(p) … … 1391 1393 ''' 1392 1394 A = 2.*acosd(Q[0]) 1393 V = Q[1:]/nl.norm(Q[1:]) 1395 V = np.array([0.,0.,1.]) 1396 if nl.norm(Q[1:]): 1397 V = Q[1:]/nl.norm(Q[1:]) 1394 1398 return A,V 1395 1399 … … 1399 1403 ''' 1400 1404 A = 2.*np.arccos(Q[0]) 1401 V = Q[1:]/nl.norm(Q[1:]) 1405 V = np.array([0.,0.,1.]) 1406 if nl.norm(Q[1:]): 1407 V = Q[1:]/nl.norm(Q[1:]) 1402 1408 return A,V 1403 1409 … … 1417 1423 else: 1418 1424 V3 = np.zeros(3) 1419 Q = np.array([ 1.0,0.0,0.0,0.0])1425 Q = np.array([0.,0.,0.,1.]) 1420 1426 D = 0. 1421 1427 if nl.norm(V3): -
trunk/GSASIIphsGUI.py
r859 r860 3075 3075 wx.CallAfter(FillRigidBodyGrid,True) 3076 3076 3077 def ThermDataSizer(RBObj): #needs to be seen by VecRbSizer!3077 def ThermDataSizer(RBObj): 3078 3078 3079 3079 def OnThermval(event): … … 3191 3191 Indx[orien.GetId()] = ix 3192 3192 topSizer.Add(orien,0,wx.ALIGN_CENTER_VERTICAL) 3193 Qcheck = wx.ComboBox(RigidBodies,-1,value='',choices=[' ','A',' Q'],3193 Qcheck = wx.ComboBox(RigidBodies,-1,value='',choices=[' ','A','AV'], 3194 3194 style=wx.CB_READONLY|wx.CB_DROPDOWN) 3195 3195 Qcheck.Bind(wx.EVT_COMBOBOX,OnOrienRef) … … 3199 3199 3200 3200 def ResrbSizer(RBObj): 3201 3201 G2frame.dataFrame.SetStatusText('NB: Rotation vector is in crystallographic space') 3202 3202 3203 def OnTorsionRef(event): 3203 3204 Obj = event.GetEventObject() … … 3274 3275 3275 3276 def VecrbSizer(RBObj): 3276 3277 G2frame.dataFrame.SetStatusText('NB: Rotation vector is in crystallographic space') 3278 3277 3279 def OnDelVecRB(event): 3278 3280 Obj = event.GetEventObject() … … 3390 3392 atomData = data['Atoms'] 3391 3393 Indx = {} 3392 atInd = [ 0,1,2]3394 atInd = [-1,-1,-1] 3393 3395 data['testRBObj'] = {} 3394 3396 … … 3402 3404 newXYZ = G2mth.UpdateRBAtoms(Bmat,rbObj,RBData,rbType) 3403 3405 Ids = [] 3406 dmax = 0.0 3404 3407 oldXYZ = G2mth.getAtomXYZ(atomData,cx) 3405 3408 for xyz in newXYZ: 3406 3409 dist = G2mth.GetXYZDist(xyz,oldXYZ,Amat) 3410 dmax = max(dmax,np.min(dist)) 3407 3411 id = np.argmin(dist) 3408 3412 Ids.append(atomData[id][-1]) 3409 3413 atomData[id][cx:cx+3] = xyz 3414 if dmax > 0.5: 3415 print '**** WARNING - some atoms not found or misidentified ****' 3416 print '**** check torsion angles & try again ****' 3417 OkBtn.SetLabel('Not Ready') 3418 OkBtn.Enable(False) 3419 return 3410 3420 rbObj['Ids'] = Ids 3411 3421 rbObj['ThermalMotion'] = ['None',[],[]] #type,values,flags … … 3442 3452 data['testRBObj']['AtNames'] = AtNames 3443 3453 data['testRBObj']['rbObj'] = {'Orig':[[0,0,0],False], 3444 'Orient':[[0 ,0,0,1.],' '],'Ids':[],'RBId':rbId,'Torsions':[],3454 'Orient':[[0.,0.,0.,1.],' '],'Ids':[],'RBId':rbId,'Torsions':[], 3445 3455 'numChain':'','RBname':RBData[rbType][rbId]['RBname']} 3446 3456 data['testRBObj']['torAtms'] = [] … … 3459 3469 atNames[i][atom[ct-1]] = iatm 3460 3470 return atNames,AtNames 3461 3462 def OnOrigX(event):3463 Obj = event.GetEventObject()3464 item = Indx[Obj.GetId()]3465 try:3466 val = float(Obj.GetValue())3467 data['testRBObj']['rbObj']['Orig'][0][item] = val3468 except ValueError:3469 pass3470 G2plt.PlotStructure(G2frame,data)3471 3472 def OnOrien(event):3473 Obj = event.GetEventObject()3474 item = Indx[Obj.GetId()]3475 Q = data['testRBObj']['rbObj']['Orient'][0]3476 try:3477 val = float(Obj.GetValue())3478 Q[item] = val3479 if not any(Q):3480 raise ValueError3481 Q = G2mth.normQ(Q)3482 data['testRBObj']['rbObj']['Orient'][0] = Q3483 except ValueError:3484 pass3485 G2plt.PlotStructure(G2frame,data)3486 3471 3487 3472 def OnAtOrigPick(event): … … 3499 3484 Oxyz = np.inner(Bmat,np.array(rbXYZ[rbRef[0]])) 3500 3485 Nxyz = np.array(atomData[nref][cx:cx+3]) 3501 data['testRBObj']['rbObj']['Orig'][0] = Nxyz-Oxyz 3502 else: 3503 data['testRBObj']['rbObj']['Orig'][0] = atomData[atNames[item][atName]][cx:cx+3] 3486 Orig = Nxyz-Oxyz 3487 data['testRBObj']['rbObj']['Orig'][0] = Orig 3488 else: 3489 Orig = atomData[atNames[item][atName]][cx:cx+3] 3490 data['testRBObj']['rbObj']['Orig'][0] = Orig 3491 for x,item in zip(Orig,Xsizers): 3492 item.SetLabel('%10.5f'%(x)) 3504 3493 G2plt.PlotStructure(G2frame,data) 3505 3494 … … 3509 3498 atName = Obj.GetValue() 3510 3499 atInd[item] = atNames[item][atName] 3500 if any([x<0 for x in atInd]): 3501 return 3502 OkBtn.SetLabel('OK') 3503 OkBtn.Enable(True) 3511 3504 rbType = data['testRBObj']['rbType'] 3512 3505 rbObj = data['testRBObj']['rbObj'] … … 3530 3523 QuatC = G2mth.prodQQ(QuatB,QuatA) 3531 3524 data['testRBObj']['rbObj']['Orient'] = [QuatC,' '] 3525 for x,item in zip(QuatC,Osizers): 3526 item.SetLabel('%10.4f'%(x)) 3532 3527 if rbType == 'Vector': 3533 3528 Oxyz = np.inner(Bmat,G2mth.prodQVQ(QuatC,rbOrig)) 3534 3529 Nxyz = np.array(atomData[atInd[0]][cx:cx+3]) 3535 data['testRBObj']['rbObj']['Orig'][0] = Nxyz-Oxyz 3530 Orig = Nxyz-Oxyz 3531 data['testRBObj']['rbObj']['Orig'][0] = Orig 3532 for x,item in zip(Orig,Xsizers): 3533 item.SetLabel('%10.5f'%(x)) 3536 3534 G2plt.PlotStructure(G2frame,data) 3537 3535 3538 3536 def OnTorAngle(event): 3537 OkBtn.SetLabel('OK') 3538 OkBtn.Enable(True) 3539 3539 Obj = event.GetEventObject() 3540 3540 [tor,torSlide] = Indx[Obj.GetId()] … … 3550 3550 3551 3551 def OnTorSlide(event): 3552 OkBtn.SetLabel('OK') 3553 OkBtn.Enable(True) 3552 3554 Obj = event.GetEventObject() 3553 3555 tor,ang = Indx[Obj.GetId()] … … 3584 3586 OriSizer.Add(wx.StaticText(RigidBodies,-1,'Origin x,y,z: '),0,wx.ALIGN_CENTER_VERTICAL) 3585 3587 for ix,x in enumerate(Orig): 3586 origX = wx.TextCtrl(RigidBodies,-1,value='%10.5f'%(x),style=wx.TE_PROCESS_ENTER) 3587 origX.Bind(wx.EVT_TEXT_ENTER,OnOrigX) 3588 origX.Bind(wx.EVT_KILL_FOCUS,OnOrigX) 3589 Indx[origX.GetId()] = ix 3588 origX = wx.StaticText(RigidBodies,-1,'%10.5f'%(x)) 3590 3589 OriSizer.Add(origX,0,wx.ALIGN_CENTER_VERTICAL) 3591 3590 Xsizers.append(origX) … … 3597 3596 OriSizer.Add(wx.StaticText(RigidBodies,-1,'Orientation quaternion: '),0,wx.ALIGN_CENTER_VERTICAL) 3598 3597 for ix,x in enumerate(Orien): 3599 orien = wx.TextCtrl(RigidBodies,-1,value='%8.4f'%(x),style=wx.TE_PROCESS_ENTER) 3600 orien.Bind(wx.EVT_TEXT_ENTER,OnOrien) 3601 orien.Bind(wx.EVT_KILL_FOCUS,OnOrien) 3602 Indx[orien.GetId()] = ix 3598 orien = wx.StaticText(RigidBodies,-1,'%10.4f'%(x)) 3603 3599 OriSizer.Add(orien,0,wx.ALIGN_CENTER_VERTICAL) 3604 3600 Osizers.append(orien) … … 3610 3606 RefSizer.Add(wx.StaticText(RigidBodies,-1,'Location setting: Select match to'),0,wx.ALIGN_CENTER_VERTICAL) 3611 3607 for i in [0,1,2]: 3612 choice = atNames[i].keys()3608 choice = ['',]+atNames[i].keys() 3613 3609 choice.sort() 3614 3610 RefSizer.Add(wx.StaticText(RigidBodies,-1,' '+refName[i]+': '),0,wx.ALIGN_CENTER_VERTICAL) 3615 atPick = wx.ComboBox(RigidBodies,-1,value= atomData[atInd[i]][ct-1],3616 choices=choice ,style=wx.CB_READONLY|wx.CB_DROPDOWN)3611 atPick = wx.ComboBox(RigidBodies,-1,value='', 3612 choices=choice[1:],style=wx.CB_READONLY|wx.CB_DROPDOWN) 3617 3613 if i: 3618 3614 atPick.Bind(wx.EVT_COMBOBOX, OnAtQPick) … … 3661 3657 mainSizer.Add(topSizer) 3662 3658 3663 OkBtn = wx.Button(RigidBodies,-1," Ok")3659 OkBtn = wx.Button(RigidBodies,-1,"Not ready") 3664 3660 OkBtn.Bind(wx.EVT_BUTTON, OnOk) 3661 OkBtn.Enable(False) 3665 3662 CancelBtn = wx.Button(RigidBodies,-1,'Cancel') 3666 3663 CancelBtn.Bind(wx.EVT_BUTTON, OnCancel) … … 3716 3713 VAR = rbRes['rbXYZ'][rbRef[1]]-rbRes['rbXYZ'][rbRef[0]] 3717 3714 VBR = rbRes['rbXYZ'][rbRef[2]]-rbRes['rbXYZ'][rbRef[0]] 3718 rbObj = {'RBname':rbRes['RBname'] ,'numChain':numChain}3715 rbObj = {'RBname':rbRes['RBname']+':'+str(rbRes['useCount']),'numChain':numChain} 3719 3716 rbAtoms = [] 3720 3717 rbIds = [] … … 3738 3735 QuatC = G2mth.prodQQ(QuatB,QuatA) 3739 3736 rbObj['Orient'] = [QuatC,' '] 3737 rbObj['ThermalMotion'] = ['None',[],[]] #type,values,flags 3740 3738 SXYZ = [] 3741 3739 TXYZ = [] … … 3753 3751 for ride in Riders: 3754 3752 SXYZ[ride] = G2mth.prodQVQ(QuatA,SXYZ[ride]-SXYZ[Patm])+SXYZ[Patm] 3755 RBData['Residue'][RBIds[res]]['useCount'] += 13753 rbRes['useCount'] += 1 3756 3754 RBObjs.append(rbObj) 3757 3755 data['RBModels']['Residue'] = RBObjs … … 3766 3764 def OnRBRemoveAll(event): 3767 3765 data['RBModels']['Residue'] = [] 3768 data['RBModels']['Vector'] = [] 3766 data['RBModels']['Vector'] = [] 3767 RBData = G2frame.PatternTree.GetItemPyData( 3768 G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Rigid bodies')) 3769 for RBType in ['Vector','Residue']: 3770 for rbId in RBData[RBType]: 3771 RBData[RBType][rbId]['useCount'] = 0 3769 3772 FillRigidBodyGrid(True) 3770 3773 -
trunk/GSASIIplot.py
r859 r860 2801 2801 2802 2802 if event.Dragging(): 2803 if event.AltDown() :2803 if event.AltDown() and rbObj: 2804 2804 if event.LeftIsDown(): 2805 2805 SetRBRotation(newxy) … … 2979 2979 Ty += V[1]*0.01 2980 2980 Tz += V[2]*0.01 2981 drawingData['oldxy'] = list(newxy)2982 2981 drawingData['viewPoint'][0] = Tx,Ty,Tz 2983 2982 SetViewPointText([Tx,Ty,Tz]) … … 2997 2996 Ty -= V[1]*0.01 2998 2997 Tz -= V[2]*0.01 2999 drawingData['oldxy'] = list(newxy)3000 2998 rbObj['Orig'][0] = Tx,Ty,Tz 3001 2999 SetRBOrigText() … … 3574 3572 pass 3575 3573 3574 # def SetRBOrigin(): 3575 # page = getSelection() 3576 # if page: 3577 # if G2frame.dataDisplay.GetPageText(page) == 'Rigid bodies': 3578 # G2frame.MapPeaksTable.SetData(mapPeaks) 3579 # panel = G2frame.dataDisplay.GetPage(page).GetChildren() 3580 # names = [child.GetName() for child in panel] 3581 # panel[names.index('grid window')].Refresh() 3582 3576 3583 def OnMouseDown(event): 3577 3584 xy = event.GetPosition() … … 3586 3593 Q = defaults['Quaternion'] 3587 3594 G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1) 3595 # elif event.RightIsDown(): 3596 # SetRBOrigin(newxy) 3588 3597 elif event.MiddleIsDown(): 3589 3598 SetRotationZ(newxy) … … 3612 3621 glLightfv(GL_LIGHT0,GL_DIFFUSE,[1,1,1,1]) 3613 3622 3623 # def SetRBOrigin(newxy): 3624 ##first get translation vector in screen coords. 3625 # oldxy = defaults['oldxy'] 3626 # if not len(oldxy): oldxy = list(newxy) 3627 # dxy = newxy-oldxy 3628 # defaults['oldxy'] = list(newxy) 3629 # V = np.array([dxy[0],-dxy[1],0.])/100. 3630 # Q = defaults['Quaternion'] 3631 # V = G2mth.prodQVQ(G2mth.invQ(Q),V) 3632 # rbData['rbXYZ'] += V 3633 # PlotRigidBody(G2frame,rbType,AtInfo,rbData,defaults) 3634 # 3614 3635 def SetRotation(newxy): 3615 3636 #first get rotation vector in screen coords. & angle increment -
trunk/GSASIIstruct.py
r859 r860 3837 3837 for item in phaseVary: 3838 3838 if '::A0' in item: 3839 print '**** WARNING - lattice parameters should not be refined in a sequential refinement '3840 print ' instead use the Dij parameters for each powder histogram****'3839 print '**** WARNING - lattice parameters should not be refined in a sequential refinement ****' 3840 print '**** instead use the Dij parameters for each powder histogram ****' 3841 3841 if 'Seq Data' in Controls: 3842 3842 histNames = Controls['Seq Data']
Note: See TracChangeset
for help on using the changeset viewer.