Changeset 1026
- Timestamp:
- Aug 12, 2013 11:26:54 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2cif.py
r1022 r1026 17 17 import datetime as dt 18 18 import os.path 19 import sys 19 20 import numpy as np 20 21 import wx … … 35 36 #reload(G2pg) 36 37 import GSASIIstrMain as G2stMn 37 38 DEBUG = False 39 #DEBUG = True #True to skip printing of reflection/powder profile lists38 reload(G2stMn) 39 40 DEBUG = True #True to skip printing of reflection/powder profile lists 40 41 41 42 def getCallerDocString(): # for development … … 66 67 67 68 def openCIF(filnam): 68 self.fp = open(filnam,'w') 69 if DEBUG: 70 self.fp = sys.stdout 71 else: 72 self.fp = open(filnam,'w') 69 73 70 74 def closeCIF(): 71 self.fp.close() 75 if not DEBUG: 76 self.fp.close() 72 77 73 78 def WriteCIFitem(name,value=''): … … 644 649 DisAglData = {} 645 650 DisAglCtls = {} 651 # create a list of atoms, but skip atoms with zero occupancy 646 652 xyz = [] 653 fpfx = str(phasedict['pId'])+'::Afrac:' 647 654 for i,atom in enumerate(Atoms): 655 if self.parmDict.get(fpfx+str(i),atom[cfrac]) == 0.0: continue 648 656 xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+3]) 649 657 if 'DisAglCtls' in generalData: … … 660 668 DisAglData['OrigAtoms'] = xyz 661 669 DisAglData['TargAtoms'] = xyz 662 DisAglData['SGData'] = generalData['SGData']663 670 SymOpList,offsetList,symOpList,G2oprList = G2spc.AllOps( 664 671 generalData['SGData']) 665 672 666 # print len(SymOpList),len(offsetList),len(symOpList),len(G2oprList) 667 # raise Exception 668 669 673 xpandSGdata = generalData['SGData'].copy() 674 xpandSGdata.update({'SGOps':symOpList, 675 'SGInv':False, 676 'SGLatt':'P', 677 'SGCen':np.array([[0, 0, 0]]),}) 678 DisAglData['SGData'] = xpandSGdata 679 670 680 DisAglData['Cell'] = generalData['Cell'][1:] #+ volume 671 681 if 'pId' in phasedict: … … 673 683 DisAglData['covData'] = self.OverallParms['Covariance'] 674 684 try: 675 G2stMn.DistAngle(DisAglCtls,DisAglData)685 AtomLabels,DistArray,AngArray = G2stMn.RetDistAngle(DisAglCtls,DisAglData) 676 686 except KeyError: # inside DistAngle for missing atom types in DisAglCtls 677 687 print '**** ERROR - try again but do "Reset" to fill in missing atom types ****' 678 688 679 680 raise Exception681 682 689 # loop over interatomic distances for this phase 683 690 WriteCIFitem('\n# MOLECULAR GEOMETRY') … … 690 697 '\n\t_geom_bond_publ_flag') 691 698 692 # Note that labels should be read from self.labellist to correspond 693 # to the values reported in the atoms table and zero occupancy atoms 694 # should not be included 695 fpfx = str(phasedict['pId'])+'::Afrac:' 696 for i,at in enumerate(Atoms): 697 if self.parmDict.get(fpfx+str(i),at[cfrac]) == 0.0: continue 698 lbl = self.labellist[i] 699 699 for i in sorted(AtomLabels.keys()): 700 Dist = DistArray[i] 701 for D in Dist: 702 line = ' '+PutInCol(AtomLabels[i],6)+PutInCol(AtomLabels[D[0]],6) 703 sig = D[4] 704 if sig == 0: sig = -0.00009 705 line += PutInCol(G2mth.ValEsd(D[3],sig,True),10) 706 line += " 1_555 " 707 line += " {:3d}_".format(D[2]) 708 for d in D[1]: 709 line += "{:1d}".format(d+5) 710 line += " yes" 711 WriteCIFitem(line) 700 712 701 713 # loop over interatomic angles for this phase 702 WriteCIFitem(' loop_' +714 WriteCIFitem('\nloop_' + 703 715 '\n\t_geom_angle_atom_site_label_1' + 704 716 '\n\t_geom_angle_atom_site_label_2' + … … 710 722 '\n\t_geom_angle_publ_flag') 711 723 724 for i in sorted(AtomLabels.keys()): 725 Dist = DistArray[i] 726 for k,j,tup in AngArray[i]: 727 Dj = Dist[j] 728 Dk = Dist[k] 729 line = ' '+PutInCol(AtomLabels[Dj[0]],6)+PutInCol(AtomLabels[i],6)+PutInCol(AtomLabels[Dk[0]],6) 730 sig = tup[1] 731 if sig == 0: sig = -0.009 732 line += PutInCol(G2mth.ValEsd(tup[0],sig,True),10) 733 line += " {:3d}_".format(Dj[2]) 734 for d in Dj[1]: 735 line += "{:1d}".format(d+5) 736 line += " 1_555 " 737 line += " {:3d}_".format(Dk[2]) 738 for d in Dk[1]: 739 line += "{:1d}".format(d+5) 740 line += " yes" 741 WriteCIFitem(line) 712 742 713 743 def WritePhaseInfo(phasenam):
Note: See TracChangeset
for help on using the changeset viewer.