Changeset 5112
- Timestamp:
- Dec 15, 2021 4:56:41 PM (22 months ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIddataGUI.py
r5043 r5112 80 80 G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist) 81 81 82 ifkeV = 'E' in UseList[G2frame.hist].get('Type','') 82 83 plotSizer = wx.BoxSizer(wx.VERTICAL) 83 choice = ['None','Mustrain','Size','Preferred orientation','St. proj. Inv. pole figure','Eq. area Inv. pole figure'] 84 if ifkeV: 85 choice = ['None','Mustrain','Size'] 86 else: 87 choice = ['None','Mustrain','Size','Preferred orientation','St. proj. Inv. pole figure','Eq. area Inv. pole figure'] 84 88 plotSel = wx.RadioBox(DData,wx.ID_ANY,'Select plot type:',choices=choice, 85 89 majorDimension=1,style=wx.RA_SPECIFY_COLS) … … 842 846 843 847 def OnLeBail(event): 844 Obj = event.GetEventObject()845 848 if not UseList[G2frame.hist]['LeBail']: 846 849 Controls['newLeBail'] = True … … 905 908 UseList[G2frame.hist]['Layer Disp'] = [0.0,False] 906 909 #end patch 910 ifkeV = 'E' in UseList[G2frame.hist].get('Type','') 907 911 offMsg = '' 908 912 bottomSizer = wx.BoxSizer(wx.VERTICAL) … … 920 924 lebail.Bind(wx.EVT_BUTTON, OnLeBail) 921 925 useBox.Add(lebail,0,WACV) 922 bottomSizer.Add(useBox,0,wx.TOP|wx.BOTTOM|wx.LEFT,5) 926 bottomSizer.Add(useBox) #,0,wx.TOP|wx.BOTTOM|wx.LEFT,5) 927 if ifkeV: 928 G2G.HorizontalLine(bottomSizer,DData) 929 bottomSizer.Add(wx.StaticText(DData,label=' NB: No structure or sample broadening refinement possible from energy dispersive data')) 930 G2G.HorizontalLine(bottomSizer,DData) 923 931 if G2frame.testSeqRefineMode() and not UseList[G2frame.hist]['LeBail']: 924 932 bottomSizer.Add(wx.StaticText(DData,label=' Sequential Refinement Options')) … … 950 958 951 959 if G2frame.hist[:4] == 'PWDR': 952 if UseList[G2frame.hist]['Size'][0] == 'isotropic': 953 isoSizer = wx.BoxSizer(wx.HORIZONTAL) 954 isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 955 'Size',OnSizeType),0,WACV) 956 isoSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 957 isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV) 958 bottomSizer.Add(isoSizer) 959 bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size',(10,4),[0.,10.],OnSizeRef),0,wx.BOTTOM,5) 960 elif UseList[G2frame.hist]['Size'][0] == 'uniaxial': 961 uniSizer = wx.BoxSizer(wx.HORIZONTAL) 962 uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 963 'Size',OnSizeType),0,WACV) 964 uniSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 965 uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV) 966 bottomSizer.Add(UniSizer('Size',OnSizeAxis),0) 967 bottomSizer.Add(uniSizer) 968 bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size',(10,3),[0.,10.],OnSizeRef),0,wx.BOTTOM,5) 969 elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal': 970 ellSizer = wx.BoxSizer(wx.HORIZONTAL) 971 ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 972 'Size',OnSizeType),0,WACV) 973 ellSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 974 ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV) 975 bottomSizer.Add(ellSizer) 976 bottomSizer.Add(EllSizeDataSizer(),0,wx.BOTTOM,5) 977 978 if UseList[G2frame.hist]['Mustrain'][0] == 'isotropic': 979 isoSizer = wx.BoxSizer(wx.HORIZONTAL) 980 isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 981 'Mustrain',OnStrainType),0,WACV) 982 isoSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 983 isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV) 984 bottomSizer.Add(isoSizer) 985 bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5) 986 elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial': 987 uniSizer = wx.BoxSizer(wx.HORIZONTAL) 988 uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 989 'Mustrain',OnStrainType),0,WACV) 990 uniSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 991 uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV) 992 bottomSizer.Add(uniSizer) 993 bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0) 994 bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5) 995 elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized': 996 genSizer = wx.BoxSizer(wx.HORIZONTAL) 997 genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 998 'Mustrain',OnStrainType),0,WACV) 999 genSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 1000 genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV) 1001 bottomSizer.Add(genSizer) 1002 bottomSizer.Add(GenStrainDataSizer(),0,wx.BOTTOM,5) 1003 960 if not ifkeV: 961 if UseList[G2frame.hist]['Size'][0] == 'isotropic': 962 isoSizer = wx.BoxSizer(wx.HORIZONTAL) 963 isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 964 'Size',OnSizeType),0,WACV) 965 isoSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 966 isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV) 967 bottomSizer.Add(isoSizer) 968 bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size',(10,4),[0.,10.],OnSizeRef),0,wx.BOTTOM,5) 969 elif UseList[G2frame.hist]['Size'][0] == 'uniaxial': 970 uniSizer = wx.BoxSizer(wx.HORIZONTAL) 971 uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 972 'Size',OnSizeType),0,WACV) 973 uniSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 974 uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV) 975 bottomSizer.Add(UniSizer('Size',OnSizeAxis),0) 976 bottomSizer.Add(uniSizer) 977 bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size',(10,3),[0.,10.],OnSizeRef),0,wx.BOTTOM,5) 978 elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal': 979 ellSizer = wx.BoxSizer(wx.HORIZONTAL) 980 ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'], 981 'Size',OnSizeType),0,WACV) 982 ellSizer.Add(LGmixSizer('Size',[0.,1.],OnLGmixRef)) 983 ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV) 984 bottomSizer.Add(ellSizer) 985 bottomSizer.Add(EllSizeDataSizer(),0,wx.BOTTOM,5) 986 987 if UseList[G2frame.hist]['Mustrain'][0] == 'isotropic': 988 isoSizer = wx.BoxSizer(wx.HORIZONTAL) 989 isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 990 'Mustrain',OnStrainType),0,WACV) 991 isoSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 992 isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV) 993 bottomSizer.Add(isoSizer) 994 bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5) 995 elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial': 996 uniSizer = wx.BoxSizer(wx.HORIZONTAL) 997 uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 998 'Mustrain',OnStrainType),0,WACV) 999 uniSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 1000 uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV) 1001 bottomSizer.Add(uniSizer) 1002 bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0) 1003 bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain',(10,1),[0.,1.e5],OnStrainRef),0,wx.BOTTOM,5) 1004 elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized': 1005 genSizer = wx.BoxSizer(wx.HORIZONTAL) 1006 genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',], 1007 'Mustrain',OnStrainType),0,WACV) 1008 genSizer.Add(LGmixSizer('Mustrain',[0.,1.],OnLGmixRef)) 1009 genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV) 1010 bottomSizer.Add(genSizer) 1011 bottomSizer.Add(GenStrainDataSizer(),0,wx.BOTTOM,5) 1012 1004 1013 bottomSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Hydrostatic/elastic strain:')) 1005 1014 bottomSizer.Add(HstrainSizer()) 1006 1015 bottomSizer.Add(DispSizer()) 1007 1016 1008 if not UseList[G2frame.hist]['LeBail'] :1017 if not UseList[G2frame.hist]['LeBail'] and not ifkeV: 1009 1018 poSizer = wx.BoxSizer(wx.VERTICAL) 1010 1019 POData = UseList[G2frame.hist]['Pref.Ori.'] … … 1024 1033 poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Spherical harmonic coefficients: '+'Texture index: %.3f'%(textJ)) 1025 1034 ,0,wx.TOP|wx.BOTTOM,5) 1026 poSizer.Add(SHDataSizer(POData) ,0,wx.TOP|wx.BOTTOM,5)1027 poSizer.Add(SHPenalty(POData) ,0,wx.TOP|wx.BOTTOM,5)1035 poSizer.Add(SHDataSizer(POData)) #,0,wx.TOP|wx.BOTTOM,5) 1036 poSizer.Add(SHPenalty(POData)) #,0,wx.TOP|wx.BOTTOM,5) 1028 1037 1029 bottomSizer.Add(poSizer ,0,wx.TOP|wx.BOTTOM,5)1038 bottomSizer.Add(poSizer) #,0,wx.TOP|wx.BOTTOM,5) 1030 1039 bottomSizer.Add(ExtSizer('PWDR'),0,wx.TOP|wx.BOTTOM,5) 1031 1040 if generalData['Type'] != 'magnetic': 1032 1041 bottomSizer.Add(BabSizer(),0,wx.BOTTOM,5) 1033 # else: #turn off PWDR intensity related paramters for LeBail refinement1034 # if UseList[G2frame.hist]['Scale'][1]:1035 # offMsg = "Phase fraction"1036 # UseList[G2frame.hist]['Scale'][1] = False1037 # if UseList[G2frame.hist]['Pref.Ori.'][2]:1038 # UseList[G2frame.hist]['Pref.Ori.'][2] = False1039 # if offMsg: offMsg += ', '1040 # offMsg += 'Preferred orientation'1041 # if UseList[G2frame.hist]['Extinction'][1]:1042 # UseList[G2frame.hist]['Extinction'][1] = False1043 # if offMsg: offMsg += ', '1044 # offMsg += 'Extinction'1045 # flag = False1046 # for item in UseList[G2frame.hist]['Babinet']:1047 # if UseList[G2frame.hist]['Babinet'][item][1]:1048 # UseList[G2frame.hist]['Babinet'][item][1] = False1049 # flag = True1050 # if flag:1051 # if offMsg: offMsg += ', '1052 # offMsg += 'Babinet'1053 # # make sure that the at least one phase uses the histogram...1054 # allLeBail = True1055 # hists,phases = G2frame.GetUsedHistogramsAndPhasesfromTree()1056 # for key in phases:1057 # d = phases[key]1058 # if G2frame.hist not in d['Histograms']: continue1059 # if not d['Histograms'][G2frame.hist]['Use']: continue1060 # if not d['Histograms'][G2frame.hist]['LeBail']:1061 # #print('Phase',key,'is used as non-LeBail')1062 # allLeBail = False1063 # break1064 # # ...or turn off scale1065 # if allLeBail:1066 # if hists[G2frame.hist]['Sample Parameters']['Scale'][1]:1067 # hists[G2frame.hist]['Sample Parameters']['Scale'][1] = False1068 # if offMsg: offMsg += ', '1069 # offMsg += 'Histogram scale factor'1070 # if offMsg:1071 # offMsg = "Refinement flags turned for: " + offMsg1072 1042 elif G2frame.hist[:4] == 'HKLF': 1073 bottomSizer.Add(ExtSizer('HKLF') ,0,wx.BOTTOM,5)1074 bottomSizer.Add(BabSizer() ,0,wx.BOTTOM,5)1043 bottomSizer.Add(ExtSizer('HKLF')) #,0,wx.BOTTOM,5) 1044 bottomSizer.Add(BabSizer()) #,0,wx.BOTTOM,5) 1075 1045 if not SGData['SGInv'] and len(UseList[G2frame.hist]['Twins']) < 2: 1076 bottomSizer.Add(FlackSizer() ,0,wx.BOTTOM,5)1077 bottomSizer.Add(twinSizer() ,0,wx.BOTTOM,5)1046 bottomSizer.Add(FlackSizer()) #,0,wx.BOTTOM,5) 1047 bottomSizer.Add(twinSizer()) #,0,wx.BOTTOM,5) 1078 1048 return bottomSizer,offMsg 1079 1049 … … 1131 1101 LeBailMsg = None 1132 1102 if G2frame.hist: 1103 ifkeV = 'E' in UseList[G2frame.hist].get('Type','') 1133 1104 topSizer = wx.FlexGridSizer(1,2,5,5) 1134 1105 DData.select = wx.ListBox(DData,choices=G2frame.dataWindow.HistsInPhase, … … 1138 1109 DData.select.Bind(wx.EVT_LISTBOX,OnSelect) 1139 1110 topSizer.Add(DData.select,0,WACV|wx.LEFT,5) 1140 if any(['PWDR' in item for item in keyList]) :1111 if any(['PWDR' in item for item in keyList]) and not ifkeV: 1141 1112 topSizer.Add(PlotSizer()) 1142 1113 mainSizer.Add(topSizer) … … 1154 1125 G2phG.SetPhaseWindow(DData,mainSizer,Scroll=Scroll) 1155 1126 if LeBailMsg: 1156 G2G.G2MessageBox(G2frame,LeBailMsg, 1157 title='LeBail refinement changes') 1127 G2G.G2MessageBox(G2frame,LeBailMsg,title='LeBail refinement changes') 1158 1128 1159 1129 def MakeHistPhaseWin(G2frame): -
trunk/GSASIIfiles.py
r5096 r5112 277 277 Inst2['Icovar'] = Icovar 278 278 return [Inst1,Inst2] 279 elif 'E' in DataType: 280 tth = float(Iparm['INS 1 ICONS']) 281 s = Iparm['INS 1PRCF11'].split() 282 names = ['Type','2-theta','XE','YE','ZE','A','B', 'C'] 283 codes = [0,0,0,0,0,0,0,0] 284 data.extend([tth,0.0,0.0,0.0,sfloat(s[0]),sfloat(s[1]),sfloat(s[2])]) #A,B,C 285 Iparm1 = makeInstDict(names,data,codes) 286 Iparm1['Bank'] = [Bank,Bank,0] 287 return [Iparm1,{}] 279 288 280 289 def ReadPowderInstprm(instLines, bank, databanks, rd): -
trunk/GSASIIindex.py
r5098 r5112 636 636 return True,chisq,A,Z,result 637 637 638 def FitHKLE(tth,ibrav,peaks,A): 639 'needs a doc string' 640 641 def errFitE(values,ibrav,d,H,keV,tth): 642 A = Values2A(ibrav,values) 643 Qo = 1./d**2 644 Qc = G2lat.calc_rDsq(H,A) 645 return (Qo-Qc) 646 647 def dervFitE(values,ibrav,d,H,keV,tth): 648 if ibrav in [0,1,2]: 649 derv = [H[0]*H[0]+H[1]*H[1]+H[2]*H[2],] 650 elif ibrav in [3,4,]: 651 derv = [H[0]*H[0]+H[1]*H[1]+H[0]*H[1],H[2]*H[2]] 652 elif ibrav in [5,6]: 653 derv = [H[0]*H[0]+H[1]*H[1],H[2]*H[2]] 654 elif ibrav in [7,8,9,10,11,12]: 655 derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2]] 656 elif ibrav in [13,14,15,16]: 657 derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[2]] 658 else: 659 derv = [H[0]*H[0],H[1]*H[1],H[2]*H[2],H[0]*H[1],H[0]*H[2],H[1]*H[2]] 660 derv = np.array(derv) 661 return derv.T 662 663 Peaks = np.array(peaks).T 664 values = A2values(ibrav,A) 665 result = so.leastsq(errFitE,values,Dfun=dervFitE,full_output=True,ftol=0.0001, 666 args=(ibrav,Peaks[7],Peaks[4:7],Peaks[0],tth)) 667 A = Values2A(ibrav,result[0]) 668 chisq = np.sum(errFitE(result[0],ibrav,Peaks[7],Peaks[4:7],Peaks[0],tth)**2) 669 return True,chisq,A,result 670 638 671 def errFitTSS(values,ibrav,d,H,tof,difC,vec,Vref,Z,Zref): 639 672 Zero = Z … … 761 794 M20,X20 = calc_M20(peaks,HKL) 762 795 return len(HKL),M20,X20,Aref,Z 796 797 def refinePeaksE(peaks,tth,ibrav,A): 798 'needs a doc string' 799 dmin = getDmin(peaks) 800 OK,smin,Aref,result = FitHKLE(tth,ibrav,peaks,A) 801 Peaks = np.array(peaks).T 802 H = Peaks[4:7] 803 Peaks[8] = 1./np.sqrt(G2lat.calc_rDsq(H,Aref)) 804 peaks = Peaks.T 805 HKL = G2lat.GenHBravais(dmin,ibrav,A) 806 M20,X20 = calc_M20(peaks,HKL) 807 return len(HKL),M20,X20,Aref 763 808 764 809 def refinePeaksZSS(peaks,wave,Inst,SGData,SSGData,maxH,ibrav,A,vec,vecRef,Zero,ZeroRef): -
trunk/GSASIIlattice.py
r5105 r5112 1141 1141 def Pos2dsp(Inst,pos): 1142 1142 ''' convert powder pattern position (2-theta or TOF, musec) to d-spacing 1143 is currently only approximate for EDX data; accurate for others. 1143 1144 ''' 1144 1145 if 'T' in Inst['Type'][0]: 1145 1146 return TOF2dsp(Inst,pos) 1147 elif 'E' in Inst['Type'][0]: 1148 return 12.398/(2.0*pos*sind(Inst['2-theta'][1]/2.0)) 1146 1149 else: #'PKS', 'C' or 'B' 1147 1150 wave = G2mth.getWave(Inst) … … 1170 1173 if 'T' in Inst['Type'][0]: 1171 1174 pos = Inst['difC'][1]*dsp+Inst['Zero'][1]+Inst['difA'][1]*dsp**2+Inst.get('difB',[0,0,False])[1]/dsp 1175 elif 'E' in Inst['Type'][0]: 1176 return 12.398/(2.0*dsp*sind(Inst['2-theta'][1]/2.0)+Inst['ZE'][1]+Inst['YE'][1]*dsp+Inst['XE'][1]*dsp**2) 1172 1177 else: #'C' or 'B' 1173 1178 wave = G2mth.getWave(Inst) … … 1177 1182 1178 1183 def getPeakPos(dataType,parmdict,dsp): 1179 ''' convert d-spacing to powder pattern position (2-theta or TOF, musec)1184 ''' convert d-spacing to powder pattern position (2-theta, E or TOF, musec) 1180 1185 ''' 1181 1186 if 'T' in dataType: 1182 1187 pos = parmdict['difC']*dsp+parmdict['difA']*dsp**2+parmdict['difB']/dsp+parmdict['Zero'] 1188 elif 'E'in dataType: 1189 pos = 12.398/(2.0*dsp*sind(parmdict['2-theta']/2.0)+parmdict['ZE']+parmdict['YE']*dsp+parmdict['XE']*dsp**2) 1183 1190 else: #'C' or 'B' 1184 1191 pos = 2.0*asind(parmdict['Lam']/(2.*dsp))+parmdict['Zero'] -
trunk/GSASIImath.py
r5104 r5112 4513 4513 ''' 4514 4514 return 1./cosd(pos/2.0),tand(pos/2.0),1.0 4515 4516 def getEDsig(ins,pos): 4517 '''get ED peak profile sig 4518 4519 :param dict ins: instrument parameters with at least 'A', 'B' & 'C' 4520 as values only 4521 :param float pos: energy of peak as keV 4522 :returns: float getEDsig: peak sigma^2 im keV**2 4523 4524 ''' 4525 return ins['A']*pos**2+ins['B']*pos+ins['C'] 4526 4527 def getEDsigDeriv(ins,pos): 4528 '''get derivatives of ED peak profile sig wrt A, B & C 4529 4530 :param float pos: energy of peak in keV 4531 4532 :returns: list getEDsigDeriv: d(sig)/dA, d(sig)/dB & d(sig)/dC, 4533 4534 ''' 4535 return pos**2,pos,1.0 4515 4536 4516 4537 def getTOFsig(ins,dsp): … … 4705 4726 gam = getCWgam(ins,pos) 4706 4727 XY = [pos,0,mag,1,alp,0,bet,0,sig,0,gam,0] #default refine intensity 1st 4728 elif 'E' in Parms['Type'][0]: 4729 for x in ['A','B','C']: 4730 ins[x] = Parms.get(x,[0.0,0.0])[ind] 4731 sig = getEDsig(ins,pos) 4732 XY = [pos,0,mag,1,sig,0] #default refine intensity 1st 4733 4707 4734 return XY 4708 4735 -
trunk/GSASIIphsGUI.py
r5111 r5112 6200 6200 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_VIEWRMC,False) 6201 6201 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,False) 6202 #G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_STOPRMC,True)6203 6202 if G2frame.FRMC.GetSizer(): 6204 6203 G2frame.FRMC.GetSizer().Clear(True) … … 6211 6210 RMCsel.Bind(wx.EVT_RADIOBOX, OnRMCselect) 6212 6211 mainSizer.Add(RMCsel,0) 6213 mainSizer.Add((5,5),0) 6212 G2G.HorizontalLine(mainSizer,G2frame.FRMC) 6213 mainSizer.Add(wx.StaticText(G2frame.FRMC, 6214 label=' NB: if you change any of the entries below, you must redo the Operations/Setup RMC step \n above to apply them before doing Operations/Execute'),0,WACV) 6215 G2G.HorizontalLine(mainSizer,G2frame.FRMC) 6214 6216 if G2frame.RMCchoice == 'fullrmc': 6215 6217 RMCPdict = data['RMC']['fullrmc'] … … 10752 10754 for histoName in newList: 10753 10755 Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,histoName) 10756 Inst = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Instrument Parameters'))[0] 10754 10757 data['Histograms'][histoName] = {'Histogram':histoName,'Show':False,'LeBail':False,'newLeBail':True, 10755 10758 'Scale':[1.0,False],'Pref.Ori.':['MD',1.0,False,[0,0,1],0,{},['',],0.1], 10756 10759 'Size':['isotropic',[1.,1.,1.],[False,False,False],[0,0,1], 10757 [1.,1.,1.,0.,0.,0.],6*[False,]], 10760 [1.,1.,1.,0.,0.,0.],6*[False,]],'Type':Inst['Type'][0], 10758 10761 'Mustrain':['isotropic',[1000.0,1000.0,1.0],[False,False,False],[0,0,1], 10759 10762 NShkl*[0.01,],NShkl*[False,]], -
trunk/GSASIIplot.py
r5109 r5112 2321 2321 if 'T' in Parms['Type'][0]: # TOF 2322 2322 dT = Parms['difC'][1] * 2 * np.pi * tolerance / q**2 2323 elif 'E' in Parms['Type'][0]: # energy dispersive x-rays 2324 pass #for now 2323 2325 else: # 'C' or 'B' in Parms['Type'][0] or 'PKS' in Parms['Type'][0]: 2324 2326 wave = G2mth.getWave(Parms) … … 2360 2362 else: 2361 2363 G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d=%9.5f Q=%9.5f Intensity =%9.2f'%(xpos,dsp,q,ypos),1) 2364 elif 'E' in Parms['Type'][0]: 2365 G2frame.G2plotNB.status.SetStatusText('Energy =%9.3f d=%9.5f Q=%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1) 2362 2366 else: 2363 2367 if 'PWDR' in plottype: … … 3326 3330 else: 3327 3331 xLabel = r'$TOF, \mathsf{\mu}$s' 3332 elif 'E' in ParmList[0]['Type'][0]: 3333 xLabel = 'E, keV' 3328 3334 else: 3329 3335 xLabel = r'$\mathsf{2\theta}$' … … 3408 3414 if ('C' in ParmList[0]['Type'][0] and Page.plotStyle['dPlot']) or \ 3409 3415 ('B' in ParmList[0]['Type'][0] and Page.plotStyle['dPlot']) or \ 3416 ('E' in ParmList[0]['Type'][0] and Page.plotStyle['dPlot']) or \ 3410 3417 ('T' in ParmList[0]['Type'][0] and Page.plotStyle['qPlot']): # reversed regions relative to data order 3411 3418 tcorner = 1 … … 5350 5357 5351 5358 for N,Pattern in enumerate(PlotList): 5352 xye = Pattern[1]5359 xye = np.array(Pattern[1]) 5353 5360 X = xye[0] 5354 5361 if not lenX: … … 6315 6322 return 6316 6323 elif 'T' in Parms['Type'][0]: 6317 difC = Parms['difC'][0] 6324 difC = Parms['difC'][1] 6325 elif 'E' in Parms['Type'][0]: 6326 tth = Parms['2-theta'][1] 6318 6327 else: 6319 6328 lam = G2mth.getWave(Parms) … … 6369 6378 Plot.plot(Q,G,color='m',label='Lorentzian') 6370 6379 6371 fit = G2mth.setPeakparms(Parms,Parms2,T,Z )6380 fit = G2mth.setPeakparms(Parms,Parms2,T,Z,useFit=True) 6372 6381 ds = T/difC 6373 6382 Q = 2.*np.pi/ds … … 6402 6411 Plot.plot(Qp,Gp,'+',color='m',label='Lorentzian peak') 6403 6412 Plot.legend(loc='best') 6413 elif 'E' in Parms['Type'][0]: 6414 isig = 4 6415 Plot.set_title('Instrument and sample peak widths') 6416 Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=14) 6417 Plot.set_ylabel(r'$\Delta Q/Q, \Delta d/d$',fontsize=14) 6418 Xmin,Xmax = limits[1] 6419 X = np.linspace(Xmin,Xmax,num=101,endpoint=True) 6420 Q = 2.*np.pi*X*npsind(tth/2.)/12.3986 6421 Z = np.ones_like(X) 6422 data = G2mth.setPeakparms(Parms,Parms2,X,Z) 6423 s = np.sqrt(data[isig]) #var -> sig(radians) 6424 Y = sq8ln2*s/X 6425 Plot.plot(Q,Y,color='r',label='Gaussian') 6426 6427 fit = G2mth.setPeakparms(Parms,Parms2,X,Z,useFit=True) 6428 sf = np.sqrt(fit[isig]) 6429 Yf = sq8ln2*sf/X 6430 Plot.plot(Q,Yf,color='r',dashes=(5,5),label='Gaussian fit') 6431 6432 Xp = [] 6433 Yp = [] 6434 for peak in peaks: 6435 Xp.append(2.*np.pi*peak[0]*npsind(tth/2.)/12.3986) 6436 try: 6437 s = math.sqrt(peak[isig]) 6438 except ValueError: 6439 s = 0.01 6440 Yp.append(sq8ln2*s/peak[0]) 6441 if len(peaks): 6442 Plot.plot(Xp,Yp,'+',color='r',label='G peak') 6443 legend = Plot.legend(loc='best') 6444 SetupLegendPick(legend,new) 6445 Page.canvas.draw() 6446 6404 6447 else: #'C' & 'B' 6405 6448 isig = 4 -
trunk/GSASIIpwd.py
r5107 r5112 807 807 return widths,fmin,fmax 808 808 809 def getWidthsED(pos,sig): 810 '''Compute the peak widths used for computing the range of a peak 811 for energy dispersive data. On low-energy side, 20 FWHM are used, 812 on high-energy side 20 are used 813 814 :param pos: peak position; energy in keV 815 :param sig: Gaussian peak variance in keV^2 816 817 :returns: widths; [Gaussian sigma] in keV, and 818 low angle, high angle ends of peak; 20 FWHM & 50 FWHM from position 819 ''' 820 widths = [np.sqrt(sig),.001] 821 fwhm = 2.355*widths[0] 822 fmin = 5.*fwhm 823 fmax = 5.*fwhm 824 return widths,fmin,fmax 825 809 826 def getWidthsTOF(pos,alp,bet,sig,gam): 810 827 '''Compute the peak widths used for computing the range of a peak … … 837 854 838 855 sig = lambda Th,U,V,W: np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W)) 856 sigED = lambda E,A,B,C: np.sqrt(max(0.001,A*E**2+B*E+C)) 839 857 sigTOF = lambda dsp,S0,S1,S2,Sq: np.sqrt(S0+S1*dsp**2+S2*dsp**4+Sq*dsp) 840 858 gam = lambda Th,X,Y,Z: Z+X/cosd(Th)+Y*tand(Th) … … 855 873 g = gam(pos/2.,Inst['X'][1],Inst['Y'][1],Inst['Z'][1]) 856 874 return getgamFW(g,s)/100. #returns FWHM in deg 875 elif 'E' in Inst['Type'][0]: 876 s = sigED(pos,Inst['A'][1],Inst['B'][1],Inst['C'][1]) 877 return 2.35482*s 857 878 else: #'B' 858 879 alp = alpPink(pos,Inst['alpha-0'][1],Inst['alpha-1'][1]) … … 943 964 yb = bakInt(ma.getdata(xdata)) 944 965 sumBk[0] = np.sum(yb) 945 #Debye function 946 if pfx+'difC' in parmDict :966 #Debye function 967 if pfx+'difC' in parmDict or 'E' in parmDict[pfx+'Type']: 947 968 ff = 1. 948 969 else: … … 1210 1231 param gam: Lorentzian width in centideg 1211 1232 1212 returns: arrays: function and derivatives of pos, sig, gam, & shl 1233 returns: arrays: function and derivatives of pos, sig & gam 1234 NB: the pos derivative has the opposite sign compared to that in other profile functions 1213 1235 ''' 1214 1236 … … 1430 1452 except KeyError: #no more peaks to process 1431 1453 return yb+yc 1454 elif 'E' in dataType: 1455 iPeak = 0 1456 dsp = 1.0 #for now - fix later 1457 while True: 1458 try: 1459 pos = parmDict['pos'+str(iPeak)] 1460 intens = parmDict['int'+str(iPeak)] 1461 sigName = 'sig'+str(iPeak) 1462 if sigName in varyList or not peakInstPrmMode: 1463 sig = parmDict[sigName] 1464 else: 1465 sig = G2mth.getEDsig(parmDict,pos) 1466 sig = max(sig,0.001) #avoid neg sigma^2 1467 Wd,fmin,fmax = getWidthsED(pos,sig) 1468 iBeg = np.searchsorted(xdata,pos-fmin) 1469 iFin = max(iBeg+3,np.searchsorted(xdata,pos+fmin)) 1470 if not iBeg+iFin: #peak below low limit 1471 iPeak += 1 1472 continue 1473 elif not iBeg-iFin: #peak above high limit 1474 return yb+yc 1475 yc[iBeg:iFin] += intens*getPsVoigt(pos,sig*10.**4,0.001,xdata[iBeg:iFin])[0] 1476 iPeak += 1 1477 except KeyError: #no more peaks to process 1478 return yb+yc 1432 1479 elif 'B' in dataType: 1433 1480 iPeak = 0 … … 1589 1636 Wd,fmin,fmax = getWidthsCW(pos,sig,gam,shl) 1590 1637 iBeg = np.searchsorted(xdata,pos-fmin) 1591 iFin = np.searchsorted(xdata,pos+fmin)1638 iFin = max(iBeg+3,np.searchsorted(xdata,pos+fmin)) 1592 1639 if not iBeg+iFin: #peak below low limit 1593 1640 iPeak += 1 … … 1637 1684 except KeyError: #no more peaks to process 1638 1685 break 1686 elif 'E' in dataType: 1687 iPeak = 0 1688 while True: 1689 try: 1690 pos = parmDict['pos'+str(iPeak)] 1691 intens = parmDict['int'+str(iPeak)] 1692 sigName = 'sig'+str(iPeak) 1693 if sigName in varyList or not peakInstPrmMode: 1694 sig = parmDict[sigName] 1695 dsdA = dsdB = dsdC = 0 1696 else: 1697 sig = G2mth.getEDsig(parmDict,pos) 1698 dsdA,dsdB,dsdC = G2mth.getEDsigDeriv(parmDict,pos) 1699 sig = max(sig,0.001) #avoid neg sigma 1700 Wd,fmin,fmax = getWidthsED(pos,sig) 1701 iBeg = np.searchsorted(xdata,pos-fmin) 1702 iFin = np.searchsorted(xdata,pos+fmin) 1703 if not iBeg+iFin: #peak below low limit 1704 iPeak += 1 1705 continue 1706 elif not iBeg-iFin: #peak above high limit 1707 break 1708 dMdpk = np.zeros(shape=(4,len(xdata))) 1709 dMdipk = getdPsVoigt(pos,sig*10.**4,0.001,xdata[iBeg:iFin]) 1710 dMdpk[0][iBeg:iFin] += dMdipk[0] 1711 for i in range(1,4): 1712 dMdpk[i][iBeg:iFin] += intens*dMdipk[i] 1713 dervDict = {'int':dMdpk[0],'pos':-dMdpk[1],'sig':dMdpk[2]*10**4} 1714 for parmName in ['pos','int','sig']: 1715 try: 1716 idx = varyList.index(parmName+str(iPeak)) 1717 dMdv[idx] = dervDict[parmName] 1718 except ValueError: 1719 pass 1720 if 'A' in varyList: 1721 dMdv[varyList.index('A')] += dsdA*dervDict['sig'] 1722 if 'B' in varyList: 1723 dMdv[varyList.index('B')] += dsdB*dervDict['sig'] 1724 if 'C' in varyList: 1725 dMdv[varyList.index('C')] += dsdC*dervDict['sig'] 1726 iPeak += 1 1727 except KeyError: #no more peaks to process 1728 break 1729 1639 1730 elif 'B' in dataType: 1640 1731 iPeak = 0 … … 1888 1979 insNames.append(parm) 1889 1980 insVals.append(Inst[parm][1]) 1890 if parm in ['Lam','difC','difA','difB','Zero', ]:1981 if parm in ['Lam','difC','difA','difB','Zero','2-theta','XE','YE','ZE']: 1891 1982 if Inst[parm][2]: 1892 1983 insVary.append(parm) … … 1908 1999 sigstr = 'esds :' 1909 2000 for parm in Inst: 1910 if parm in ['Lam','difC','difA','difB','Zero', ]:2001 if parm in ['Lam','difC','difA','difB','Zero','2-theta','XE','YE','ZE']: 1911 2002 ptlbls += "%s" % (parm.center(12)) 1912 2003 ptstr += ptfmt % (Inst[parm][1]) … … 2097 2188 insNames.append(parm) 2098 2189 insVals.append(Inst[parm][1]) 2099 if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha', 2190 if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha','A','B','C', 2100 2191 'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','alpha-0','alpha-1'] and Inst[parm][2]: 2101 2192 insVary.append(parm) 2102 2193 instDict = dict(zip(insNames,insVals)) 2103 # instDict['X'] = max(instDict['X'],0.01)2104 # instDict['Y'] = max(instDict['Y'],0.01)2105 2194 if 'SH/L' in instDict: 2106 2195 instDict['SH/L'] = max(instDict['SH/L'],0.002) … … 2119 2208 dsp = G2lat.Pos2dsp(Inst,pos) 2120 2209 parmDict[sigName] = G2mth.getTOFsig(parmDict,dsp) 2210 if 'E' in Inst['Type'][0]: 2211 parmDict[sigName] = G2mth.getEDsig(parmDict,pos) 2121 2212 else: 2122 2213 parmDict[sigName] = G2mth.getCWsig(parmDict,pos) … … 2139 2230 sigstr = 'esds :' 2140 2231 for parm in Inst: 2141 if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha', 2232 if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha','A','B','C', 2142 2233 'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','alpha-0','alpha-1']: 2143 2234 ptlbls += "%s" % (parm.center(12)) … … 2157 2248 if 'C' in dataType: 2158 2249 names = ['pos','int','sig','gam'] 2250 elif 'E' in dataType: 2251 names = ['pos','int','sig'] 2159 2252 else: #'T' and 'B' 2160 2253 names = ['pos','int','alp','bet','sig','gam'] … … 2171 2264 if 'C' in Inst['Type'][0]: 2172 2265 names = ['pos','int','sig','gam'] 2266 elif 'E' in Inst['Type'][0]: 2267 names = ['pos','int','sig'] 2173 2268 else: #'T' & 'B' 2174 2269 names = ['pos','int','alp','bet','sig','gam'] … … 2194 2289 if 'T' in Inst['Type'][0]: 2195 2290 peak[2*j] = G2mth.getTOFsig(parmDict,dsp) 2291 elif 'E' in Inst['Type'][0]: 2292 peak[2*j] = G2mth.getEDsig(parmDict,pos) 2196 2293 else: #'C' & 'B' 2197 2294 peak[2*j] = G2mth.getCWsig(parmDict,pos) … … 2206 2303 if 'C' in dataType: 2207 2304 names = ['pos','int','sig','gam'] 2305 elif 'E' in dataType: 2306 names = ['pos','int','sig'] 2208 2307 else: #'T' & 'B' 2209 2308 names = ['pos','int','alp','bet','sig','gam'] … … 2218 2317 if 'C' in dataType: 2219 2318 ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f",'gam':"%10.3f"} 2319 elif 'E' in dataType: 2320 ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f"} 2220 2321 elif 'T' in dataType: 2221 2322 ptfmt = {'pos':"%10.2f",'int':"%10.4f",'alp':"%8.3f",'bet':"%8.5f",'sig':"%10.3f",'gam':"%10.3f"} … … 2290 2391 fullvaryList = varyList[:] 2291 2392 if not peakInstPrmMode: 2292 for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1', 2393 for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1','A','B','C', 2293 2394 'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',): 2294 2395 if v in varyList: -
trunk/GSASIIpwdGUI.py
r5084 r5112 675 675 if 'T' in Inst['Type'][0]: 676 676 refs = G2mth.sortArray(refs,0,reverse=True) #big TOFs first 677 else: #' c' or 'B'678 refs = G2mth.sortArray(refs,0,reverse=False) #small 2-Thetas first677 else: #'C', 'E' or 'B' 678 refs = G2mth.sortArray(refs,0,reverse=False) #small 2-Thetas or energies first 679 679 for i,ref1 in enumerate(refs): #reject picks closer than 1 FWHM 680 680 for ref2 in refs[i+1:]: … … 683 683 if 'T' in Inst['Type'][0]: 684 684 refs = G2mth.sortArray(refs,1,reverse=False) 685 else: #'C' or 'B'685 else: #'C', 'E' or 'B' 686 686 refs = G2mth.sortArray(refs,1,reverse=True) 687 687 for pos,mag in refs: … … 917 917 parent=G2frame, 918 918 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT) 919 screenSize = wx.ClientDisplayRect() 920 Size = dlg.GetSize() 921 if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0 922 dlg.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x 923 dlg.CenterOnParent() 924 try: 925 results = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],background,limits,inst,inst2,data,bxye,[],oneCycle,controls,wtFactor,dlg) 926 peaks['sigDict'] = results[0] 927 text = 'Peak fit: Rwp=%.2f%% Nobs= %d Nparm= %d Npeaks= %d'%(results[3]['Rwp'],results[1][2]['fjac'].shape[1],len(results[0]),len(peaks['peaks'])) 928 finally: 929 dlg.Destroy() 919 # Size = dlg.GetSize() 920 # if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0 921 # dlg.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x 922 # dlg.CenterOnParent() 923 results = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],background,limits,inst,inst2,data,bxye,[],oneCycle,controls,wtFactor,dlg) 924 peaks['sigDict'] = results[0] 925 text = 'Peak fit: Rwp=%.2f%% Nobs= %d Nparm= %d Npeaks= %d'%(results[3]['Rwp'],results[1][2]['fjac'].shape[1],len(results[0]),len(peaks['peaks'])) 926 # dlg.Destroy() 930 927 newpeaks = copy.copy(peaks) 931 928 G2frame.GPXtree.SetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Peak List'),newpeaks) … … 1143 1140 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL, 1144 1141 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1142 elif 'E' in Inst['Type'][0]: 1143 colLabels = ['position','refine','intensity','refine','sigma','refine'] 1144 Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL, 1145 wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL, 1146 wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL] 1145 1147 else: 1146 1148 colLabels = ['position','refine','intensity','refine','alpha','refine', … … 1186 1188 # G2frame.dataWindow.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, onCellListDClick) 1187 1189 reflGrid.AutoSizeColumns(False) 1188 reflGrid.SetScrollRate(10,10)1190 # reflGrid.SetScrollRate(10,10) 1189 1191 G2frame.reflGrid = reflGrid 1190 1192 topSizer = wx.BoxSizer(wx.HORIZONTAL) … … 1893 1895 good = [] 1894 1896 for key in keys: 1895 if key in ['Type','Bank','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha', 1897 if key in ['Type','Bank','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha','A','B','C', 1896 1898 'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','Polariz.','alpha-0','alpha-1', 1897 'Lam','Azimuth','2-theta','fltPath','difC','difA','difB','Zero','Lam1','Lam2' ]:1899 'Lam','Azimuth','2-theta','fltPath','difC','difA','difB','Zero','Lam1','Lam2','XE','YE','ZE',]: 1898 1900 good.append(key) 1899 1901 return good … … 2182 2184 copyList = [] 2183 2185 copyData = copy.deepcopy(data) 2184 del copyData['Azimuth'] #not to be copied! 2186 if 'E' not in data['Type'][0]: 2187 del copyData['Azimuth'] #not to be copied! 2185 2188 instType = data['Type'][0] 2186 2189 dlg = G2G.G2MultiChoiceDialog(G2frame,'Copy inst params from\n'+hst, … … 2381 2384 instSizer.Add(itemVal,0,WACV) 2382 2385 instSizer.Add(RefineBox(item),0,WACV) 2386 elif 'E' in insVal['Type']: 2387 key = '2-theta' 2388 instSizer.Add(wx.StaticText(G2frame.dataWindow,-1,u' 2-theta): (%10.6f)'%(insDef[key])),0,WACV) 2389 tthVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,insVal,key,nDig=(10,6),typeHint=float,OnLeave=AfterChange) 2390 labelLst.append(u'2-theta') 2391 elemKeysLst.append([key,1]) 2392 dspLst.append([10,3]) 2393 instSizer.Add(tthVal,0,WACV) 2394 refFlgElem.append([key,2]) 2395 instSizer.Add(RefineBox(key),0,WACV) 2396 for item in ['XE','YE','ZE','A','B','C']: 2397 nDig = (10,6,'g') 2398 labelLst.append(item) 2399 elemKeysLst.append([item,1]) 2400 dspLst.append(nDig) 2401 refFlgElem.append([item,2]) 2402 instSizer.Add(wx.StaticText(G2frame.dataWindow,-1,lblWdef(item,nDig[1],insDef[item])),0,WACV) 2403 itemVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,insVal,item,nDig=nDig,typeHint=float,OnLeave=NewProfile) 2404 instSizer.Add(itemVal,0,WACV) 2405 instSizer.Add(RefineBox(item),0,WACV) 2383 2406 elif 'T' in insVal['Type']: #time of flight (neutrons) 2384 2407 subSizer = wx.BoxSizer(wx.HORIZONTAL) … … 2505 2528 patched += 1 2506 2529 if patched: print (patched,' instrument parameters changed from tuples') 2507 if ' Z' not in data:2530 if 'E' not in data['Type'][0] and 'Z' not in data: 2508 2531 data['Z'] = [0.0,0.0,False] 2509 2532 #end of patch … … 2526 2549 insDef = dict(zip(instkeys,[data[key][0] for key in instkeys])) 2527 2550 insRef = {} 2528 elif 'R' in data['Type'][0]: # low angledata2551 elif 'R' in data['Type'][0]: #Reflectometry data 2529 2552 insVal = dict(zip(instkeys,[data[key][1] for key in instkeys])) 2530 2553 insDef = dict(zip(instkeys,[data[key][0] for key in instkeys])) … … 3024 3047 nameSizer.Add(wx.StaticText(G2frame.dataWindow,wx.ID_ANY,' Diffractometer type: '), 3025 3048 0,WACV) 3026 if 'T' in Inst['Type'][0] or 'B' in Inst['Type'][0] :3049 if 'T' in Inst['Type'][0] or 'B' in Inst['Type'][0] or 'E' in Inst['Type'][0]: 3027 3050 choices = ['Debye-Scherrer',] 3028 3051 else: … … 3713 3736 A = G2lat.cell2A(cell) 3714 3737 ibrav = bravaisSymb.index(controls[5]) 3715 # if not controls[13]: controls[13] = SPGlist[controls[5]][0] #don't know if this is needed?3716 3738 SGData = G2spc.SpcGroup(controls[13])[1] 3717 3739 if 'T' in Inst['Type'][0]: … … 3726 3748 G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A,Inst) 3727 3749 peaks = [G2indx.IndexPeaks(peaks[0],G2frame.HKL)[1],peaks[1]] #put peak fit esds back in peaks 3728 Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksT(peaks[0],difC,ibrav,A,controls[1],controls[0]) 3750 Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksT(peaks[0],difC,ibrav,A,controls[1],controls[0]) 3751 elif 'E' in Inst['Type'][0]: #no super lattice stuff for EDX data - resolution too low 3752 G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A,Inst) 3753 peaks = [G2indx.IndexPeaks(peaks[0],G2frame.HKL)[1],peaks[1]] #put peak fit esds back in peaks 3754 Lhkl,M20,X20,Aref = G2indx.refinePeaksE(peaks[0],TTh,ibrav,A) 3755 Zero = 0.0 3729 3756 else: 3730 3757 if ssopt.get('Use',False): … … 4407 4434 if 'T' in Inst['Type'][0]: 4408 4435 difC = Inst['difC'][1] 4409 dmin = G2lat.Pos2dsp(Inst,Limits[0]) 4436 dmin = G2lat.Pos2dsp(Inst,Limits[1]) 4437 elif 'E' in Inst['Type'][0]: 4438 TTh = Inst['2-theta'][1] 4439 dmin = G2lat.Pos2dsp(Inst,Limits[1]) 4410 4440 else: #'C', 'B', or 'PKS' 4411 4441 wave = G2mth.getWave(Inst) … … 4496 4526 mainSizer.Add(littleSizer,0) 4497 4527 mainSizer.Add((5,5),0) 4498 mainSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select Bravais Lattices for indexing: '), 4499 0) 4528 mainSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select Bravais Lattices for indexing: '),0) 4500 4529 mainSizer.Add((5,5),0) 4501 4530 indentSizer = wx.BoxSizer(wx.HORIZONTAL) … … 4543 4572 spcSel.Bind(wx.EVT_CHOICE,OnSpcSel) 4544 4573 littleSizer.Add(spcSel,0,WACV) 4545 if ssopt.get('Use',False): #zero for super lattice doesn't work! 4546 controls[0] = False 4547 else: 4548 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Zero offset "),0,WACV) 4549 zero = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,1,nDig=(10,4),typeHint=float, 4550 xmin=-5.,xmax=5.,size=(50,-1),OnLeave=OnCellChange) 4551 littleSizer.Add(zero,0,WACV) 4552 zeroVar = wx.CheckBox(G2frame.dataWindow,label="Refine?") 4553 zeroVar.SetValue(controls[0]) 4554 zeroVar.Bind(wx.EVT_CHECKBOX,OnZeroVar) 4555 littleSizer.Add(zeroVar,0,WACV) 4556 SSopt = wx.CheckBox(G2frame.dataWindow,label="Modulated?") 4557 SSopt.SetValue(ssopt.get('Use',False)) 4558 SSopt.Bind(wx.EVT_CHECKBOX,OnSSopt) 4559 littleSizer.Add(SSopt,0,WACV) 4560 if 'N' in Inst['Type'][0]: 4561 MagSel = wx.CheckBox(G2frame.dataWindow,label="Magnetic?") 4562 MagSel.SetValue('MagSpGrp' in SGData) 4563 MagSel.Bind(wx.EVT_CHECKBOX,OnMagSel) 4564 littleSizer.Add(MagSel,0,WACV) 4574 if 'E' not in Inst['Type'][0]: 4575 if ssopt.get('Use',False): #zero for super lattice doesn't work! 4576 controls[0] = False 4577 else: 4578 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label=" Zero offset "),0,WACV) 4579 zero = G2G.ValidatedTxtCtrl(G2frame.dataWindow,controls,1,nDig=(10,4),typeHint=float, 4580 xmin=-5.,xmax=5.,size=(50,-1),OnLeave=OnCellChange) 4581 littleSizer.Add(zero,0,WACV) 4582 zeroVar = wx.CheckBox(G2frame.dataWindow,label="Refine?") 4583 zeroVar.SetValue(controls[0]) 4584 zeroVar.Bind(wx.EVT_CHECKBOX,OnZeroVar) 4585 littleSizer.Add(zeroVar,0,WACV) 4586 SSopt = wx.CheckBox(G2frame.dataWindow,label="Modulated?") 4587 SSopt.SetValue(ssopt.get('Use',False)) 4588 SSopt.Bind(wx.EVT_CHECKBOX,OnSSopt) 4589 littleSizer.Add(SSopt,0,WACV) 4590 if 'N' in Inst['Type'][0]: 4591 MagSel = wx.CheckBox(G2frame.dataWindow,label="Magnetic?") 4592 MagSel.SetValue('MagSpGrp' in SGData) 4593 MagSel.Bind(wx.EVT_CHECKBOX,OnMagSel) 4594 littleSizer.Add(MagSel,0,WACV) 4565 4595 mainSizer.Add(littleSizer,0) 4566 4596 mainSizer.Add((5,5),0) … … 4974 5004 elif 'B' in Inst['Type'][0]: 4975 5005 refs = np.vstack((refList.T[:17+Super],I100,MuStr,CrSize)).T 5006 elif 'E' in Inst['Type'][0]: 5007 refs = np.vstack((refList.T[:11+Super],I100,MuStr,CrSize)).T 4976 5008 rowLabels = [str(i) for i in range(len(refs))] 4977 5009 Types = (4+Super)*[wg.GRID_VALUE_LONG,]+4*[wg.GRID_VALUE_FLOAT+':10,4',]+ \ … … 4995 5027 colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','alp','bet','Prfo','Abs','Ext','I100','mustrain','Size'] 4996 5028 Types += 8*[wg.GRID_VALUE_FLOAT+':10,3',] 5029 elif 'E' in Inst['Type'][0]: 5030 colLabels = ['H','K','L','mul','d','pos','sig','gam','Fosq','Fcsq','phase','Icorr','I100'] 5031 Types += [wg.GRID_VALUE_FLOAT+':10,3',] 4997 5032 if Super: 4998 5033 colLabels.insert(3,'M') … … 7722 7757 mainSizer.Add(DiffSizer()) 7723 7758 else: 7724 mainSizer.Add(wx.StaticText(G2frame.dataWindow, wx.ID_ANY,7725 powName+' not in Tree'))7759 mainSizer.Add(wx.StaticText(G2frame.dataWindow,label='Controls for %s:\n'%powName)) 7760 mainSizer.Add(DiffSizer()) 7726 7761 G2frame.dataWindow.SetSizer(mainSizer) 7727 7762 G2frame.dataWindow.SetDataSize() -
trunk/GSASIIspc.py
r4985 r5112 3693 3693 # not found 3694 3694 return '' 3695 3696 def fullHM2shortHM(SpcGp): 3697 ''' Accepts a full H-M space group symbol and returns a short H-M symbol that the space group 3698 interpreter can translate 3699 ''' 3700 fields = SpcGp.split() 3701 if len(fields) == 4 and fields[1] == '1' and fields[3] == '1': #b-unique monoclinics 3702 return fields[0]+' '+fields[2] 3703 if '/' not in SpcGp: 3704 return SpcGp 3705 if '-3' in fields[1]: #trigonals 3706 fields[2] = fields.split('/')[1] 3707 return ' '.join(fields) 3708 if '-3' in fields[2]: #cubics 3709 fields[1] = fields.split('/')[1] 3710 if len(fields) == 4: 3711 fields[3].split('/')[1] 3712 return ' '.join(fields) 3713 if '6' in fields[1] and '/' in fields[2]: #hexagonals 3714 fields[2] = fields[2].split('/')[1] 3715 fields[3] = fields[3].split('/')[1] 3716 return ' '.join(fields) 3717 if '4' in fields[1] and '/' in fields[2] and len(fields) == 4: #tetragonals 3718 fields[2] = fields[2].split('/')[1] 3719 fields[3] = fields[3].split('/')[1] 3720 return ' '.join(fields) 3721 if '/' in fields[1] and len(fields) == 4: #orthorhombics 3722 if fields[2] == '1': #skip a-unique monoclinics 3723 return SpcGp 3724 fields[1] = fields[1].split('/')[1] 3725 fields[2] = fields[2].split('/')[1] 3726 fields[3] = fields[3].split('/')[1] 3727 return ' '.join(fields) 3728 return SpcGp 3695 3729 3696 3730 def SpaceGroupNumber(spcgroup): -
trunk/GSASIIstrIO.py
r5106 r5112 320 320 var = dvar.replace('::dA','::A') 321 321 albl = Ilbl[:Ilbl.rfind('_')] 322 v = Ilbl[Ilbl.rfind('_')+1:] 322 pval = 0 323 #v = Ilbl[Ilbl.rfind('_')+1:] 323 324 #pval = ISO['ParentStructure'][albl][['dx','dy','dz'].index(v)] 324 325 if var in parmDict: … … 2520 2521 dmin = wave/(2.0*sind(limits[1]/2.0)) 2521 2522 elif 'T' in inst['Type'][0]: 2523 dmin = G2lat.Pos2dsp(inst,limits[1]) 2522 2524 dmin = limits[0]/inst['difC'][1] 2525 elif 'E' in inst['Type'][0]: 2526 dmin = G2lat.Pos2dsp(inst,limits[1]) 2523 2527 else: 2524 2528 wave = inst['Lam'][1] … … 2554 2558 else: 2555 2559 hapDict[pfx+'LayerDisp'] = 0.0 2556 controlDict[pfx+'poType'] = hapData['Pref.Ori.'][0] 2557 if hapData['Pref.Ori.'][0] == 'MD': 2558 hapDict[pfx+'MD'] = hapData['Pref.Ori.'][1] 2559 controlDict[pfx+'MDAxis'] = hapData['Pref.Ori.'][3] 2560 if hapData['Pref.Ori.'][2]: # and not hapDict[pfx+'LeBail']: 2561 hapVary.append(pfx+'MD') 2562 else: #'SH' spherical harmonics 2563 controlDict[pfx+'SHord'] = hapData['Pref.Ori.'][4] 2564 controlDict[pfx+'SHncof'] = len(hapData['Pref.Ori.'][5]) 2565 controlDict[pfx+'SHnames'] = G2lat.GenSHCoeff(SGData['SGLaue'],'0',controlDict[pfx+'SHord'],False) 2566 controlDict[pfx+'SHhkl'] = [] 2567 try: #patch for old Pref.Ori. items 2568 controlDict[pfx+'SHtoler'] = 0.1 2569 if hapData['Pref.Ori.'][6][0] != '': 2570 controlDict[pfx+'SHhkl'] = [eval(a.replace(' ',',')) for a in hapData['Pref.Ori.'][6]] 2571 controlDict[pfx+'SHtoler'] = hapData['Pref.Ori.'][7] 2572 except IndexError: 2573 pass 2574 for item in hapData['Pref.Ori.'][5]: 2575 hapDict[pfx+item] = hapData['Pref.Ori.'][5][item] 2576 if hapData['Pref.Ori.'][2]: # and not hapDict[pfx+'LeBail']: 2577 hapVary.append(pfx+item) 2578 for item in ['Mustrain','Size']: 2579 controlDict[pfx+item+'Type'] = hapData[item][0] 2580 hapDict[pfx+item+';mx'] = hapData[item][1][2] 2581 if hapData[item][2][2]: 2582 hapVary.append(pfx+item+';mx') 2583 if hapData[item][0] in ['isotropic','uniaxial']: 2584 hapDict[pfx+item+';i'] = hapData[item][1][0] 2585 if hapData[item][2][0]: 2586 hapVary.append(pfx+item+';i') 2587 if hapData[item][0] == 'uniaxial': 2588 controlDict[pfx+item+'Axis'] = hapData[item][3] 2589 hapDict[pfx+item+';a'] = hapData[item][1][1] 2590 if hapData[item][2][1]: 2591 hapVary.append(pfx+item+';a') 2592 else: #generalized for mustrain or ellipsoidal for size 2593 Nterms = len(hapData[item][4]) 2594 if item == 'Mustrain': 2595 names = G2spc.MustrainNames(SGData) 2596 pwrs = [] 2597 for name in names: 2598 h,k,l = name[1:] 2599 pwrs.append([int(h),int(k),int(l)]) 2600 controlDict[pfx+'MuPwrs'] = pwrs 2601 for i in range(Nterms): 2602 sfx = ';'+str(i) 2603 hapDict[pfx+item+sfx] = hapData[item][4][i] 2604 if hapData[item][5][i]: 2605 hapVary.append(pfx+item+sfx) 2606 if Phases[phase]['General']['Type'] != 'magnetic': 2607 for bab in ['BabA','BabU']: 2608 hapDict[pfx+bab] = hapData['Babinet'][bab][0] 2609 if hapData['Babinet'][bab][1]: # and not hapDict[pfx+'LeBail']: 2610 hapVary.append(pfx+bab) 2560 if 'E' not in inst['Type'][0]: 2561 controlDict[pfx+'poType'] = hapData['Pref.Ori.'][0] 2562 if hapData['Pref.Ori.'][0] == 'MD': 2563 hapDict[pfx+'MD'] = hapData['Pref.Ori.'][1] 2564 controlDict[pfx+'MDAxis'] = hapData['Pref.Ori.'][3] 2565 if hapData['Pref.Ori.'][2]: # and not hapDict[pfx+'LeBail']: 2566 hapVary.append(pfx+'MD') 2567 else: #'SH' spherical harmonics 2568 controlDict[pfx+'SHord'] = hapData['Pref.Ori.'][4] 2569 controlDict[pfx+'SHncof'] = len(hapData['Pref.Ori.'][5]) 2570 controlDict[pfx+'SHnames'] = G2lat.GenSHCoeff(SGData['SGLaue'],'0',controlDict[pfx+'SHord'],False) 2571 controlDict[pfx+'SHhkl'] = [] 2572 try: #patch for old Pref.Ori. items 2573 controlDict[pfx+'SHtoler'] = 0.1 2574 if hapData['Pref.Ori.'][6][0] != '': 2575 controlDict[pfx+'SHhkl'] = [eval(a.replace(' ',',')) for a in hapData['Pref.Ori.'][6]] 2576 controlDict[pfx+'SHtoler'] = hapData['Pref.Ori.'][7] 2577 except IndexError: 2578 pass 2579 for item in hapData['Pref.Ori.'][5]: 2580 hapDict[pfx+item] = hapData['Pref.Ori.'][5][item] 2581 if hapData['Pref.Ori.'][2]: # and not hapDict[pfx+'LeBail']: 2582 hapVary.append(pfx+item) 2583 for item in ['Mustrain','Size']: 2584 controlDict[pfx+item+'Type'] = hapData[item][0] 2585 hapDict[pfx+item+';mx'] = hapData[item][1][2] 2586 if hapData[item][2][2]: 2587 hapVary.append(pfx+item+';mx') 2588 if hapData[item][0] in ['isotropic','uniaxial']: 2589 hapDict[pfx+item+';i'] = hapData[item][1][0] 2590 if hapData[item][2][0]: 2591 hapVary.append(pfx+item+';i') 2592 if hapData[item][0] == 'uniaxial': 2593 controlDict[pfx+item+'Axis'] = hapData[item][3] 2594 hapDict[pfx+item+';a'] = hapData[item][1][1] 2595 if hapData[item][2][1]: 2596 hapVary.append(pfx+item+';a') 2597 else: #generalized for mustrain or ellipsoidal for size 2598 Nterms = len(hapData[item][4]) 2599 if item == 'Mustrain': 2600 names = G2spc.MustrainNames(SGData) 2601 pwrs = [] 2602 for name in names: 2603 h,k,l = name[1:] 2604 pwrs.append([int(h),int(k),int(l)]) 2605 controlDict[pfx+'MuPwrs'] = pwrs 2606 for i in range(Nterms): 2607 sfx = ';'+str(i) 2608 hapDict[pfx+item+sfx] = hapData[item][4][i] 2609 if hapData[item][5][i]: 2610 hapVary.append(pfx+item+sfx) 2611 if Phases[phase]['General']['Type'] != 'magnetic': 2612 for bab in ['BabA','BabU']: 2613 hapDict[pfx+bab] = hapData['Babinet'][bab][0] 2614 if hapData['Babinet'][bab][1]: # and not hapDict[pfx+'LeBail']: 2615 hapVary.append(pfx+bab) 2611 2616 2612 2617 if Print: … … 2615 2620 if hapDict[pfx+'LeBail']: 2616 2621 pFile.write(' Perform LeBail extraction\n') 2617 el se:2622 elif 'E' not in inst['Type'][0]: 2618 2623 pFile.write(' Phase fraction : %10.4g Refine? %s\n'%(hapData['Scale'][0],hapData['Scale'][1])) 2619 2624 pFile.write(' Extinction coeff: %10.4f Refine? %s\n'%(hapData['Extinction'][0],hapData['Extinction'][1])) … … 2625 2630 PrintSHPO(hapData['Pref.Ori.']) 2626 2631 pFile.write(' Penalty hkl list: %s tolerance: %.2f\n'%(controlDict[pfx+'SHhkl'],controlDict[pfx+'SHtoler'])) 2627 PrintSize(hapData['Size']) 2628 PrintMuStrain(hapData['Mustrain'],SGData) 2632 if 'E' not in inst['Type'][0]: 2633 PrintSize(hapData['Size']) 2634 PrintMuStrain(hapData['Mustrain'],SGData) 2629 2635 PrintHStrain(hapData['HStrain'],SGData) 2630 2636 if 'Layer Disp' in hapData: 2631 2637 pFile.write(' Layer Displacement: %10.3f Refine? %s\n'%(hapData['Layer Disp'][0],hapData['Layer Disp'][1])) 2632 if Phases[phase]['General']['Type'] != 'magnetic' :2638 if Phases[phase]['General']['Type'] != 'magnetic'and 'E' not in inst['Type'][0]: 2633 2639 if hapData['Babinet']['BabA'][0]: 2634 2640 PrintBabinet(hapData['Babinet']) … … 2690 2696 refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,StartI, 0.0,0.0,0.0,0.0, 1.0,1.0,1.0]) 2691 2697 # ... sig,gam,fotsq,fctsq, phase,icorr,alp,bet, prfo,abs,ext 2698 elif 'E' in inst['Type'][0]: 2699 pos = G2lat.Dsp2pos(inst,d) 2700 if limits[0] < pos < limits[1]: 2701 refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,StartI, 0.0,0.0]) 2702 # ... sig,gam,fotsq,fctsq, phase,icorr 2692 2703 Histogram['Reflection Lists'][phase] = {'RefList':np.array(refList),'FF':{},'Type':inst['Type'][0],'Super':ifSuper} 2693 2704 elif 'HKLF' in histogram: … … 2987 2998 wtFrSum[hId] = 0. 2988 2999 if 'PWDR' in histogram: 2989 parmDict[pfx+'Scale'] = max(1.e-12,parmDict[pfx+'Scale']) 2990 for item in ['Scale','Extinction']: 2991 hapData[item][0] = parmDict[pfx+item] 2992 if pfx+item in sigDict and not parmDict[pfx+'LeBail']: 2993 PhFrExtPOSig.update({pfx+item:sigDict[pfx+item],}) 2994 wtFrSum[hId] += hapData['Scale'][0]*General['Mass'] 2995 if hapData['Pref.Ori.'][0] == 'MD': 2996 hapData['Pref.Ori.'][1] = parmDict[pfx+'MD'] 2997 if pfx+'MD' in sigDict and not parmDict[pfx+'LeBail']: 2998 PhFrExtPOSig.update({pfx+'MD':sigDict[pfx+'MD'],}) 2999 else: #'SH' spherical harmonics 3000 for item in hapData['Pref.Ori.'][5]: 3001 hapData['Pref.Ori.'][5][item] = parmDict[pfx+item] 3000 inst = Histogram['Instrument Parameters'][0] #TODO - grab table here if present 3001 if 'E' not in inst['Type'][0]: 3002 parmDict[pfx+'Scale'] = max(1.e-12,parmDict[pfx+'Scale']) 3003 for item in ['Scale','Extinction']: 3004 hapData[item][0] = parmDict[pfx+item] 3002 3005 if pfx+item in sigDict and not parmDict[pfx+'LeBail']: 3003 3006 PhFrExtPOSig.update({pfx+item:sigDict[pfx+item],}) 3004 SizeMuStrSig.update({pfx+'Mustrain':[[0,0,0],[0 for i in range(len(hapData['Mustrain'][4]))]], 3005 pfx+'Size':[[0,0,0],[0 for i in range(len(hapData['Size'][4]))]], 3006 pfx+'HStrain':{}}) 3007 for item in ['Mustrain','Size']: 3008 hapData[item][1][2] = parmDict[pfx+item+';mx'] 3009 # hapData[item][1][2] = min(1.,max(0.,hapData[item][1][2])) 3010 if pfx+item+';mx' in sigDict: 3011 SizeMuStrSig[pfx+item][0][2] = sigDict[pfx+item+';mx'] 3012 if hapData[item][0] in ['isotropic','uniaxial']: 3013 hapData[item][1][0] = parmDict[pfx+item+';i'] 3014 if item == 'Size': 3015 hapData[item][1][0] = min(10.,max(0.001,hapData[item][1][0])) 3016 if pfx+item+';i' in sigDict: 3017 SizeMuStrSig[pfx+item][0][0] = sigDict[pfx+item+';i'] 3018 if hapData[item][0] == 'uniaxial': 3019 hapData[item][1][1] = parmDict[pfx+item+';a'] 3007 wtFrSum[hId] += hapData['Scale'][0]*General['Mass'] 3008 if hapData['Pref.Ori.'][0] == 'MD': 3009 hapData['Pref.Ori.'][1] = parmDict[pfx+'MD'] 3010 if pfx+'MD' in sigDict and not parmDict[pfx+'LeBail']: 3011 PhFrExtPOSig.update({pfx+'MD':sigDict[pfx+'MD'],}) 3012 else: #'SH' spherical harmonics 3013 for item in hapData['Pref.Ori.'][5]: 3014 hapData['Pref.Ori.'][5][item] = parmDict[pfx+item] 3015 if pfx+item in sigDict and not parmDict[pfx+'LeBail']: 3016 PhFrExtPOSig.update({pfx+item:sigDict[pfx+item],}) 3017 SizeMuStrSig.update({pfx+'Mustrain':[[0,0,0],[0 for i in range(len(hapData['Mustrain'][4]))]], 3018 pfx+'Size':[[0,0,0],[0 for i in range(len(hapData['Size'][4]))]],pfx+'HStrain':{}}) 3019 for item in ['Mustrain','Size']: 3020 hapData[item][1][2] = parmDict[pfx+item+';mx'] 3021 # hapData[item][1][2] = min(1.,max(0.,hapData[item][1][2])) 3022 if pfx+item+';mx' in sigDict: 3023 SizeMuStrSig[pfx+item][0][2] = sigDict[pfx+item+';mx'] 3024 if hapData[item][0] in ['isotropic','uniaxial']: 3025 hapData[item][1][0] = parmDict[pfx+item+';i'] 3020 3026 if item == 'Size': 3021 hapData[item][1][1] = min(10.,max(0.001,hapData[item][1][1])) 3022 if pfx+item+';a' in sigDict: 3023 SizeMuStrSig[pfx+item][0][1] = sigDict[pfx+item+';a'] 3024 else: #generalized for mustrain or ellipsoidal for size 3025 Nterms = len(hapData[item][4]) 3026 for i in range(Nterms): 3027 sfx = ';'+str(i) 3028 hapData[item][4][i] = parmDict[pfx+item+sfx] 3029 if pfx+item+sfx in sigDict: 3030 SizeMuStrSig[pfx+item][1][i] = sigDict[pfx+item+sfx] 3027 hapData[item][1][0] = min(10.,max(0.001,hapData[item][1][0])) 3028 if pfx+item+';i' in sigDict: 3029 SizeMuStrSig[pfx+item][0][0] = sigDict[pfx+item+';i'] 3030 if hapData[item][0] == 'uniaxial': 3031 hapData[item][1][1] = parmDict[pfx+item+';a'] 3032 if item == 'Size': 3033 hapData[item][1][1] = min(10.,max(0.001,hapData[item][1][1])) 3034 if pfx+item+';a' in sigDict: 3035 SizeMuStrSig[pfx+item][0][1] = sigDict[pfx+item+';a'] 3036 else: #generalized for mustrain or ellipsoidal for size 3037 Nterms = len(hapData[item][4]) 3038 for i in range(Nterms): 3039 sfx = ';'+str(i) 3040 hapData[item][4][i] = parmDict[pfx+item+sfx] 3041 if pfx+item+sfx in sigDict: 3042 SizeMuStrSig[pfx+item][1][i] = sigDict[pfx+item+sfx] 3043 else: 3044 SizeMuStrSig.update({pfx+'HStrain':{}}) 3031 3045 names = G2spc.HStrainNames(SGData) 3032 3046 for i,name in enumerate(names): … … 3038 3052 if pfx+'LayerDisp' in sigDict: 3039 3053 SizeMuStrSig[pfx+'LayerDisp'] = sigDict[pfx+'LayerDisp'] 3040 if Phases[phase]['General']['Type'] != 'magnetic' :3054 if Phases[phase]['General']['Type'] != 'magnetic' and 'E' not in inst['Type'][0]: 3041 3055 for name in ['BabA','BabU']: 3042 3056 hapData['Babinet'][name][0] = parmDict[pfx+name] … … 3104 3118 pFile.write(' Bragg intensity sum = %.3g\n'%(Histogram['Residuals'][pfx+'sumInt'])) 3105 3119 3106 if parmDict[pfx+'LeBail'] :3120 if parmDict[pfx+'LeBail'] or 'E' in Inst['Type'][0]: 3107 3121 pFile.write(' Performed LeBail extraction for phase %s in histogram %s\n'%(phase,histogram)) 3108 else: 3109 # if calcControls != None: #skipped in seqRefine 3110 # if 'X'in Inst['Type'][0]: 3111 # PrintFprime(calcControls['FFtables'],hfx,pFile) 3112 # elif 'NC' in Inst['Type'][0]: 3113 # PrintBlength(calcControls['BLtables'],Inst['Lam'][1],pFile) 3122 elif 'E' not in Inst['Type'][0]: 3114 3123 if pfx+'Scale' in PhFrExtPOSig: 3115 3124 wtFr = hapData['Scale'][0]*General['Mass']/wtFrSum[hId] … … 3124 3133 else: 3125 3134 PrintSHPOAndSig(pfx,hapData['Pref.Ori.'],PhFrExtPOSig) 3126 PrintSizeAndSig(hapData['Size'],SizeMuStrSig[pfx+'Size']) 3127 PrintMuStrainAndSig(hapData['Mustrain'],SizeMuStrSig[pfx+'Mustrain'],SGData) 3135 if 'E' not in Inst['Type'][0]: 3136 PrintSizeAndSig(hapData['Size'],SizeMuStrSig[pfx+'Size']) 3137 PrintMuStrainAndSig(hapData['Mustrain'],SizeMuStrSig[pfx+'Mustrain'],SGData) 3128 3138 PrintHStrainAndSig(hapData['HStrain'],SizeMuStrSig[pfx+'HStrain'],SGData) 3129 3139 if pfx+'LayerDisp' in SizeMuStrSig: 3130 3140 pFile.write(' Layer displacement : %10.3f, sig %10.3f\n'%(hapData['Layer Disp'][0],SizeMuStrSig[pfx+'LayerDisp'])) 3131 if Phases[phase]['General']['Type'] != 'magnetic' and not parmDict[pfx+'LeBail'] :3141 if Phases[phase]['General']['Type'] != 'magnetic' and not parmDict[pfx+'LeBail'] and 'E' not in Inst['Type'][0]: 3132 3142 if len(BabSig): 3133 3143 PrintBabinetAndSig(pfx,hapData['Babinet'],BabSig) … … 3210 3220 def GetInstParms(hId,Inst): 3211 3221 #patch 3212 if 'Z' not in Inst: 3222 dataType = Inst['Type'][0] 3223 if 'Z' not in Inst and 'E' not in dataType: 3213 3224 Inst['Z'] = [0.0,0.0,False] 3214 dataType = Inst['Type'][0]3215 3225 instDict = {} 3216 3226 insVary = [] … … 3219 3229 insKeys.sort() 3220 3230 for item in insKeys: 3221 if item in 'Azimuth':3231 if 'Azimuth' in item: 3222 3232 continue 3223 3233 insName = pfx+item … … 3237 3247 if not instDict[pfx+'beta-0'] and not instDict[pfx+'beta-1']: 3238 3248 instDict[pfx+'beta-1'] = 1.0 3249 elif 'E' in dataType: 3250 pass 3239 3251 return dataType,instDict,insVary 3240 3252 … … 3398 3410 pFile.write('\n Histogram: %s histogram Id: %d\n'%(histogram,hId)) 3399 3411 pFile.write(135*'='+'\n') 3400 Units = {'C':' deg','T':' msec','B':' deg' }3412 Units = {'C':' deg','T':' msec','B':' deg','E':'keV'} 3401 3413 units = Units[controlDict[pfx+'histType'][2]] 3402 3414 Limits = controlDict[pfx+'Limits'] -
trunk/GSASIIstrMath.py
r5038 r5112 447 447 hId = Histograms[hist]['hId'] 448 448 phfx = '%d:%d:'%(pId,hId) 449 if calcControls [phfx+'poType']== 'SH':449 if calcControls.get(phfx+'poType','') == 'SH': 450 450 toler = calcControls[phfx+'SHtoler'] 451 451 wt = 1./toler**2 … … 2692 2692 Sum += parmDict[phfx+'Mustrain;'+str(i)]*strm 2693 2693 Mgam = 0.018*refl[4+im]**2*tand(refl[5+im]/2.)*np.sqrt(Sum)/np.pi 2694 elif 'E' in calcControls[hfx+'histType']: 2695 return 0.,0. 2694 2696 elif 'T' in calcControls[hfx+'histType']: #All checked & OK 2695 2697 #crystallite size … … 2802 2804 gamDict[phfx+'Mustrain;mx'] = Mgam 2803 2805 sigDict[phfx+'Mustrain;mx'] = -2.*Mgam**2*(1.-parmDict[phfx+'Mustrain;mx'])/ateln2 2806 elif 'E' in calcControls[hfx+'histType']: 2807 return {},{} 2804 2808 else: #'T'OF - All checked & OK 2805 2809 if calcControls[phfx+'SizeType'] == 'isotropic': #OK … … 3198 3202 parmDict[hfx+'sig-2']*refl[4+im]**4+parmDict[hfx+'sig-q']*refl[4+im] 3199 3203 gam = parmDict[hfx+'X']*refl[4+im]+parmDict[hfx+'Y']*refl[4+im]**2+parmDict[hfx+'Z'] 3204 Ssig,Sgam = GetSampleSigGam(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict) 3205 sig += Ssig 3206 gam += Sgam 3207 return sig,gam 3208 3209 def GetReflSigGamED(refl,im,G,GB,phfx,calcControls,parmDict): 3210 sig = parmDict[hfx+'A']*refl[4+im]**2+parmDict[hfx+'B']*refl[4+im]+parmDict[hfx+'C'] 3211 gam = 0.001 3200 3212 Ssig,Sgam = GetSampleSigGam(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict) 3201 3213 sig += Ssig … … 3588 3600 if 'T' in calcControls[hfx+'histType']: 3589 3601 wave = refl[14+im] 3590 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl,im,wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 3602 if 'E' in calcControls[hfx+'histType']: 3603 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = [0.,0.,0.,0.,0.,0.,0.,0.] 3604 else: 3605 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl,im,wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 3591 3606 if 'C' in calcControls[hfx+'histType']: #CW powder 3592 3607 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5+im],refl[6+im],refl[7+im],shl) … … 3595 3610 elif 'B' in calcControls[hfx+'histType']: 3596 3611 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5+im],refl[12+im],refl[13+im],refl[6+im]/1.e4,refl[7+im]/100.) 3612 elif 'E' in calcControls[hfx+'histType']: 3613 Wd,fmin,fmax = G2pwd.getWidthsED(refl[5+im],refl[10+im]) 3597 3614 iBeg = np.searchsorted(x,refl[5+im]-fmin) 3598 3615 iFin = np.searchsorted(x,refl[5+im]+fmax) … … 3642 3659 for i in range(6): 3643 3660 dMdpk[i] = refl[11+im]*refl[9+im]*dMdipk[i] 3644 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4]/1.e4,'gam':dMdpk[5]/100.} 3661 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4]/1.e4,'gam':dMdpk[5]/100.} 3662 elif 'E' in calcControls[hfx+'histType']: 3663 lenBF = iFin-iBeg 3664 if lenBF < 0: #bad peak coeff 3665 break 3666 dMdpk = np.zeros(shape=(4,lenBF)) 3667 dMdipk = G2pwd.getdPsVoigt(refl[5+im],refl[12+im]*10**4,0.001,ma.getdata(x[iBeg:iFin])) 3668 for i in range(4): 3669 dMdpk[i] = refl[11+im]*refl[9+im]*dMdipk[i] 3670 dervDict = {'int':dMdpk[0],'pos':-dMdpk[1],'sig':dMdpk[4]*1.e4} 3645 3671 if Phase['General'].get('doPawley'): 3646 3672 dMdpw = np.zeros(len(x)) … … 3686 3712 hfx+'alpha-0':[1.0,'alp'],hfx+'alpha-1':[tanth,'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[tanth,'bet'], 3687 3713 hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],hfx+'DisplaceX':[dpdX,'pos'],hfx+'DisplaceY':[dpdY,'pos']} 3714 elif 'E' in calcControls[hfx+'histType']: 3715 dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY,dpdV = GetReflPosDerv(refl,im,wave,A,pfx,hfx,phfx,calcControls,parmDict) 3716 names = {hfx+'Scale':[dIdsh,'int'],phfx+'Scale':[dIdsp,'int'],hfx+'Lam':[dpdw,'pos'], 3717 hfx+'Zero':[dpdZ,'pos'],hfx+'X':[1.0/costh,'gam'],hfx+'Y':[tanth,'gam'],hfx+'Z':[1.0,'gam'], 3718 hfx+'U':[tanth**2,'sig'],hfx+'V':[tanth,'sig'],hfx+'W':[1.0,'sig'],hfx+'Polariz.':[dIdpola,'int'], 3719 hfx+'alpha-0':[1.0,'alp'],hfx+'alpha-1':[tanth,'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[tanth,'bet'], 3720 hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],hfx+'DisplaceX':[dpdX,'pos'],hfx+'DisplaceY':[dpdY,'pos']} 3721 3688 3722 for name in names: 3689 3723 item = names[name] -
trunk/ISODISTORT.py
r5070 r5112 32 32 print('Could not open URL') 33 33 34 def GetISODISTORT(Phase,parentcif ):34 def GetISODISTORT(Phase,parentcif,method=1): 35 35 '''Run Stokes & Campbell ISODISTORT. 36 36 This requires doing a post to the BYU upload site with a cif file, which returns a BYU local … … 74 74 out2 = requests.post(isoformsite,up2).text 75 75 76 ISOdata = Phase['ISODISTORT'] 76 77 #recover required info for the distortion search; includes info from cif file (no longer needed) 77 78 try: 79 pos = out2.index('<p><FORM') 80 except ValueError: 81 HandleError(out2) 82 return [],[] 83 data = {} 84 while True: 78 if method == 1: 85 79 try: 86 posB = out2[pos:].index('INPUT TYPE')+pos 87 posF = out2[posB:].index('>')+posB 88 items = out2[posB:posF].split('=',3) 89 name = items[2].split()[0].replace('"','') 90 if 'isosystem' in name: 80 pos = out2.index('<p><FORM') 81 except ValueError: 82 HandleError(out2) 83 return [],[] 84 data = {} 85 while True: 86 try: 87 posB = out2[pos:].index('INPUT TYPE')+pos 88 posF = out2[posB:].index('>')+posB 89 items = out2[posB:posF].split('=',3) 90 name = items[2].split()[0].replace('"','') 91 if 'isosystem' in name: 92 break 93 vals = items[3].replace('"','') 94 data[name] = vals 95 pos = posF 96 except ValueError: 91 97 break 92 vals = items[3].replace('"','') 93 data[name] = vals 94 pos = posF 95 except ValueError: 96 break 97 #save copy for future use 98 data2 = copy.deepcopy(data) 99 100 #no limits on space group or lattice 101 102 data['isosubgroup'] = 'no choice' 103 data['isolattice'] = 'no choice' 104 data['isoplattice'] = 'no choice' 98 #save copy for future use 99 data2 = copy.deepcopy(data) 100 101 #no limits on space group or lattice 102 103 data['isosubgroup'] = 'no choice' 104 data['isolattice'] = 'no choice' 105 data['isoplattice'] = 'no choice' 105 106 106 107 #do the distortion search - result is radio button list of choices … … 122 123 posF = out3[pos:].index('<BR>')+pos 123 124 num += 1 124 items = out3[pos:posF].split('=',2) 125 radio['orderparam%d'%num] = items [2].replace('"','')125 items = out3[pos:posF].split('=',2)[2].split('>')[0] 126 radio['orderparam%d'%num] = items.replace('"','') 126 127 pos = out3[posF:].index('RADIO')+posF 127 128 except ValueError: -
trunk/imports/G2phase_CIF.py
r5083 r5112 235 235 else: 236 236 SpGrp = SpGrp.replace('_','') 237 SpGrp = G2spc.fullHM2shortHM(SpGrp) 237 238 self.Phase['General']['Type'] = 'nuclear' 238 239 #process space group symbol … … 242 243 if SpGrpNorm: 243 244 E,SGData = G2spc.SpcGroup(SpGrpNorm) 244 if E: #try lookup from number - found full symbol?245 SpGrpNorm = G2spc.spgbyNum[int(blk.get('_symmetry_Int_Tables_number'))]246 if SpGrpNorm:247 E,SGData = G2spc.SpcGroup(SpGrpNorm)245 # if E: #try lookup from number - found full symbol? 246 # SpGrpNorm = G2spc.spgbyNum[int(blk.get('_symmetry_Int_Tables_number'))] 247 # if SpGrpNorm: 248 # E,SGData = G2spc.SpcGroup(SpGrpNorm) 248 249 # nope, try the space group "out of the Box" 249 250 if E: -
trunk/imports/G2pwd_fxye.py
r4192 r5112 175 175 S = File.readline() 176 176 j = 0 177 Ecoef = np.zeros(4) 178 if 'EDS' in cons[4]: 179 Ecoef = np.fromstring(' '.join(cons[5:9]),sep=' ') 177 180 while S and S[:4] != 'BANK' and S[0] != '#': 178 181 if 'TIME_MAP' in S or '\x1a' in S: … … 182 185 break 183 186 xi = start+step*j 187 if 'EDS' in Bank: #Energy dispersive - convert CN to EkeV 188 xi = Ecoef[0]+(Ecoef[1]+(Ecoef[2]+Ecoef[3]*j)*j)*j 184 189 ni = max(sint(S[i:i+2]),1) 185 190 yi = max(sfloat(S[i+2:i+8]),0.0)
Note: See TracChangeset
for help on using the changeset viewer.