Changeset 1028
- Timestamp:
- Aug 12, 2013 11:44:25 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r1017 r1028 69 69 wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT, 70 70 wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE, 71 wxID_ASSIGNATMS2RB 72 ] = [wx.NewId() for item in range(1 2)]71 wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL 72 ] = [wx.NewId() for item in range(13)] 73 73 74 74 [ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR, … … 1930 1930 self.ReImportMenuId[item.GetId()] = None # try all readers 1931 1931 1932 self.AtomCompute.Append(id=wxID_ATOMSDISAGL, kind=wx.ITEM_NORMAL,text='Distances && Angles', 1932 self.AtomCompute.Append(id=wxID_ATOMSDISAGL, kind=wx.ITEM_NORMAL,text='Show Distances && Angles', 1933 help='Compute distances & angles for selected atoms') 1934 self.AtomCompute.Append(id=wxID_ATOMSPDISAGL, kind=wx.ITEM_NORMAL,text='Save Distances && Angles', 1933 1935 help='Compute distances & angles for selected atoms') 1934 1936 self.PostfillDataMenu() -
trunk/GSASIIphsGUI.py
r1022 r1028 21 21 22 22 ''' 23 import os.path 23 24 import wx 24 25 import wx.grid as wg … … 1551 1552 Atoms.ForceRefresh() 1552 1553 1553 def OnDistAngle(event): 1554 def OnDistAnglePrt(event): 1555 fp = file(os.path.abspath(os.path.splitext(G2frame.GSASprojectfile 1556 )[0]+'.disagl'),'w') 1557 OnDistAngle(event,fp=fp) 1558 fp.close() 1559 1560 def OnDistAngle(event,fp=None): 1554 1561 indx = Atoms.GetSelectedRows() 1555 1562 Oxyz = [] … … 1587 1594 DisAglData['covData'] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Covariance')) 1588 1595 try: 1589 G2stMn.DistAngle(DisAglCtls,DisAglData) 1596 if fp: 1597 G2stMn.PrintDistAngle(DisAglCtls,DisAglData,fp) 1598 else: 1599 G2stMn.PrintDistAngle(DisAglCtls,DisAglData) 1590 1600 except KeyError: # inside DistAngle for missing atom types in DisAglCtls 1591 1601 print '**** ERROR - try again but do "Reset" to fill in missing atom types ****' … … 4999 5009 G2frame.dataFrame.Bind(wx.EVT_MENU, OnReloadDrawAtoms, id=G2gd.wxID_RELOADDRAWATOMS) 5000 5010 G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAngle, id=G2gd.wxID_ATOMSDISAGL) 5011 G2frame.dataFrame.Bind(wx.EVT_MENU, OnDistAnglePrt, id=G2gd.wxID_ATOMSPDISAGL) 5001 5012 for id in G2frame.dataFrame.ReImportMenuId: #loop over submenu items 5002 5013 G2frame.dataFrame.Bind(wx.EVT_MENU, OnReImport, id=id) -
trunk/GSASIIpwdGUI.py
r1021 r1028 960 960 topSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Ka1/Ka2:'), 961 961 0,wx.ALIGN_CENTER_VERTICAL) 962 topSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, ' %8.6f/%8.6f'%(insVal['Lam1'],insVal['Lam2'])),962 topSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,u' %8.6f/%8.6f\xc5'%(insVal['Lam1'],insVal['Lam2'])), 963 963 0,wx.ALIGN_CENTER_VERTICAL) 964 964 waveSizer = wx.BoxSizer(wx.HORIZONTAL) … … 981 981 982 982 else: 983 topSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, ' Lam: (%10.6f)'%(insDef['Lam'])),983 topSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,u' Lam (\xc5): (%10.6f)'%(insDef['Lam'])), 984 984 0,wx.ALIGN_CENTER_VERTICAL) 985 985 waveVal = wx.TextCtrl(G2frame.dataDisplay,wx.ID_ANY,'%10.6f'%(insVal['Lam']),style=wx.TE_PROCESS_ENTER) … … 1064 1064 else: #single crystal data 1065 1065 if 'C' in insVal['Type']: #constant wavelength 1066 instSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, ' Lam: (%10.6f)'%(insDef['Lam'])),1066 instSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,u' Lam (\xc5): (%10.6f)'%(insDef['Lam'])), 1067 1067 0,wx.ALIGN_CENTER_VERTICAL) 1068 1068 waveVal = wx.TextCtrl(G2frame.dataDisplay,wx.ID_ANY,'%10.6f'%(insVal['Lam']),style=wx.TE_PROCESS_ENTER) -
trunk/GSASIIstrMain.py
r1016 r1028 386 386 print ' ***** Sequential refinement successful *****' 387 387 388 def DistAngle(DisAglCtls,DisAglData): 389 'Needs a doc string' 388 def RetDistAngle(DisAglCtls,DisAglData): 389 '''Compute and return distances and angles 390 391 :param dict DisAglCtls: contains distance/angle radii usually defined using 392 :func:`GSASIIgrid.DisAglDialog` 393 :param dict DisAglData: contains phase data: 394 Items 'OrigAtoms' and 'TargAtoms' contain the atoms to be used 395 for distance/angle origins and atoms to be used as targets. 396 Item 'SGData' has the space group information (see :ref:`Space Group object<SGData_table>`) 397 398 :returns: AtomLabels,DistArray,AngArray where: 399 400 **AtomLabels** is a dict of atom labels, keys are the atom number 401 402 **DistArray** is a dict keyed by the origin atom number where the value is a list 403 of distance entries. The value for each distance is a list containing: 404 405 0) the target atom number (int); 406 1) the unit cell offsets added to x,y & z (tuple of int values) 407 2) the symmetry operator number (which may be modified to indicate centering and center of symmetry) 408 3) an interatomic distance in A (float) 409 4) an uncertainty on the distance in A or 0.0 (float) 410 411 **AngArray** is a dict keyed by the origin (central) atom number where 412 the value is a list of 413 angle entries. The value for each angle entry consists of three values: 414 415 0) a distance item reference for one neighbor (int) 416 1) a distance item reference for a second neighbor (int) 417 2) a angle, uncertainty pair; the s.u. may be zero (tuple of two floats) 418 419 The AngArray distance reference items refer directly to the index of the items in the 420 DistArray item for the list of distances for the central atom. 421 ''' 390 422 import numpy.ma as ma 391 423 392 def ShowBanner(name):393 print 80*'*'394 print ' Interatomic Distances and Angles for phase '+name395 print 80*'*','\n'396 397 ShowBanner(DisAglCtls['Name'])398 424 SGData = DisAglData['SGData'] 399 SGtext = G2spc.SGPrint(SGData)400 for line in SGtext: print line401 425 Cell = DisAglData['Cell'] 402 426 … … 412 436 names = [' a = ',' b = ',' c = ',' alpha = ',' beta = ',' gamma = ',' Volume = '] 413 437 valEsd = [G2mth.ValEsd(Cell[i],cellSig[i],True) for i in range(7)] 414 line = '\n Unit cell:' 415 for name,vals in zip(names,valEsd): 416 line += name+vals 417 print line 418 else: 419 print '\n Unit cell: a = ','%.5f'%(Cell[0]),' b = ','%.5f'%(Cell[1]),' c = ','%.5f'%(Cell[2]), \ 420 ' alpha = ','%.3f'%(Cell[3]),' beta = ','%.3f'%(Cell[4]),' gamma = ', \ 421 '%.3f'%(Cell[5]),' volume = ','%.3f'%(Cell[6]) 438 422 439 Factor = DisAglCtls['Factors'] 423 440 Radii = dict(zip(DisAglCtls['AtomTypes'],zip(DisAglCtls['BondRadii'],DisAglCtls['AngleRadii']))) … … 426 443 origAtoms = DisAglData['OrigAtoms'] 427 444 targAtoms = DisAglData['TargAtoms'] 445 AtomLabels = {} 428 446 for Oatom in origAtoms: 447 AtomLabels[Oatom[0]] = Oatom[1] 448 for Oatom in targAtoms: 449 AtomLabels[Oatom[0]] = Oatom[1] 450 DistArray = {} 451 AngArray = {} 452 for Oatom in origAtoms: 453 DistArray[Oatom[0]] = [] 454 AngArray[Oatom[0]] = [] 429 455 OxyzNames = '' 430 456 IndBlist = [] … … 454 480 IndBlist.append(str(dx.T[indb][i])) 455 481 unit = Units[indb][i] 456 tunit = '[%2d%2d%2d]'%(unit[0]+Tunit[0],unit[1]+Tunit[1],unit[2]+Tunit[2])482 tunit = (unit[0]+Tunit[0],unit[1]+Tunit[1],unit[2]+Tunit[2]) 457 483 pdpx = G2mth.getDistDerv(Oatom[3:6],Tatom[3:6],Amat,unit,Top,SGData) 458 484 sig = 0.0 459 485 if len(Xvcov): 460 486 sig = np.sqrt(np.inner(pdpx,np.inner(Xvcov,pdpx))) 461 Dist.append([Oatom[ 1],Tatom[1],tunit,Top,ma.getdata(dist[indb])[i],sig])487 Dist.append([Oatom[0],Tatom[0],tunit,Top,ma.getdata(dist[indb])[i],sig]) 462 488 if (Dist[-1][-2]-AsumR) <= 0.: 463 489 Vect.append(dx.T[indb][i]/Dist[-1][-2]) … … 466 492 Vect.append([0.,0.,0.]) 467 493 VectA.append([]) 494 for D in Dist: 495 DistArray[Oatom[0]].append(D[1:]) 468 496 Vect = np.array(Vect) 469 497 angles = np.zeros((len(Vect),len(Vect))) … … 474 502 if np.any(vecb): 475 503 angles[i][j],angsig[i][j] = G2mth.getAngSig(VectA[i],VectA[j],Amat,SGData,covData) 504 if i <= j: continue 505 AngArray[Oatom[0]].append((i,j, 506 G2mth.getAngSig(VectA[i],VectA[j],Amat,SGData,covData) 507 )) 508 return AtomLabels,DistArray,AngArray 509 510 def PrintDistAngle(DisAglCtls,DisAglData,out=sys.stdout): 511 '''Print distances and angles 512 513 :param dict DisAglCtls: contains distance/angle radii usually defined using 514 :func:`GSASIIgrid.DisAglDialog` 515 :param dict DisAglData: contains phase data: 516 Items 'OrigAtoms' and 'TargAtoms' contain the atoms to be used 517 for distance/angle origins and atoms to be used as targets. 518 Item 'SGData' has the space group information (see :ref:`Space Group object<SGData_table>`) 519 :param file out: file object for output. Defaults to sys.stdout. 520 ''' 521 import numpy.ma as ma 522 def MyPrint(s): 523 out.write(s+'\n') 524 # print(s,file=out) # use in Python 3 525 526 def ShowBanner(name): 527 MyPrint(80*'*') 528 MyPrint(' Interatomic Distances and Angles for phase '+name) 529 MyPrint((80*'*')+'\n') 530 531 ShowBanner(DisAglCtls['Name']) 532 SGData = DisAglData['SGData'] 533 SGtext = G2spc.SGPrint(SGData) 534 for line in SGtext: MyPrint(line) 535 Cell = DisAglData['Cell'] 536 537 Amat,Bmat = G2lat.cell2AB(Cell[:6]) 538 covData = {} 539 if 'covData' in DisAglData: 540 covData = DisAglData['covData'] 541 covMatrix = covData['covMatrix'] 542 varyList = covData['varyList'] 543 pfx = str(DisAglData['pId'])+'::' 544 A = G2lat.cell2A(Cell[:6]) 545 cellSig = G2stIO.getCellEsd(pfx,SGData,A,covData) 546 names = [' a = ',' b = ',' c = ',' alpha = ',' beta = ',' gamma = ',' Volume = '] 547 valEsd = [G2mth.ValEsd(Cell[i],cellSig[i],True) for i in range(7)] 548 line = '\n Unit cell:' 549 for name,vals in zip(names,valEsd): 550 line += name+vals 551 MyPrint(line) 552 else: 553 MyPrint('\n Unit cell: a = '+('%.5f'%Cell[0])+' b = '+('%.5f'%Cell[1])+' c = '+('%.5f'%Cell[2])+ 554 ' alpha = '+('%.3f'%Cell[3])+' beta = '+('%.3f'%Cell[4])+' gamma = '+ 555 ('%.3f'%Cell[5])+' volume = '+('%.3f'%Cell[6])) 556 557 AtomLabels,DistArray,AngArray = RetDistAngle(DisAglCtls,DisAglData) 558 origAtoms = DisAglData['OrigAtoms'] 559 targAtoms = DisAglData['TargAtoms'] 560 for Oatom in origAtoms: 561 i = Oatom[0] 562 Dist = DistArray[i] 563 nDist = len(Dist) 564 angles = np.zeros((nDist,nDist)) 565 angsig = np.zeros((nDist,nDist)) 566 for k,j,tup in AngArray[i]: 567 angles[k][j],angsig[k][j] = angles[j][k],angsig[j][k] = tup 476 568 line = '' 477 569 for i,x in enumerate(Oatom[3:6]): 478 if len(Xvcov): 479 line += '%12s'%(G2mth.ValEsd(x,np.sqrt(Xvcov[i][i]),True)) 480 else: 481 line += '%12.5f'%(x) 482 print '\n Distances & angles for ',Oatom[1],' at ',line 483 print 80*'*' 570 line += ('%12.5f'%x).rstrip('0') 571 MyPrint('\n Distances & angles for '+Oatom[1]+' at '+line.rstrip()) 572 MyPrint(80*'*') 484 573 line = '' 485 574 for dist in Dist[:-1]: 486 line += '%12s'%( dist[1].center(12))487 print ' To cell +(sym. op.) dist. ',line575 line += '%12s'%(AtomLabels[dist[0]].center(12)) 576 MyPrint(' To cell +(sym. op.) dist. '+line.rstrip()) 488 577 for i,dist in enumerate(Dist): 489 578 line = '' … … 498 587 else: 499 588 line += 12*' ' 500 if dist[ 5]: #sig exists!501 val = G2mth.ValEsd(dist[ 4],dist[5])589 if dist[4]: #sig exists! 590 val = G2mth.ValEsd(dist[3],dist[4]) 502 591 else: 503 val = '%8.4f'%(dist[4]) 504 print ' %8s%10s+(%4d) %12s'%(dist[1].ljust(8),dist[2].ljust(10),dist[3],val.center(12)),line 592 val = '%8.4f'%(dist[3]) 593 tunit = '[%2d%2d%2d]'% dist[1] 594 MyPrint((' %8s%10s+(%4d) %12s'%(AtomLabels[dist[0]].ljust(8),tunit.ljust(10),dist[2],val.center(12)))+line.rstrip()) 505 595 506 596 def DisAglTor(DATData):
Note: See TracChangeset
for help on using the changeset viewer.