Changeset 1884
- Timestamp:
- Jun 9, 2015 4:02:06 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIddataGUI.py
r1878 r1884 18 18 ''' 19 19 import wx 20 import math21 import copy22 import time23 import sys24 20 import GSASIIpath 25 21 GSASIIpath.SetVersionNumber("$Revision$") … … 781 777 return flackSizer 782 778 779 def twinSizer(): 780 781 def OnAddTwin(event): 782 twinMat = np.array([[1,0,0],[0,1,0],[0,0,1]]) 783 twinVal = [1.0,False] 784 UseList[G2frame.hist]['Twins'].append([twinMat,twinVal]) 785 addtwin.SetValue(False) 786 wx.CallLater(100,RepaintHistogramInfo) 787 788 def OnMat(event): 789 Obj = event.GetEventObject() 790 it,im = Indx[Obj.GetId()] 791 newMat = Obj.GetValue().split() 792 try: 793 uvw = [int(newMat[i]) for i in range(3)] 794 except ValueError: 795 uvw = UseList[G2frame.hist]['Twins'][it][0][im] 796 UseList[G2frame.hist]['Twins'][it][0][im] = uvw 797 Obj.SetValue('%d %d %d'%(uvw[0],uvw[1],uvw[2])) 798 799 def OnTwinVal(event): 800 Obj = event.GetEventObject() 801 it = Indx[Obj.GetId()] 802 try: 803 val = float(Obj.GetValue()) 804 if 0. > val > 1.:\ 805 raise ValueError 806 except ValueError: 807 val = UseList[G2frame.hist]['Twins'][it][1][0] 808 UseList[G2frame.hist]['Twins'][it][1][0] = val 809 Obj.SetValue('%.3f'%(val)) 810 811 def OnTwinRef(event): 812 Obj = event.GetEventObject() 813 it = Indx[Obj.GetId()] 814 UseList[G2frame.hist]['Twins'][it][1][1] = Obj.GetValue() 815 816 def OnTwinDel(event): 817 Obj = event.GetEventObject() 818 it = Indx[Obj.GetId()] 819 del UseList[G2frame.hist]['Twins'][it] 820 wx.CallLater(100,RepaintHistogramInfo) 821 822 twinsizer = wx.BoxSizer(wx.VERTICAL) 823 topsizer = wx.BoxSizer(wx.HORIZONTAL) 824 topsizer.Add(wx.StaticText(DData,wx.ID_ANY,' Merohedral/pseudomerohedral twins: '),0,WACV) 825 addtwin = wx.CheckBox(DData,wx.ID_ANY,label=' Add Twin Law') 826 addtwin.Bind(wx.EVT_CHECKBOX, OnAddTwin) 827 topsizer.Add(addtwin,0,WACV) 828 twinsizer.Add(topsizer) 829 Indx = {} 830 for it,Twin in enumerate(UseList[G2frame.hist]['Twins']): 831 twinMat,twinVal = Twin 832 matSizer = wx.BoxSizer(wx.HORIZONTAL) 833 matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV) 834 Style = wx.TE_READONLY 835 if it: 836 Style = wx.TE_PROCESS_ENTER 837 for im,Mat in enumerate(twinMat): 838 mat = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(Mat[0],Mat[1],Mat[2]), 839 style=Style) 840 if it: 841 Indx[mat.GetId()] = [it,im] 842 mat.Bind(wx.EVT_TEXT_ENTER,OnMat) 843 mat.Bind(wx.EVT_KILL_FOCUS,OnMat) 844 matSizer.Add(mat,0,WACV|wx.LEFT,5) 845 twinsizer.Add(matSizer,0,WACV|wx.LEFT,5) 846 valSizer = wx.BoxSizer(wx.HORIZONTAL) 847 valSizer.Add(wx.StaticText(DData,-1,label=' Twin element fraction:'),0,WACV) 848 twinval = wx.TextCtrl(DData,-1,'%.3f'%(Twin[1][0]),style=wx.TE_PROCESS_ENTER) 849 Indx[twinval.GetId()] = it 850 twinval.Bind(wx.EVT_TEXT_ENTER,OnTwinVal) 851 twinval.Bind(wx.EVT_KILL_FOCUS,OnTwinVal) 852 valSizer.Add(twinval,0,WACV) 853 if it: 854 twinref = wx.CheckBox(DData,wx.ID_ANY,label=' Refine?') 855 Indx[twinref.GetId()] = it 856 twinref.SetValue(Twin[1][1]) 857 twinref.Bind(wx.EVT_CHECKBOX, OnTwinRef) 858 valSizer.Add(twinref,0,WACV) 859 twindel = wx.CheckBox(DData,wx.ID_ANY,label=' Delete?') 860 Indx[twindel.GetId()] = it 861 twindel.Bind(wx.EVT_CHECKBOX, OnTwinDel) 862 valSizer.Add(twindel,0,WACV) 863 twinsizer.Add(valSizer,0,WACV|wx.LEFT,5) 864 return twinsizer 865 783 866 def OnSelect(event): 784 867 G2frame.hist = keyList[select.GetSelection()] … … 938 1021 if 'Flack' not in UseList[G2frame.hist]: 939 1022 UseList[G2frame.hist]['Flack'] = [0.0,False] 1023 if 'Twins' not in UseList[G2frame.hist]: 1024 UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],] 940 1025 #end patch 941 1026 bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5) … … 943 1028 if not SGData['SGInv']: #not operational yet - no test data 944 1029 bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5) 1030 bottomSizer.Add(twinSizer(),0,WACV|wx.BOTTOM,5) 945 1031 return bottomSizer 946 1032 -
trunk/GSASIIobj.py
r1875 r1884 1301 1301 'Eg$' : 'Secondary type I extinction', 1302 1302 'Flack' : 'Flack parameter', 1303 'TwinFr' : 'Twin fraction', 1303 1304 #Histogram vars (:h:<var>) 1304 1305 'Absorption' : 'Absorption coef.', -
trunk/GSASIIphsGUI.py
r1875 r1884 28 28 import wx.lib.scrolledpanel as wxscroll 29 29 import matplotlib as mpl 30 import math31 30 import copy 32 31 import time … … 2079 2078 atomData = data['Atoms'] 2080 2079 atomNames = [] 2080 All = False 2081 2081 for atom in atomData: 2082 atomNames.append( atom[:ct+1])2082 atomNames.append(''.join(atom[:ct+1]).capitalize()) #eliminate spurious differences 2083 2083 for atom in rd.Phase['Atoms']: 2084 2084 try: 2085 idx = atomNames.index( atom[:ct+1])2085 idx = atomNames.index(''.join(atom[:ct+1]).capitalize()) #eliminate spurious differences 2086 2086 atId = atom[cia+8] 2087 2087 atomData[idx][:-1] = atom[:-1] 2088 2088 atomData[idx][cia+8] = atId 2089 2089 except ValueError: 2090 print atom[:ct+1], 'not in Atom array; not updated' 2090 if All: 2091 atomData.append(atom) 2092 else: 2093 dlg = wx.MessageDialog(G2frame,'Some atoms not in List; do you want to append them all', \ 2094 'Unknown atom '+atom[0],wx.YES_NO|wx.ICON_QUESTION) 2095 try: 2096 result = dlg.ShowModal() 2097 if result in [wx.ID_YES,]: 2098 All = True 2099 atomData.append(atom) 2100 else: 2101 print atom[:ct+1], 'not in Atom array; not updated' 2102 finally: 2103 dlg.Destroy() 2091 2104 wx.CallAfter(FillAtomsGrid,Atoms) 2092 2105 … … 2319 2332 2320 2333 ################################################################################ 2321 # Structure drawing GUI stuff2334 #### Structure drawing GUI stuff 2322 2335 ################################################################################ 2323 2336 … … 3835 3848 'Extinction':['Lorentzian','None', 3836 3849 {'Tbar':0.1,'Cos2TM':0.955,'Eg':[1.e-7,False],'Es':[1.e-7,False],'Ep':[1.e-7,False]},], 3837 'Flack':[0.0,False] }3850 'Flack':[0.0,False],'Twins':[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]} 3838 3851 UpdateHKLFdata(histoName) 3839 3852 data['Histograms'] = UseList … … 3860 3873 sourceDict = UseList[hist] 3861 3874 if 'HKLF' in sourceDict['Histogram']: 3862 copyNames = ['Scale','Extinction','Babinet','Flack' ]3875 copyNames = ['Scale','Extinction','Babinet','Flack','Twins'] 3863 3876 else: #PWDR 3864 3877 copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet'] … … 3884 3897 copyNames = ['Scale','Extinction','Babinet','Flack'] 3885 3898 else: #PWDR 3886 copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet' ]3899 copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','Twins'] 3887 3900 babNames = ['BabA','BabU'] 3888 3901 for name in copyNames: 3889 if name in ['Scale','Extinction','HStrain','Flack' ]:3902 if name in ['Scale','Extinction','HStrain','Flack','Twins']: 3890 3903 if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']: 3891 3904 copyDict[name] = {name:[sourceDict[name][:2]]} 3892 3905 for item in ['Eg','Es','Ep']: 3893 3906 copyDict[name][item] = sourceDict[name][2][item][1] 3907 elif name == 'Twins': 3908 for it,twin in enumerate(sourceDict['Twins']): 3909 copyDict[name][it] = twin[1][1] 3894 3910 else: 3895 3911 copyDict[name] = sourceDict[name][1] … … 3919 3935 UseList[item] 3920 3936 for name in copyNames: 3921 if name in ['Scale','Extinction','HStrain','Flack' ]:3937 if name in ['Scale','Extinction','HStrain','Flack','Twins']: 3922 3938 if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']: 3923 3939 UseList[item][name][:2] = copy.deepcopy(sourceDict[name][:2]) 3924 3940 for itm in ['Eg','Es','Ep']: 3925 3941 UseList[item][name][2][itm][1] = copy.deepcopy(copyDict[name][itm]) 3942 elif name == 'Twins': 3943 for it,twin in enumerate(sourceDict['Twins']): 3944 UseList[item]['Twins'][it][1][1] = copyDict['Twins'][it] 3926 3945 else: 3927 3946 UseList[item][name][1] = copy.deepcopy(copyDict[name]) … … 3951 3970 copyDict = {} 3952 3971 if 'HKLF' in sourceDict['Histogram']: 3953 copyNames = ['Scale','Extinction','Babinet','Flack' ]3972 copyNames = ['Scale','Extinction','Babinet','Flack','Twins'] 3954 3973 else: #PWDR 3955 3974 copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet'] -
trunk/GSASIIstrIO.py
r1876 r1884 2027 2027 print >>pFile,varstr 2028 2028 2029 2030 2029 hapDict = {} 2031 2030 hapVary = [] … … 2243 2242 if hapData.get('Flack',[0,False])[1]: 2244 2243 hapVary.append(pfx+'Flack') 2244 Twins = hapData.get('Twins',[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]) 2245 sumTwFr = 0. 2246 for it,twin in enumerate(Twins): 2247 controlDict[pfx+'TwinLaw;'+str(it)] = twin[0] 2248 hapDict[pfx+'TwinFr;'+str(it)] = twin[1][0] 2249 sumTwFr += twin[1][0] 2250 if twin[1][1]: 2251 hapVary.append(pfx+'TwinFr;'+str(it)) 2252 for it,twin in enumerate(Twins): #force sum to unity 2253 hapDict[pfx+'TwinFr;'+str(it)] /= sumTwFr 2245 2254 if Print: 2246 2255 print >>pFile,'\n Phase: ',phase,' in histogram: ',histogram … … 2257 2266 if not SGData['SGInv']: 2258 2267 print >>pFile,' Flack parameter: %10.3f'%(hapData['Flack'][0]),' Refine?',hapData['Flack'][1] 2268 if len(Twins) > 1: 2269 for it,twin in enumerate(Twins): 2270 print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr;'+str(it)]),twin[1][1] 2271 2259 2272 Histogram['Reflection Lists'] = phase 2260 2273 … … 2409 2422 print >>pFile,ptstr 2410 2423 print >>pFile,sigstr 2424 2425 def PrintTwinsAndSig(pfx,hapData,TwinSig): 2426 print >>pFile,'\n Twin Law fractions : ' 2427 ptlbls = ' names :' 2428 ptstr = ' values:' 2429 sigstr = ' sig :' 2430 for item in hapData: 2431 ptlbls += '%12s'%(item) 2432 ptstr += '%12.3f'%(hapData[item][0]) 2433 if pfx+item in TwinSig: 2434 sigstr += '%12.3f'%(TwinSig[pfx+item]) 2435 else: 2436 sigstr += 12*' ' 2437 print >>pFile,ptlbls 2438 print >>pFile,ptstr 2439 print >>pFile,sigstr 2440 2411 2441 2412 2442 PhFrExtPOSig = {} … … 2414 2444 ScalExtSig = {} 2415 2445 BabSig = {} 2446 TwinFrSig = {} 2416 2447 wtFrSum = {} 2417 2448 for phase in Phases: … … 2496 2527 if pfx+item in sigDict: 2497 2528 ScalExtSig[pfx+item] = sigDict[pfx+item] 2498 for name in ['BabA','BabU']: 2499 hapData['Babinet'][name][0] = parmDict[pfx+name] 2500 if pfx+name in sigDict: 2501 BabSig[pfx+name] = sigDict[pfx+name] 2529 for item in ['BabA','BabU']: 2530 hapData['Babinet'][item][0] = parmDict[pfx+item] 2531 if pfx+item in sigDict: 2532 BabSig[pfx+item] = sigDict[pfx+item] 2533 item = 'TwinFr' 2534 it = 0 2535 while True: 2536 try: 2537 hapData['TwinFr'][1][0] = parmDict[pfx+'TwinFr;'+str(it)] 2538 if pfx+'TwinFr;'+str(it) in sigDict: 2539 TwinFrSig[pfx+'TwinFr;'+str(it)] = sigDict[pfx+'TwinFr;'+str(it)] 2540 it += 1 2541 except KeyError: 2542 break 2502 2543 2503 2544 if Print: … … 2561 2602 if pfx+'Flack' in ScalExtSig: 2562 2603 print >>pFile,' Flack parameter : %10.3f, sig %10.3f'%(hapData['Flack'][0],ScalExtSig[pfx+'Flack']) 2604 if pfx+'TwinFr;1' in TwinFrSig: 2605 PrintTwinFrAndSig(pfx,hapData['TwinFr'],TwinFrSig) 2563 2606 2564 2607 ################################################################################ -
trunk/GSASIIstrMath.py
r1880 r1884 12 12 ########### SVN repository information ################### 13 13 import time 14 import math15 14 import copy 16 15 import numpy as np … … 36 35 atan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi 37 36 38 ateln2 = 8.0* math.log(2.0)37 ateln2 = 8.0*np.log(2.0) 39 38 twopi = 2.0*np.pi 40 39 twopisq = 2.0*np.pi**2 -
trunk/imports/G2sfact.py
r1832 r1884 85 85 return False 86 86 87 class HKLF 2_ReaderClass(G2IO.ImportStructFactor):88 'Routines to import F**2, sig(F**2) reflections from a HKLF file'89 def __init__(self): 90 if 'linux' in sys.platform: # wx 3.0.0.0 on gtk does not like Unicode in menus 91 formatName = 'HKL F2'92 longFormatName = 'S imple[hkl, Fo2, sig(Fo2)] Structure factor text file'87 class HKLF4_ReaderClass(G2IO.ImportStructFactor): 88 'Routines to import F**2, sig(F**2) reflections from a HKLF 4 file' 89 def __init__(self): 90 if 'linux' in sys.platform: # wx 3.0.0.0 on gtk does not like Unicode in menus 91 formatName = 'HKL 4' 92 longFormatName = 'Shelx HKL4 [hkl, Fo2, sig(Fo2)] Structure factor text file' 93 93 else: 94 94 formatName = u'HKL F\u00b2' 95 longFormatName = u'S imple[hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'95 longFormatName = u'Shelx HKL4 [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file' 96 96 super(self.__class__,self).__init__( # fancy way to self-reference 97 97 extensionlist=('.hkl','.HKL'), … … 203 203 204 204 class SHELX5_ReaderClass(G2IO.ImportStructFactor): 205 'Routines to import F**2, sig(F**2) reflections from a fixed format SHELX HKLF5 file'206 def __init__(self): 207 if 'linux' in sys.platform: # wx 3.0.0.0 on gtk does not like Unicode in menus 208 formatName = 'SHELX HKL F2'209 longFormatName = 'SHELX HKLF5 [hkl , Fo2, sig(Fo2)] Structure factor text file'205 'Routines to import F**2, sig(F**2) twin index reflections from a fixed format SHELX HKLF5 file' 206 def __init__(self): 207 if 'linux' in sys.platform: # wx 3.0.0.0 on gtk does not like Unicode in menus 208 formatName = 'SHELX HKL5 F2' 209 longFormatName = 'SHELX HKLF5 [hklm, Fo2, sig(Fo2), Tind] Structure factor text file' 210 210 else: 211 211 formatName = u'SHELX HKL F\u00b2' 212 longFormatName = u'SHELX HKLF5 [hkl , Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'212 longFormatName = u'SHELX HKLF5 [hklm, Fo\u00b2, sig(Fo\u00b2), Tind] Structure factor text file' 213 213 super(self.__class__,self).__init__( # fancy way to self-reference 214 214 extensionlist=('.hkl','.HKL'), … … 222 222 numCols = 0 223 223 for i,line in enumerate(filepointer): 224 numCols = max(numCols,len(line ))224 numCols = max(numCols,len(line.split())) 225 225 if i > 20: 226 226 break 227 self.Super = (numCols-33)/4 #= 0,1,2,or 3 228 print numCols,self.Super 227 self.Super = numCols-6 #= 0,1,2,or 3 228 if self.Super > 1: 229 raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry") 229 230 return True #ColumnValidator(self, filepointer) 230 231 … … 235 236 self.errors = ' Error reading line '+str(line+1) 236 237 if self.Super == 0: 237 h,k,l,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:20],S[20:28]238 h,k,l,Fo,sigFo,Tw = S.split() 238 239 h,k,l = [int(h),int(k),int(l)] 239 240 elif self.Super == 1: 240 h,k,l,m1,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:16],S[16:24],S[24:32]241 h,k,l,m1,Fo,sigFo,Tw = S.split() 241 242 h,k,l,m1 = [int(h),int(k),int(l),int(m1)] 242 elif self.Super == 2:243 h,k,l,m1,m2,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:16],S[16:20],S[20:28],S[28:36]244 h,k,l,m1,m2 = [int(h),int(k),int(l),int(m1),int(m2)]245 elif self.Super == 3:246 h,k,l,m1,m2,m3,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:16],S[16:20],S[20:24],S[24:32],S[32:40]247 h,k,l,m1,m2,m3 = [int(h),int(k),int(l),int(m1),int(m2),int(m3)]248 243 if not any([h,k,l]): 249 244 break … … 252 247 # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,... 253 248 if self.Super == 0: 254 self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0 ])249 self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0,Tw]) 255 250 elif self.Super == 1: 256 self.RefDict['RefList'].append([h,k,l,m1,0,0,Fo,sigFo,0,Fo,0,0,0]) 257 elif self.Super == 2: 258 self.RefDict['RefList'].append([h,k,l,m1,m2,0,0,Fo,sigFo,0,Fo,0,0,0]) 259 elif self.Super == 3: 260 self.RefDict['RefList'].append([h,k,l,m1,m2,m3,0,0,Fo,sigFo,0,Fo,0,0,0]) 251 self.RefDict['RefList'].append([h,k,l,m1,0,0,Fo,sigFo,0,Fo,0,0,0,Tw]) 261 252 #self.RefDict['FF'].append({}) # now done in OnImportSfact 262 253 self.errors = 'Error after reading reflections (unexpected!)'
Note: See TracChangeset
for help on using the changeset viewer.