Changeset 1595
- Timestamp:
- Dec 4, 2014 4:07:45 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r1581 r1595 1390 1390 ''' 1391 1391 # Note: this routine is Python 3 compatible -- I think 1392 cutoff = 3.16228 #=(sqrt(10); same as old GSAS was 1.95 1392 1393 if math.isnan(value): # invalid value, bail out 1393 1394 return '?' … … 1397 1398 elif esd != 0: 1398 1399 # transform the esd to a one or two digit integer 1399 l = math.log10(abs(esd)) % 1 1400 # cut off of 19 1.9==>(19) but 1.95==>(2) N.B. log10(1.95) = 0.2900... 1401 if l < 0.290034611362518: l+= 1. 1400 l = math.log10(abs(esd)) % 1. 1401 if l < math.log10(cutoff): l+= 1. 1402 1402 intesd = int(round(10**l)) # esd as integer 1403 1403 # determine the number of digits offset for the esd -
trunk/GSASIIobj.py
r1496 r1595 1253 1253 'A([0-5])' : 'Reciprocal metric tensor component \\1', 1254 1254 'Vol' : 'Unit cell volume', 1255 'mV([0-2])' : 'Modulation vector component \\1', 1255 1256 # Atom vars (p::<var>:a) 1256 1257 'dA([xyz])$' : 'change to atomic coordinate, \\1', -
trunk/GSASIIphsGUI.py
r1594 r1595 5056 5056 for h,k,l,m,d in HKLd: 5057 5057 ext,mul = G2spc.GenHKLf([h,k,l],SGData)[:2] 5058 if not ext:5058 if m or not ext: 5059 5059 mul *= 2 #for powder multiplicity 5060 5060 PawleyPeaks.append([h,k,l,m,mul,d,False,100.0,1.0]) … … 5083 5083 return 5084 5084 Vst = 1.0/data['General']['Cell'][7] #Get volume 5085 generalData = data['General'] 5086 im = 0 5087 if generalData['Type'] in ['modulated','magnetic',]: 5088 im = 1 5085 5089 HistoNames = filter(lambda a:Histograms[a]['Use']==True,Histograms.keys()) 5086 5090 PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistoNames[0]) … … 5096 5100 try: 5097 5101 for ref in Refs: 5098 pos = 2.0*asind(wave/(2.0*ref[4 ]))5102 pos = 2.0*asind(wave/(2.0*ref[4+im])) 5099 5103 if 'Bragg' in Sample['Type']: 5100 5104 pos -= const*(4.*Sample['Shift'][0]*cosd(pos/2.0)+ \ … … 5109 5113 # we multiply the observed peak height by sqrt(8 ln 2)/(FWHM*sqrt(pi)) to determine the value of Icorr*F^2 5110 5114 # then divide by Icorr to get F^2. 5111 ref[6 ] = (xdata[1][indx]-xdata[4][indx])*gconst/(FWHM*np.sqrt(np.pi)) #Area of Gaussian is height * FWHM * sqrt(pi)5115 ref[6+im] = (xdata[1][indx]-xdata[4][indx])*gconst/(FWHM*np.sqrt(np.pi)) #Area of Gaussian is height * FWHM * sqrt(pi) 5112 5116 Lorenz = 1./(2.*sind(xdata[0][indx]/2.)**2*cosd(xdata[0][indx]/2.)) #Lorentz correction 5113 5117 pola = 1.0 … … 5117 5121 pola = 1.0 5118 5122 # Include histo scale and volume in calculation 5119 ref[6 ] /= (Sample['Scale'][0] * Vst * Lorenz * pola * ref[3])5123 ref[6+im] /= (Sample['Scale'][0] * Vst * Lorenz * pola * ref[3+im]) 5120 5124 except IndexError: 5121 5125 pass -
trunk/GSASIIpwdGUI.py
r1594 r1595 2301 2301 def OnSpcSel(event): 2302 2302 controls[13] = spcSel.GetString(spcSel.GetSelection()) 2303 G2frame.dataFrame.RefineCell.Enable(True) 2303 2304 2304 2305 def SetCellValue(Obj,ObjId,value): … … 2940 2941 2*[wg.GRID_VALUE_FLOAT+':10,2',]+[wg.GRID_VALUE_FLOAT+':10,3',]+ \ 2941 2942 [wg.GRID_VALUE_FLOAT+':10,3',] 2942 superLabels = ['M1','M2','M3']2943 2943 if HKLF: 2944 2944 colLabels = ['H','K','L','mul','d','Fosq','sig','Fcsq','FoTsq','FcTsq','phase','ExtC',] … … 2947 2947 Types += 2*[wg.GRID_VALUE_FLOAT+':10,3',] 2948 2948 if Super: 2949 for i in range(Super): 2950 colLabels.insert(3+i,superLabels[i]) 2949 colLabels.insert(3,'M') 2951 2950 else: 2952 2951 if 'C' in Inst['Type'][0]: … … 2957 2956 Types += 7*[wg.GRID_VALUE_FLOAT+':10,3',] 2958 2957 if Super: 2959 for i in range(Super): 2960 colLabels.insert(3+i,superLabels[i]) 2958 colLabels.insert(3,'M') 2961 2959 2962 2960 G2frame.PeakTable = G2gd.Table(refs,rowLabels=rowLabels,colLabels=colLabels,types=Types) -
trunk/GSASIIstrIO.py
r1594 r1595 973 973 if cell[0]: 974 974 phaseVary += cellVary(pfx,SGData) 975 SSGtext = [] #no superstructure 976 im = 0 975 977 if General['Type'] in ['modulated','magnetic']: 978 im = 1 #refl offset 976 979 Vec,vRef,maxH = General['SuperVec'] 977 980 phaseDict.update({pfx+'mV0':Vec[0],pfx+'mV1':Vec[1],pfx+'mV2':Vec[2]}) … … 1080 1083 PrintBLtable(BLtable) 1081 1084 print >>pFile,'' 1082 for line in SGtext: print >>pFile,line 1083 if len(SGtable): 1084 for item in SGtable: 1085 line = ' %s '%(item) 1086 print >>pFile,line 1085 if len(SSGtext): #if superstructure 1086 for line in SSGtext: print >>pFile,line 1087 if len(SSGtable): 1088 for item in SSGtable: 1089 line = ' %s '%(item) 1090 print >>pFile,line 1091 else: 1092 print >>pFile,' ( 1) %s'%(SSGtable[0]) 1087 1093 else: 1088 print >>pFile,' ( 1) %s'%(SGtable[0]) 1094 for line in SGtext: print >>pFile,line 1095 if len(SGtable): 1096 for item in SGtable: 1097 line = ' %s '%(item) 1098 print >>pFile,line 1099 else: 1100 print >>pFile,' ( 1) %s'%(SGtable[0]) 1089 1101 PrintRBObjects(resRBData,vecRBData) 1090 1102 PrintAtoms(General,Atoms) 1091 print >>pFile,'\n Unit cell: a =','%.5f'%(cell[1]),' b =','%.5f'%(cell[2]),' c =','%.5f'%(cell[3]), \ 1092 ' alpha =','%.3f'%(cell[4]),' beta =','%.3f'%(cell[5]),' gamma =', \ 1093 '%.3f'%(cell[6]),' volume =','%.3f'%(cell[7]),' Refine?',cell[0] 1103 print >>pFile,'\n Unit cell: a = %.5f'%(cell[1]),' b = %.5f'%(cell[2]),' c = %.5f'%(cell[3]), \ 1104 ' alpha = %.3f'%(cell[4]),' beta = %.3f'%(cell[5]),' gamma = %.3f'%(cell[6]), \ 1105 ' volume = %.3f'%(cell[7]),' Refine?',cell[0] 1106 if len(SSGtext): #if superstructure 1107 print >>pFile,'\n Modulation vector: mV0 = %.4f'%(Vec[0]),' mV1 = %.4f'%(Vec[1]), \ 1108 ' mV2 = %.4f'%(Vec[2]),' max mod. index = %d'%(maxH),' Refine?',vRef 1094 1109 PrintTexture(textureData) 1095 1110 if name in RestraintDict: … … 1098 1113 1099 1114 elif PawleyRef: 1115 if Print: 1116 print >>pFile,'\n Phase name: ',General['Name'] 1117 print >>pFile,135*'-' 1118 print >>pFile,'' 1119 if len(SSGtext): #if superstructure 1120 for line in SSGtext: print >>pFile,line 1121 if len(SSGtable): 1122 for item in SSGtable: 1123 line = ' %s '%(item) 1124 print >>pFile,line 1125 else: 1126 print >>pFile,' ( 1) %s'%(SSGtable[0]) 1127 else: 1128 for line in SGtext: print >>pFile,line 1129 if len(SGtable): 1130 for item in SGtable: 1131 line = ' %s '%(item) 1132 print >>pFile,line 1133 else: 1134 print >>pFile,' ( 1) %s'%(SGtable[0]) 1135 print >>pFile,'\n Unit cell: a = %.5f'%(cell[1]),' b = %.5f'%(cell[2]),' c = %.5f'%(cell[3]), \ 1136 ' alpha = %.3f'%(cell[4]),' beta = %.3f'%(cell[5]),' gamma = %.3f'%(cell[6]), \ 1137 ' volume = %.3f'%(cell[7]),' Refine?',cell[0] 1138 if len(SSGtext): #if superstructure 1139 print >>pFile,'\n Modulation vector: mV0 = %.4f'%(Vec[0]),' mV1 = %.4f'%(Vec[1]), \ 1140 ' mV2 = %.4f'%(Vec[2]),' max mod. index = %d'%(maxH),' Refine?',vRef 1100 1141 pawleyVary = [] 1101 1142 for i,refl in enumerate(PawleyRef): 1102 phaseDict[pfx+'PWLref:'+str(i)] = refl[6] 1103 pawleyLookup[pfx+'%d,%d,%d'%(refl[0],refl[1],refl[2])] = i 1104 if refl[5]: 1143 phaseDict[pfx+'PWLref:'+str(i)] = refl[6+im] 1144 if im: 1145 pawleyLookup[pfx+'%d,%d,%d,%d'%(refl[0],refl[1],refl[2],refl[3])] = i 1146 else: 1147 pawleyLookup[pfx+'%d,%d,%d'%(refl[0],refl[1],refl[2])] = i 1148 if refl[5+im]: 1105 1149 pawleyVary.append(pfx+'PWLref:'+str(i)) 1106 1150 GetPawleyConstr(SGData['SGLaue'],PawleyRef,pawleyVary) #does G2mv.StoreEquivalence … … 1552 1596 print >>pFile,ptstr 1553 1597 print >>pFile,sigstr 1598 ik = 6 #for Pawley stuff below 1599 if General['Type'] in ['modulated','magnetic']: 1600 ik = 7 1601 Vec,vRef,maxH = General['SuperVec'] 1602 if vRef: 1603 print >>pFile,' New modulation vector:' 1604 namstr = ' names :' 1605 ptstr = ' values:' 1606 sigstr = ' esds :' 1607 for var in ['mV0','mV1','mV2']: 1608 namstr += '%12s'%(pfx+var) 1609 ptstr += '%12.4f'%(parmDict[pfx+var]) 1610 if pfx+var in sigDict: 1611 sigstr += '%12.4f'%(sigDict[pfx+var]) 1612 else: 1613 sigstr += 12*' ' 1614 print >>pFile,namstr 1615 print >>pFile,ptstr 1616 print >>pFile,sigstr 1554 1617 1555 1618 General['Mass'] = 0. … … 1558 1621 for i,refl in enumerate(pawleyRef): 1559 1622 key = pfx+'PWLref:'+str(i) 1560 refl[ 6] = parmDict[key]1623 refl[ik] = parmDict[key] 1561 1624 if key in sigDict: 1562 refl[ 7] = sigDict[key]1625 refl[ik+1] = sigDict[key] 1563 1626 else: 1564 refl[ 7] = 01627 refl[ik+1] = 0 1565 1628 else: 1566 1629 VRBIds = RBIds['Vector'] … … 1743 1806 cell = Phases[phase]['General']['Cell'][1:7] 1744 1807 A = G2lat.cell2A(cell) 1808 if Phases[phase]['General']['Type'] in ['modulated','magnetic']: 1809 SSGData = Phases[phase]['General']['SSGData'] 1810 Vec,x,maxH = Phases[phase]['General']['SuperVec'] 1745 1811 pId = Phases[phase]['pId'] 1746 1812 histoList = HistoPhase.keys() … … 1840 1906 PrintHStrain(hapData['HStrain'],SGData) 1841 1907 if hapData['Babinet']['BabA'][0]: 1842 PrintBabinet(hapData['Babinet']) 1843 HKLd = np.array(G2lat.GenHLaue(dmin,SGData,A)) #+DIJS 1908 PrintBabinet(hapData['Babinet']) 1909 if Phases[phase]['General']['Type'] in ['modulated','magnetic']: 1910 HKLd = G2lat.GenSSHLaue(dmin,SGData,SSGData,Vec,maxH,A) 1911 else: 1912 HKLd = np.array(G2lat.GenHLaue(dmin,SGData,A)) 1844 1913 if resetRefList: 1845 1914 refList = [] 1846 1915 Uniq = [] 1847 1916 Phi = [] 1848 for h,k,l,d in HKLd: 1849 ext,mul,uniq,phi = G2spc.GenHKLf([h,k,l],SGData) 1850 mul *= 2 # for powder overlap of Friedel pairs 1851 if ext: 1852 continue 1853 if 'C' in inst['Type'][0]: 1854 pos = 2.0*asind(wave/(2.0*d))+Zero 1855 if limits[0] < pos < limits[1]: 1856 refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,0.0, 0.0,0.0,1.0,1.0,1.0]) 1857 #... sig,gam,fotsq,fctsq, phase,icorr,prfo,abs,ext 1858 Uniq.append(uniq) 1859 Phi.append(phi) 1860 elif 'T' in inst['Type'][0]: 1861 pos = inst['difC'][1]*d+inst['difA'][1]*d**2+inst['difB'][1]/d+Zero 1862 if limits[0] < pos < limits[1]: 1863 wave = inst['difC'][1]*d/(252.816*inst['fltPath'][0]) 1864 refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,wave, 1.0,1.0,1.0]) 1865 # ... sig,gam,fotsq,fctsq, phase,icorr,alp,bet,wave, prfo,abs,ext 1866 Uniq.append(uniq) 1867 Phi.append(phi) 1917 if Phases[phase]['General']['Type'] in ['modulated','magnetic']: 1918 for h,k,l,m,d in HKLd: 1919 ext,mul,uniq,phi = G2spc.GenHKLf([h,k,l],SGData) #is this right for SS refl.?? 1920 mul *= 2 # for powder overlap of Friedel pairs 1921 if m or not ext: 1922 if 'C' in inst['Type'][0]: 1923 pos = G2lat.Dsp2pos(inst,d) 1924 if limits[0] < pos < limits[1]: 1925 refList.append([h,k,l,m,mul,d, pos,0.0,0.0,0.0,0.0, 0.0,0.0,1.0,1.0,1.0]) 1926 #... sig,gam,fotsq,fctsq, phase,icorr,prfo,abs,ext 1927 Uniq.append(uniq) 1928 Phi.append(phi) 1929 elif 'T' in inst['Type'][0]: 1930 pos = G2lat.Dsp2pos(inst,d) 1931 if limits[0] < pos < limits[1]: 1932 wave = inst['difC'][1]*d/(252.816*inst['fltPath'][0]) 1933 refList.append([h,k,l,m,mul,d, pos,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,wave, 1.0,1.0,1.0]) 1934 # ... sig,gam,fotsq,fctsq, phase,icorr,alp,bet,wave, prfo,abs,ext 1935 Uniq.append(uniq) 1936 Phi.append(phi) 1937 else: 1938 for h,k,l,d in HKLd: 1939 ext,mul,uniq,phi = G2spc.GenHKLf([h,k,l],SGData) 1940 mul *= 2 # for powder overlap of Friedel pairs 1941 if ext: 1942 continue 1943 if 'C' in inst['Type'][0]: 1944 pos = G2lat.Dsp2pos(inst,d) 1945 if limits[0] < pos < limits[1]: 1946 refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,0.0, 0.0,0.0,1.0,1.0,1.0]) 1947 #... sig,gam,fotsq,fctsq, phase,icorr,prfo,abs,ext 1948 Uniq.append(uniq) 1949 Phi.append(phi) 1950 elif 'T' in inst['Type'][0]: 1951 pos = G2lat.Dsp2pos(inst,d) 1952 if limits[0] < pos < limits[1]: 1953 wave = inst['difC'][1]*d/(252.816*inst['fltPath'][0]) 1954 refList.append([h,k,l,mul,d, pos,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,wave, 1.0,1.0,1.0]) 1955 # ... sig,gam,fotsq,fctsq, phase,icorr,alp,bet,wave, prfo,abs,ext 1956 Uniq.append(uniq) 1957 Phi.append(phi) 1868 1958 Histogram['Reflection Lists'][phase] = {'RefList':np.array(refList),'FF':{},'Type':inst['Type'][0]} 1869 1959 elif 'HKLF' in histogram: -
trunk/GSASIIstrMath.py
r1591 r1595 798 798 return dFdvDict 799 799 800 def SCExtinction(ref, phfx,hfx,pfx,calcControls,parmDict,varyList):800 def SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varyList): 801 801 ''' Single crystal extinction function; returns extinction & derivative 802 802 ''' … … 804 804 dervDict = {} 805 805 if calcControls[phfx+'EType'] != 'None': 806 SQ = 1/(4.*ref[4 ]**2)806 SQ = 1/(4.*ref[4+im]**2) 807 807 if 'C' in parmDict[hfx+'Type']: 808 808 cos2T = 1.0-2.*SQ*parmDict[hfx+'Lam']**2 #cos(2theta) 809 809 else: #'T' 810 cos2T = 1.0-2.*SQ*ref[12 ]**2 #cos(2theta)810 cos2T = 1.0-2.*SQ*ref[12+im]**2 #cos(2theta) 811 811 if 'SXC' in parmDict[hfx+'Type']: 812 812 AV = 7.9406e5/parmDict[pfx+'Vol']**2 813 813 PL = np.sqrt(1.0-cos2T**2)/parmDict[hfx+'Lam'] 814 814 P12 = (calcControls[phfx+'Cos2TM']+cos2T**4)/(calcControls[phfx+'Cos2TM']+cos2T**2) 815 PLZ = AV*P12*ref[7 ]*parmDict[hfx+'Lam']**2815 PLZ = AV*P12*ref[7+im]*parmDict[hfx+'Lam']**2 816 816 elif 'SNT' in parmDict[hfx+'Type']: 817 817 AV = 1.e7/parmDict[pfx+'Vol']**2 818 818 PL = SQ 819 PLZ = AV*ref[7 ]*ref[12]**2819 PLZ = AV*ref[7+im]*ref[12+im]**2 820 820 elif 'SNC' in parmDict[hfx+'Type']: 821 821 AV = 1.e7/parmDict[pfx+'Vol']**2 … … 829 829 PLZ *= calcControls[phfx+'Tbar'] 830 830 else: #'T' 831 PLZ *= ref[13 ] #t-bar831 PLZ *= ref[13+im] #t-bar 832 832 if 'Primary' in calcControls[phfx+'EType']: 833 833 PLZ *= 1.5 … … 860 860 861 861 if 'Primary' in calcControls[phfx+'EType'] and phfx+'Ep' in varyList: 862 dervDict[phfx+'Ep'] = -ref[7 ]*PLZ*PF3862 dervDict[phfx+'Ep'] = -ref[7+im]*PLZ*PF3 863 863 if 'II' in calcControls[phfx+'EType'] and phfx+'Es' in varyList: 864 dervDict[phfx+'Es'] = -ref[7 ]*PLZ*PF3*(PSIG/parmDict[phfx+'Es'])**3864 dervDict[phfx+'Es'] = -ref[7+im]*PLZ*PF3*(PSIG/parmDict[phfx+'Es'])**3 865 865 if 'I' in calcControls[phfx+'EType'] and phfx+'Eg' in varyList: 866 dervDict[phfx+'Eg'] = -ref[7 ]*PLZ*PF3*(PSIG/parmDict[phfx+'Eg'])**3*PL**2866 dervDict[phfx+'Eg'] = -ref[7+im]*PLZ*PF3*(PSIG/parmDict[phfx+'Eg'])**3*PL**2 867 867 868 868 return 1./extCor,dervDict … … 908 908 return newAtomDict 909 909 910 def SHTXcal(refl, g,pfx,hfx,SGData,calcControls,parmDict):910 def SHTXcal(refl,im,g,pfx,hfx,SGData,calcControls,parmDict): 911 911 'Spherical harmonics texture' 912 912 IFCoup = 'Bragg' in calcControls[hfx+'instType'] … … 914 914 tth = parmDict[hfx+'2-theta'] 915 915 else: 916 tth = refl[5 ]916 tth = refl[5+im] 917 917 odfCor = 1.0 918 918 H = refl[:3] … … 931 931 return odfCor 932 932 933 def SHTXcalDerv(refl, g,pfx,hfx,SGData,calcControls,parmDict):933 def SHTXcalDerv(refl,im,g,pfx,hfx,SGData,calcControls,parmDict): 934 934 'Spherical harmonics texture derivatives' 935 935 if 'T' in calcControls[hfx+'histType']: 936 936 tth = parmDict[hfx+'2-theta'] 937 937 else: 938 tth = refl[5 ]938 tth = refl[5+im] 939 939 FORPI = 4.0*np.pi 940 940 IFCoup = 'Bragg' in calcControls[hfx+'instType'] … … 960 960 return odfCor,dFdODF,dFdSA 961 961 962 def SHPOcal(refl, g,phfx,hfx,SGData,calcControls,parmDict):962 def SHPOcal(refl,im,g,phfx,hfx,SGData,calcControls,parmDict): 963 963 'spherical harmonics preferred orientation (cylindrical symmetry only)' 964 964 if 'T' in calcControls[hfx+'histType']: 965 965 tth = parmDict[hfx+'2-theta'] 966 966 else: 967 tth = refl[5 ]967 tth = refl[5+im] 968 968 odfCor = 1.0 969 969 H = refl[:3] … … 985 985 return np.squeeze(odfCor) 986 986 987 def SHPOcalDerv(refl, g,phfx,hfx,SGData,calcControls,parmDict):987 def SHPOcalDerv(refl,im,g,phfx,hfx,SGData,calcControls,parmDict): 988 988 'spherical harmonics preferred orientation derivatives (cylindrical symmetry only)' 989 989 if 'T' in calcControls[hfx+'histType']: 990 990 tth = parmDict[hfx+'2-theta'] 991 991 else: 992 tth = refl[5 ]992 tth = refl[5+im] 993 993 FORPI = 12.5663706143592 994 994 odfCor = 1.0 … … 1013 1013 return odfCor,dFdODF 1014 1014 1015 def GetPrefOri( refl,uniq,G,g,phfx,hfx,SGData,calcControls,parmDict):1015 def GetPrefOri(uniq,G,g,phfx,hfx,SGData,calcControls,parmDict): 1016 1016 'March-Dollase preferred orientation correction' 1017 1017 POcorr = 1.0 … … 1027 1027 return POcorr 1028 1028 1029 def GetPrefOriDerv(refl, uniq,G,g,phfx,hfx,SGData,calcControls,parmDict):1029 def GetPrefOriDerv(refl,im,uniq,G,g,phfx,hfx,SGData,calcControls,parmDict): 1030 1030 'Needs a doc string' 1031 1031 POcorr = 1.0 … … 1045 1045 else: #spherical harmonics 1046 1046 if calcControls[phfx+'SHord']: 1047 POcorr,POderv = SHPOcalDerv(refl, g,phfx,hfx,SGData,calcControls,parmDict)1047 POcorr,POderv = SHPOcalDerv(refl,im,g,phfx,hfx,SGData,calcControls,parmDict) 1048 1048 return POcorr,POderv 1049 1049 1050 def GetAbsorb(refl, hfx,calcControls,parmDict):1050 def GetAbsorb(refl,im,hfx,calcControls,parmDict): 1051 1051 'Needs a doc string' 1052 1052 if 'Debye' in calcControls[hfx+'instType']: 1053 1053 if 'T' in calcControls[hfx+'histType']: 1054 return G2pwd.Absorb('Cylinder',parmDict[hfx+'Absorption']*refl[14 ],parmDict[hfx+'2-theta'],0,0)1054 return G2pwd.Absorb('Cylinder',parmDict[hfx+'Absorption']*refl[14+im],parmDict[hfx+'2-theta'],0,0) 1055 1055 else: 1056 return G2pwd.Absorb('Cylinder',parmDict[hfx+'Absorption'],refl[5 ],0,0)1056 return G2pwd.Absorb('Cylinder',parmDict[hfx+'Absorption'],refl[5+im],0,0) 1057 1057 else: 1058 return G2pwd.SurfaceRough(parmDict[hfx+'SurfRoughA'],parmDict[hfx+'SurfRoughB'],refl[5 ])1059 1060 def GetAbsorbDerv(refl, hfx,calcControls,parmDict):1058 return G2pwd.SurfaceRough(parmDict[hfx+'SurfRoughA'],parmDict[hfx+'SurfRoughB'],refl[5+im]) 1059 1060 def GetAbsorbDerv(refl,im,hfx,calcControls,parmDict): 1061 1061 'Needs a doc string' 1062 1062 if 'Debye' in calcControls[hfx+'instType']: 1063 1063 if 'T' in calcControls[hfx+'histType']: 1064 return G2pwd.AbsorbDerv('Cylinder',parmDict[hfx+'Absorption']*refl[14 ],parmDict[hfx+'2-theta'],0,0)1064 return G2pwd.AbsorbDerv('Cylinder',parmDict[hfx+'Absorption']*refl[14+im],parmDict[hfx+'2-theta'],0,0) 1065 1065 else: 1066 return G2pwd.AbsorbDerv('Cylinder',parmDict[hfx+'Absorption'],refl[5 ],0,0)1066 return G2pwd.AbsorbDerv('Cylinder',parmDict[hfx+'Absorption'],refl[5+im],0,0) 1067 1067 else: 1068 return np.array(G2pwd.SurfaceRoughDerv(parmDict[hfx+'SurfRoughA'],parmDict[hfx+'SurfRoughB'],refl[5 ]))1068 return np.array(G2pwd.SurfaceRoughDerv(parmDict[hfx+'SurfRoughA'],parmDict[hfx+'SurfRoughB'],refl[5+im])) 1069 1069 1070 def GetPwdrExt(refl, pfx,phfx,hfx,calcControls,parmDict):1070 def GetPwdrExt(refl,im,pfx,phfx,hfx,calcControls,parmDict): 1071 1071 'Needs a doc string' 1072 1072 coef = np.array([-0.5,0.25,-0.10416667,0.036458333,-0.0109375,2.8497409E-3]) … … 1074 1074 if 'T' in calcControls[hfx+'histType']: 1075 1075 sth2 = sind(parmDict[hfx+'2-theta']/2.)**2 1076 wave = refl[14 ]1076 wave = refl[14+im] 1077 1077 else: #'C'W 1078 sth2 = sind(refl[5 ]/2.)**21078 sth2 = sind(refl[5+im]/2.)**2 1079 1079 wave = parmDict.get(hfx+'Lam',parmDict.get(hfx+'Lam1',1.0)) 1080 1080 c2th = 1.-2.0*sth2 1081 flv2 = refl[9 ]*(wave/parmDict[pfx+'Vol'])**21081 flv2 = refl[9+im]*(wave/parmDict[pfx+'Vol'])**2 1082 1082 if 'X' in calcControls[hfx+'histType']: 1083 1083 flv2 *= 0.079411*(1.0+c2th**2)/2.0 … … 1095 1095 return exb*sth2+exl*(1.-sth2) 1096 1096 1097 def GetPwdrExtDerv(refl, pfx,phfx,hfx,calcControls,parmDict):1097 def GetPwdrExtDerv(refl,im,pfx,phfx,hfx,calcControls,parmDict): 1098 1098 'Needs a doc string' 1099 1099 delt = 0.001 1100 1100 parmDict[phfx+'Extinction'] += delt 1101 plus = GetPwdrExt(refl, pfx,phfx,hfx,calcControls,parmDict)1101 plus = GetPwdrExt(refl,im,pfx,phfx,hfx,calcControls,parmDict) 1102 1102 parmDict[phfx+'Extinction'] -= 2.*delt 1103 minus = GetPwdrExt(refl, pfx,phfx,hfx,calcControls,parmDict)1103 minus = GetPwdrExt(refl,im,pfx,phfx,hfx,calcControls,parmDict) 1104 1104 parmDict[phfx+'Extinction'] += delt 1105 1105 return (plus-minus)/(2.*delt) 1106 1106 1107 def GetIntensityCorr(refl, uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict):1107 def GetIntensityCorr(refl,im,uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict): 1108 1108 'Needs a doc string' #need powder extinction! 1109 Icorr = parmDict[phfx+'Scale']*parmDict[hfx+'Scale']*refl[3 ] #scale*multiplicity1109 Icorr = parmDict[phfx+'Scale']*parmDict[hfx+'Scale']*refl[3+im] #scale*multiplicity 1110 1110 if 'X' in parmDict[hfx+'Type']: 1111 Icorr *= G2pwd.Polarization(parmDict[hfx+'Polariz.'],refl[5 ],parmDict[hfx+'Azimuth'])[0]1111 Icorr *= G2pwd.Polarization(parmDict[hfx+'Polariz.'],refl[5+im],parmDict[hfx+'Azimuth'])[0] 1112 1112 POcorr = 1.0 1113 1113 if pfx+'SHorder' in parmDict: #generalized spherical harmonics texture 1114 POcorr = SHTXcal(refl, g,pfx,hfx,SGData,calcControls,parmDict)1114 POcorr = SHTXcal(refl,im,g,pfx,hfx,SGData,calcControls,parmDict) 1115 1115 elif calcControls[phfx+'poType'] == 'MD': #March-Dollase 1116 POcorr = GetPrefOri( refl,uniq,G,g,phfx,hfx,SGData,calcControls,parmDict)1116 POcorr = GetPrefOri(uniq,G,g,phfx,hfx,SGData,calcControls,parmDict) 1117 1117 elif calcControls[phfx+'SHord']: #cylindrical spherical harmonics 1118 POcorr = SHPOcal(refl, g,phfx,hfx,SGData,calcControls,parmDict)1118 POcorr = SHPOcal(refl,im,g,phfx,hfx,SGData,calcControls,parmDict) 1119 1119 Icorr *= POcorr 1120 1120 AbsCorr = 1.0 1121 AbsCorr = GetAbsorb(refl, hfx,calcControls,parmDict)1121 AbsCorr = GetAbsorb(refl,im,hfx,calcControls,parmDict) 1122 1122 Icorr *= AbsCorr 1123 ExtCorr = GetPwdrExt(refl, pfx,phfx,hfx,calcControls,parmDict)1123 ExtCorr = GetPwdrExt(refl,im,pfx,phfx,hfx,calcControls,parmDict) 1124 1124 Icorr *= ExtCorr 1125 1125 return Icorr,POcorr,AbsCorr,ExtCorr 1126 1126 1127 def GetIntensityDerv(refl, wave,uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict):1127 def GetIntensityDerv(refl,im,wave,uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict): 1128 1128 'Needs a doc string' #need powder extinction derivs! 1129 1129 dIdsh = 1./parmDict[hfx+'Scale'] 1130 1130 dIdsp = 1./parmDict[phfx+'Scale'] 1131 1131 if 'X' in parmDict[hfx+'Type']: 1132 pola,dIdPola = G2pwd.Polarization(parmDict[hfx+'Polariz.'],refl[5 ],parmDict[hfx+'Azimuth'])1132 pola,dIdPola = G2pwd.Polarization(parmDict[hfx+'Polariz.'],refl[5+im],parmDict[hfx+'Azimuth']) 1133 1133 dIdPola /= pola 1134 1134 else: #'N' … … 1138 1138 dIdPO = {} 1139 1139 if pfx+'SHorder' in parmDict: 1140 odfCor,dFdODF,dFdSA = SHTXcalDerv(refl, g,pfx,hfx,SGData,calcControls,parmDict)1140 odfCor,dFdODF,dFdSA = SHTXcalDerv(refl,im,g,pfx,hfx,SGData,calcControls,parmDict) 1141 1141 for iSH in dFdODF: 1142 1142 dFdODF[iSH] /= odfCor … … 1144 1144 dFdSA[i] /= odfCor 1145 1145 elif calcControls[phfx+'poType'] == 'MD' or calcControls[phfx+'SHord']: 1146 POcorr,dIdPO = GetPrefOriDerv(refl, uniq,G,g,phfx,hfx,SGData,calcControls,parmDict)1146 POcorr,dIdPO = GetPrefOriDerv(refl,im,uniq,G,g,phfx,hfx,SGData,calcControls,parmDict) 1147 1147 for iPO in dIdPO: 1148 1148 dIdPO[iPO] /= POcorr 1149 1149 if 'T' in parmDict[hfx+'Type']: 1150 dFdAb = GetAbsorbDerv(refl, hfx,calcControls,parmDict)*wave/refl[16] #wave/abs corr1151 dFdEx = GetPwdrExtDerv(refl, pfx,phfx,hfx,calcControls,parmDict)/refl[17] #/ext corr1150 dFdAb = GetAbsorbDerv(refl,im,hfx,calcControls,parmDict)*wave/refl[16+im] #wave/abs corr 1151 dFdEx = GetPwdrExtDerv(refl,im,pfx,phfx,hfx,calcControls,parmDict)/refl[17+im] #/ext corr 1152 1152 else: 1153 dFdAb = GetAbsorbDerv(refl, hfx,calcControls,parmDict)*wave/refl[13] #wave/abs corr1154 dFdEx = GetPwdrExtDerv(refl, pfx,phfx,hfx,calcControls,parmDict)/refl[14] #/ext corr1153 dFdAb = GetAbsorbDerv(refl,im,hfx,calcControls,parmDict)*wave/refl[13+im] #wave/abs corr 1154 dFdEx = GetPwdrExtDerv(refl,im,pfx,phfx,hfx,calcControls,parmDict)/refl[14+im] #/ext corr 1155 1155 return dIdsh,dIdsp,dIdPola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx 1156 1156 1157 def GetSampleSigGam(refl, wave,G,GB,SGData,hfx,phfx,calcControls,parmDict):1157 def GetSampleSigGam(refl,im,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict): 1158 1158 'Needs a doc string' 1159 1159 if 'C' in calcControls[hfx+'histType']: #All checked & OK 1160 costh = cosd(refl[5 ]/2.)1160 costh = cosd(refl[5+im]/2.) 1161 1161 #crystallite size 1162 1162 if calcControls[phfx+'SizeType'] == 'isotropic': … … 1175 1175 #microstrain 1176 1176 if calcControls[phfx+'MustrainType'] == 'isotropic': 1177 Mgam = 0.018*parmDict[phfx+'Mustrain;i']*tand(refl[5 ]/2.)/np.pi1177 Mgam = 0.018*parmDict[phfx+'Mustrain;i']*tand(refl[5+im]/2.)/np.pi 1178 1178 elif calcControls[phfx+'MustrainType'] == 'uniaxial': 1179 1179 H = np.array(refl[:3]) … … 1182 1182 Si = parmDict[phfx+'Mustrain;i'] 1183 1183 Sa = parmDict[phfx+'Mustrain;a'] 1184 Mgam = 0.018*Si*Sa*tand(refl[5 ]/2.)/(np.pi*np.sqrt((Si*cosP)**2+(Sa*sinP)**2))1184 Mgam = 0.018*Si*Sa*tand(refl[5+im]/2.)/(np.pi*np.sqrt((Si*cosP)**2+(Sa*sinP)**2)) 1185 1185 else: #generalized - P.W. Stephens model 1186 1186 Strms = G2spc.MustrainCoeff(refl[:3],SGData) … … 1188 1188 for i,strm in enumerate(Strms): 1189 1189 Sum += parmDict[phfx+'Mustrain:'+str(i)]*strm 1190 Mgam = 0.018*refl[4 ]**2*tand(refl[5]/2.)*np.sqrt(Sum)/np.pi1190 Mgam = 0.018*refl[4+im]**2*tand(refl[5+im]/2.)*np.sqrt(Sum)/np.pi 1191 1191 elif 'T' in calcControls[hfx+'histType']: #All checked & OK 1192 1192 #crystallite size 1193 1193 if calcControls[phfx+'SizeType'] == 'isotropic': #OK 1194 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4 ]**2/parmDict[phfx+'Size;i']1194 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4+im]**2/parmDict[phfx+'Size;i'] 1195 1195 elif calcControls[phfx+'SizeType'] == 'uniaxial': #OK 1196 1196 H = np.array(refl[:3]) 1197 1197 P = np.array(calcControls[phfx+'SizeAxis']) 1198 1198 cosP,sinP = G2lat.CosSinAngle(H,P,G) 1199 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4 ]**2/(parmDict[phfx+'Size;i']*parmDict[phfx+'Size;a'])1199 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4+im]**2/(parmDict[phfx+'Size;i']*parmDict[phfx+'Size;a']) 1200 1200 Sgam *= np.sqrt((sinP*parmDict[phfx+'Size;a'])**2+(cosP*parmDict[phfx+'Size;i'])**2) 1201 1201 else: #ellipsoidal crystallites #OK … … 1203 1203 H = np.array(refl[:3]) 1204 1204 lenR = G2pwd.ellipseSize(H,Sij,GB) 1205 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4 ]**2/lenR1205 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4+im]**2/lenR 1206 1206 #microstrain 1207 1207 if calcControls[phfx+'MustrainType'] == 'isotropic': #OK 1208 Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4 ]*parmDict[phfx+'Mustrain;i']1208 Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4+im]*parmDict[phfx+'Mustrain;i'] 1209 1209 elif calcControls[phfx+'MustrainType'] == 'uniaxial': #OK 1210 1210 H = np.array(refl[:3]) … … 1213 1213 Si = parmDict[phfx+'Mustrain;i'] 1214 1214 Sa = parmDict[phfx+'Mustrain;a'] 1215 Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4 ]*Si*Sa/np.sqrt((Si*cosP)**2+(Sa*sinP)**2)1215 Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4+im]*Si*Sa/np.sqrt((Si*cosP)**2+(Sa*sinP)**2) 1216 1216 else: #generalized - P.W. Stephens model OK 1217 1217 Strms = G2spc.MustrainCoeff(refl[:3],SGData) … … 1219 1219 for i,strm in enumerate(Strms): 1220 1220 Sum += parmDict[phfx+'Mustrain:'+str(i)]*strm 1221 Mgam = 1.e-6*parmDict[hfx+'difC']*np.sqrt(Sum)*refl[4 ]**31221 Mgam = 1.e-6*parmDict[hfx+'difC']*np.sqrt(Sum)*refl[4+im]**3 1222 1222 1223 1223 gam = Sgam*parmDict[phfx+'Size;mx']+Mgam*parmDict[phfx+'Mustrain;mx'] … … 1226 1226 return sig,gam 1227 1227 1228 def GetSampleSigGamDerv(refl, wave,G,GB,SGData,hfx,phfx,calcControls,parmDict):1228 def GetSampleSigGamDerv(refl,im,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict): 1229 1229 'Needs a doc string' 1230 1230 gamDict = {} 1231 1231 sigDict = {} 1232 1232 if 'C' in calcControls[hfx+'histType']: #All checked & OK 1233 costh = cosd(refl[5 ]/2.)1234 tanth = tand(refl[5 ]/2.)1233 costh = cosd(refl[5+im]/2.) 1234 tanth = tand(refl[5+im]/2.) 1235 1235 #crystallite size derivatives 1236 1236 if calcControls[phfx+'SizeType'] == 'isotropic': … … 1267 1267 #microstrain derivatives 1268 1268 if calcControls[phfx+'MustrainType'] == 'isotropic': 1269 Mgam = 0.018*parmDict[phfx+'Mustrain;i']*tand(refl[5 ]/2.)/np.pi1269 Mgam = 0.018*parmDict[phfx+'Mustrain;i']*tand(refl[5+im]/2.)/np.pi 1270 1270 gamDict[phfx+'Mustrain;i'] = 0.018*tanth*parmDict[phfx+'Mustrain;mx']/np.pi 1271 1271 sigDict[phfx+'Mustrain;i'] = 0.036*Mgam*tanth*(1.-parmDict[phfx+'Mustrain;mx'])**2/(np.pi*ateln2) … … 1286 1286 sigDict[phfx+'Mustrain;a'] = 2*(Mgam/Sa+dsa)*Mgam*(1.-parmDict[phfx+'Mustrain;mx'])**2/ateln2 1287 1287 else: #generalized - P.W. Stephens model 1288 const = 0.018*refl[4 ]**2*tanth/np.pi1288 const = 0.018*refl[4+im]**2*tanth/np.pi 1289 1289 Strms = G2spc.MustrainCoeff(refl[:3],SGData) 1290 1290 Sum = 0 … … 1301 1301 else: #'T'OF - All checked & OK 1302 1302 if calcControls[phfx+'SizeType'] == 'isotropic': #OK 1303 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4 ]**2/parmDict[phfx+'Size;i']1303 Sgam = 1.e-4*parmDict[hfx+'difC']*refl[4+im]**2/parmDict[phfx+'Size;i'] 1304 1304 gamDict[phfx+'Size;i'] = -Sgam*parmDict[phfx+'Size;mx']/parmDict[phfx+'Size;i'] 1305 1305 sigDict[phfx+'Size;i'] = -2.*Sgam**2*(1.-parmDict[phfx+'Size;mx'])**2/(ateln2*parmDict[phfx+'Size;i']) 1306 1306 elif calcControls[phfx+'SizeType'] == 'uniaxial': #OK 1307 const = 1.e-4*parmDict[hfx+'difC']*refl[4 ]**21307 const = 1.e-4*parmDict[hfx+'difC']*refl[4+im]**2 1308 1308 H = np.array(refl[:3]) 1309 1309 P = np.array(calcControls[phfx+'SizeAxis']) … … 1321 1321 sigDict[phfx+'Size;a'] = 2.*dsa*Sgam*(1.-parmDict[phfx+'Size;mx'])**2/ateln2 1322 1322 else: #OK ellipsoidal crystallites 1323 const = 1.e-4*parmDict[hfx+'difC']*refl[4 ]**21323 const = 1.e-4*parmDict[hfx+'difC']*refl[4+im]**2 1324 1324 Sij =[parmDict[phfx+'Size:%d'%(i)] for i in range(6)] 1325 1325 H = np.array(refl[:3]) … … 1334 1334 #microstrain derivatives 1335 1335 if calcControls[phfx+'MustrainType'] == 'isotropic': 1336 Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4 ]*parmDict[phfx+'Mustrain;i']1337 gamDict[phfx+'Mustrain;i'] = 1.e-6*refl[4 ]*parmDict[hfx+'difC']*parmDict[phfx+'Mustrain;mx'] #OK1336 Mgam = 1.e-6*parmDict[hfx+'difC']*refl[4+im]*parmDict[phfx+'Mustrain;i'] 1337 gamDict[phfx+'Mustrain;i'] = 1.e-6*refl[4+im]*parmDict[hfx+'difC']*parmDict[phfx+'Mustrain;mx'] #OK 1338 1338 sigDict[phfx+'Mustrain;i'] = 2.*Mgam**2*(1.-parmDict[phfx+'Mustrain;mx'])**2/(ateln2*parmDict[phfx+'Mustrain;i']) 1339 1339 elif calcControls[phfx+'MustrainType'] == 'uniaxial': … … 1343 1343 Si = parmDict[phfx+'Mustrain;i'] 1344 1344 Sa = parmDict[phfx+'Mustrain;a'] 1345 gami = 1.e-6*parmDict[hfx+'difC']*refl[4 ]*Si*Sa1345 gami = 1.e-6*parmDict[hfx+'difC']*refl[4+im]*Si*Sa 1346 1346 sqtrm = np.sqrt((Si*cosP)**2+(Sa*sinP)**2) 1347 1347 Mgam = gami/sqtrm … … 1355 1355 pwrs = calcControls[phfx+'MuPwrs'] 1356 1356 Strms = G2spc.MustrainCoeff(refl[:3],SGData) 1357 const = 1.e-6*parmDict[hfx+'difC']*refl[4 ]**31357 const = 1.e-6*parmDict[hfx+'difC']*refl[4+im]**3 1358 1358 Sum = 0 1359 1359 for i,strm in enumerate(Strms): … … 1370 1370 return sigDict,gamDict 1371 1371 1372 def GetReflPos(refl, wave,A,hfx,calcControls,parmDict):1372 def GetReflPos(refl,im,wave,A,hfx,calcControls,parmDict): 1373 1373 'Needs a doc string' 1374 1374 h,k,l = refl[:3] 1375 1375 d = 1./np.sqrt(G2lat.calc_rDsq(np.array([h,k,l]),A)) 1376 1376 1377 refl[4 ] = d1377 refl[4+im] = d 1378 1378 if 'C' in calcControls[hfx+'histType']: 1379 1379 pos = 2.0*asind(wave/(2.0*d))+parmDict[hfx+'Zero'] … … 1389 1389 return pos 1390 1390 1391 def GetReflPosDerv(refl, wave,A,hfx,calcControls,parmDict):1391 def GetReflPosDerv(refl,im,wave,A,hfx,calcControls,parmDict): 1392 1392 'Needs a doc string' 1393 1393 dpr = 180./np.pi … … 1397 1397 dsp = 1./dst 1398 1398 if 'C' in calcControls[hfx+'histType']: 1399 pos = refl[5 ]-parmDict[hfx+'Zero']1399 pos = refl[5+im]-parmDict[hfx+'Zero'] 1400 1400 const = dpr/np.sqrt(1.0-wave**2*dstsq/4.0) 1401 1401 dpdw = const*dst … … 1419 1419 return dpdA,dpdZ,dpdDC,dpdDA,dpdDB 1420 1420 1421 def GetHStrainShift(refl, SGData,phfx,hfx,calcControls,parmDict):1421 def GetHStrainShift(refl,im,SGData,phfx,hfx,calcControls,parmDict): 1422 1422 'Needs a doc string' 1423 1423 laue = SGData['SGLaue'] … … 1426 1426 if laue in ['m3','m3m']: 1427 1427 Dij = parmDict[phfx+'D11']*(h**2+k**2+l**2)+ \ 1428 refl[4 ]**2*parmDict[phfx+'eA']*((h*k)**2+(h*l)**2+(k*l)**2)/(h**2+k**2+l**2)**21428 refl[4+im]**2*parmDict[phfx+'eA']*((h*k)**2+(h*l)**2+(k*l)**2)/(h**2+k**2+l**2)**2 1429 1429 elif laue in ['6/m','6/mmm','3m1','31m','3']: 1430 1430 Dij = parmDict[phfx+'D11']*(h**2+k**2+h*k)+parmDict[phfx+'D33']*l**2 … … 1447 1447 parmDict[phfx+'D12']*h*k+parmDict[phfx+'D13']*h*l+parmDict[phfx+'D23']*k*l 1448 1448 if 'C' in calcControls[hfx+'histType']: 1449 return -180.*Dij*refl[4 ]**2*tand(refl[5]/2.0)/np.pi1449 return -180.*Dij*refl[4+im]**2*tand(refl[5+im]/2.0)/np.pi 1450 1450 else: 1451 return -Dij*parmDict[hfx+'difC']*refl[4 ]**2/2.1451 return -Dij*parmDict[hfx+'difC']*refl[4+im]**2/2. 1452 1452 1453 def GetHStrainShiftDerv(refl, SGData,phfx,hfx,calcControls,parmDict):1453 def GetHStrainShiftDerv(refl,im,SGData,phfx,hfx,calcControls,parmDict): 1454 1454 'Needs a doc string' 1455 1455 laue = SGData['SGLaue'] … … 1458 1458 if laue in ['m3','m3m']: 1459 1459 dDijDict = {phfx+'D11':h**2+k**2+l**2, 1460 phfx+'eA':refl[4 ]**2*((h*k)**2+(h*l)**2+(k*l)**2)/(h**2+k**2+l**2)**2}1460 phfx+'eA':refl[4+im]**2*((h*k)**2+(h*l)**2+(k*l)**2)/(h**2+k**2+l**2)**2} 1461 1461 elif laue in ['6/m','6/mmm','3m1','31m','3']: 1462 1462 dDijDict = {phfx+'D11':h**2+k**2+h*k,phfx+'D33':l**2} … … 1481 1481 if 'C' in calcControls[hfx+'histType']: 1482 1482 for item in dDijDict: 1483 dDijDict[item] *= 180.0*refl[4 ]**2*tand(refl[5]/2.0)/np.pi1483 dDijDict[item] *= 180.0*refl[4+im]**2*tand(refl[5+im]/2.0)/np.pi 1484 1484 else: 1485 1485 for item in dDijDict: 1486 dDijDict[item] *= -parmDict[hfx+'difC']*refl[4 ]**3/2.1486 dDijDict[item] *= -parmDict[hfx+'difC']*refl[4+im]**3/2. 1487 1487 return dDijDict 1488 1488 … … 1519 1519 for phase in refLists: 1520 1520 Phase = Phases[phase] 1521 im = 0 1522 if Phase['General']['Type'] in ['modulated','magnetic']: 1523 im = 1 1521 1524 pId = Phase['pId'] 1522 1525 phfx = '%d:%d:'%(pId,hId) … … 1529 1532 if 'C' in calcControls[hfx+'histType']: 1530 1533 yp = np.zeros_like(yb) 1531 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5 ],refl[6],refl[7],shl)1532 iBeg = max(xB,np.searchsorted(x,refl[5 ]-fmin))1533 iFin = max(xB,min(np.searchsorted(x,refl[5 ]+fmax),xF))1534 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5+im],refl[6+im],refl[7+im],shl) 1535 iBeg = max(xB,np.searchsorted(x,refl[5+im]-fmin)) 1536 iFin = max(xB,min(np.searchsorted(x,refl[5+im]+fmax),xF)) 1534 1537 iFin2 = iFin 1535 1538 if not iBeg+iFin: #peak below low limit - skip peak … … 1538 1541 break 1539 1542 elif iBeg < iFin: 1540 yp[iBeg:iFin] = refl[11 ]*refl[9]*G2pwd.getFCJVoigt3(refl[5],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here1543 yp[iBeg:iFin] = refl[11+im]*refl[9+im]*G2pwd.getFCJVoigt3(refl[5+im],refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1541 1544 if Ka2: 1542 pos2 = refl[5 ]+lamRatio*tand(refl[5]/2.0) # + 360/pi * Dlam/lam * tan(th)1543 Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6 ],refl[7],shl)1545 pos2 = refl[5+im]+lamRatio*tand(refl[5+im]/2.0) # + 360/pi * Dlam/lam * tan(th) 1546 Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6+im],refl[7+im],shl) 1544 1547 iBeg2 = max(xB,np.searchsorted(x,pos2-fmin)) 1545 1548 iFin2 = min(np.searchsorted(x,pos2+fmax),xF) 1546 yp[iBeg2:iFin2] += refl[11 ]*refl[9]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6],refl[7],shl,ma.getdata(x[iBeg2:iFin2])) #and here1547 refl[8 ] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11]*(1.+kRatio)),0.0))1549 yp[iBeg2:iFin2] += refl[11+im]*refl[9+im]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg2:iFin2])) #and here 1550 refl[8+im] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11+im]*(1.+kRatio)),0.0)) 1548 1551 elif 'T' in calcControls[hfx+'histType']: 1549 1552 yp = np.zeros_like(yb) 1550 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5 ],refl[12],refl[13],refl[6],refl[7])1551 iBeg = max(xB,np.searchsorted(x,refl[5 ]-fmin))1552 iFin = max(xB,min(np.searchsorted(x,refl[5 ]+fmax),xF))1553 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im]) 1554 iBeg = max(xB,np.searchsorted(x,refl[5+im]-fmin)) 1555 iFin = max(xB,min(np.searchsorted(x,refl[5+im]+fmax),xF)) 1553 1556 if iBeg < iFin: 1554 yp[iBeg:iFin] = refl[11 ]*refl[9]*G2pwd.getEpsVoigt(refl[5],refl[12],refl[13],refl[6],refl[7],ma.getdata(x[iBeg:iFin])) #>90% of time spent here1555 refl[8 ] = np.sum(np.where(ratio[iBeg:iFin]>0.,yp[iBeg:iFin]*ratio[iBeg:iFin]/refl[11],0.0))1556 Fo = np.sqrt(np.abs(refl[8 ]))1557 Fc = np.sqrt(np.abs(refl[9] ))1557 yp[iBeg:iFin] = refl[11+im]*refl[9+im]*G2pwd.getEpsVoigt(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im],ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1558 refl[8+im] = np.sum(np.where(ratio[iBeg:iFin]>0.,yp[iBeg:iFin]*ratio[iBeg:iFin]/refl[11+im],0.0)) 1559 Fo = np.sqrt(np.abs(refl[8+im])) 1560 Fc = np.sqrt(np.abs(refl[9]+im)) 1558 1561 sumFo += Fo 1559 sumFosq += refl[8 ]**21562 sumFosq += refl[8+im]**2 1560 1563 sumdF += np.abs(Fo-Fc) 1561 sumdFsq += (refl[8 ]-refl[9])**21564 sumdFsq += (refl[8+im]-refl[9+im])**2 1562 1565 Histogram['Residuals'][phfx+'Rf'] = min(100.,(sumdF/sumFo)*100.) 1563 1566 Histogram['Residuals'][phfx+'Rf^2'] = min(100.,np.sqrt(sumdFsq/sumFosq)*100.) … … 1571 1574 'Needs a doc string' 1572 1575 1573 def GetReflSigGamCW(refl, wave,G,GB,phfx,calcControls,parmDict):1576 def GetReflSigGamCW(refl,im,wave,G,GB,phfx,calcControls,parmDict): 1574 1577 U = parmDict[hfx+'U'] 1575 1578 V = parmDict[hfx+'V'] … … 1577 1580 X = parmDict[hfx+'X'] 1578 1581 Y = parmDict[hfx+'Y'] 1579 tanPos = tand(refl[5 ]/2.0)1580 Ssig,Sgam = GetSampleSigGam(refl, wave,G,GB,SGData,hfx,phfx,calcControls,parmDict)1582 tanPos = tand(refl[5+im]/2.0) 1583 Ssig,Sgam = GetSampleSigGam(refl,im,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict) 1581 1584 sig = U*tanPos**2+V*tanPos+W+Ssig #save peak sigma 1582 1585 sig = max(0.001,sig) 1583 gam = X/cosd(refl[5 ]/2.0)+Y*tanPos+Sgam #save peak gamma1586 gam = X/cosd(refl[5+im]/2.0)+Y*tanPos+Sgam #save peak gamma 1584 1587 gam = max(0.001,gam) 1585 1588 return sig,gam 1586 1589 1587 def GetReflSigGamTOF(refl, G,GB,phfx,calcControls,parmDict):1588 sig = parmDict[hfx+'sig-0']+parmDict[hfx+'sig-1']*refl[4 ]**2+ \1589 parmDict[hfx+'sig-2']*refl[4 ]**4+parmDict[hfx+'sig-q']/refl[4]**21590 gam = parmDict[hfx+'X']*refl[4 ]+parmDict[hfx+'Y']*refl[4]**21591 Ssig,Sgam = GetSampleSigGam(refl, 0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)1590 def GetReflSigGamTOF(refl,im,G,GB,phfx,calcControls,parmDict): 1591 sig = parmDict[hfx+'sig-0']+parmDict[hfx+'sig-1']*refl[4+im]**2+ \ 1592 parmDict[hfx+'sig-2']*refl[4+im]**4+parmDict[hfx+'sig-q']/refl[4+im]**2 1593 gam = parmDict[hfx+'X']*refl[4+im]+parmDict[hfx+'Y']*refl[4+im]**2 1594 Ssig,Sgam = GetSampleSigGam(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict) 1592 1595 sig += Ssig 1593 1596 gam += Sgam 1594 1597 return sig,gam 1595 1598 1596 def GetReflAlpBet(refl, hfx,parmDict):1597 alp = parmDict[hfx+'alpha']/refl[4 ]1598 bet = parmDict[hfx+'beta-0']+parmDict[hfx+'beta-1']/refl[4 ]**4+parmDict[hfx+'beta-q']/refl[4]**21599 def GetReflAlpBet(refl,im,hfx,parmDict): 1600 alp = parmDict[hfx+'alpha']/refl[4+im] 1601 bet = parmDict[hfx+'beta-0']+parmDict[hfx+'beta-1']/refl[4+im]**4+parmDict[hfx+'beta-q']/refl[4+im]**2 1599 1602 return alp,bet 1600 1603 … … 1626 1629 SGData = Phase['General']['SGData'] 1627 1630 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1631 im = 0 1632 if Phase['General']['Type'] in ['modulated','magnetic']: 1633 SSGData = Phase['General']['SSGData'] 1634 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 1635 im = 1 #offset in SS reflection list 1636 #?? 1628 1637 Dij = GetDij(phfx,SGData,parmDict) 1629 1638 A = [parmDict[pfx+'A%d'%(i)]+Dij[i] for i in range(6)] … … 1639 1648 for iref,refl in enumerate(refDict['RefList']): 1640 1649 if 'C' in calcControls[hfx+'histType']: 1641 h,k,l = refl[:3] 1650 if im: 1651 h,k,l,m = refl[:4] 1652 else: 1653 h,k,l = refl[:3] 1642 1654 Uniq = np.inner(refl[:3],SGMT) 1643 refl[5 ] = GetReflPos(refl,wave,A,hfx,calcControls,parmDict) #corrected reflection position1644 Lorenz = 1./(2.*sind(refl[5 ]/2.)**2*cosd(refl[5]/2.)) #Lorentz correction1645 # refl[5 ] += GetHStrainShift(refl,SGData,phfx,hfx,calcControls,parmDict) #apply hydrostatic strain shift1646 refl[6 :8] = GetReflSigGamCW(refl,wave,G,GB,phfx,calcControls,parmDict) #peak sig & gam1647 refl[11 :15] = GetIntensityCorr(refl,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict)1648 refl[11 ] *= Vst*Lorenz1655 refl[5+im] = GetReflPos(refl,im,wave,A,hfx,calcControls,parmDict) #corrected reflection position 1656 Lorenz = 1./(2.*sind(refl[5+im]/2.)**2*cosd(refl[5+im]/2.)) #Lorentz correction 1657 # refl[5+im] += GetHStrainShift(refl,im,SGData,phfx,hfx,calcControls,parmDict) #apply hydrostatic strain shift 1658 refl[6+im:8+im] = GetReflSigGamCW(refl,im,wave,G,GB,phfx,calcControls,parmDict) #peak sig & gam 1659 refl[11+im:15+im] = GetIntensityCorr(refl,im,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 1660 refl[11+im] *= Vst*Lorenz 1649 1661 1650 1662 if Phase['General'].get('doPawley'): 1651 1663 try: 1652 pInd =pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 1653 refl[9] = parmDict[pInd] 1664 if im: 1665 pInd = pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d,%d'%(h,k,l,m)]) 1666 else: 1667 pInd = pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 1668 refl[9+im] = parmDict[pInd] 1654 1669 except KeyError: 1655 1670 # print ' ***Error %d,%d,%d missing from Pawley reflection list ***'%(h,k,l) 1656 1671 continue 1657 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5 ],refl[6],refl[7],shl)1658 iBeg = np.searchsorted(x,refl[5 ]-fmin)1659 iFin = np.searchsorted(x,refl[5 ]+fmax)1672 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5+im],refl[6+im],refl[7+im],shl) 1673 iBeg = np.searchsorted(x,refl[5+im]-fmin) 1674 iFin = np.searchsorted(x,refl[5+im]+fmax) 1660 1675 if not iBeg+iFin: #peak below low limit - skip peak 1661 1676 continue … … 1665 1680 badPeak = True 1666 1681 continue 1667 yc[iBeg:iFin] += refl[11 ]*refl[9]*G2pwd.getFCJVoigt3(refl[5],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here1682 yc[iBeg:iFin] += refl[11+im]*refl[9+im]*G2pwd.getFCJVoigt3(refl[5+im],refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1668 1683 if Ka2: 1669 pos2 = refl[5 ]+lamRatio*tand(refl[5]/2.0) # + 360/pi * Dlam/lam * tan(th)1670 Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6 ],refl[7],shl)1684 pos2 = refl[5+im]+lamRatio*tand(refl[5+im]/2.0) # + 360/pi * Dlam/lam * tan(th) 1685 Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6+im],refl[7+im],shl) 1671 1686 iBeg = np.searchsorted(x,pos2-fmin) 1672 1687 iFin = np.searchsorted(x,pos2+fmax) … … 1677 1692 elif iBeg > iFin: #bad peak coeff - skip 1678 1693 continue 1679 yc[iBeg:iFin] += refl[11 ]*refl[9]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin])) #and here1694 yc[iBeg:iFin] += refl[11+im]*refl[9+im]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg:iFin])) #and here 1680 1695 elif 'T' in calcControls[hfx+'histType']: 1681 1696 h,k,l = refl[:3] 1682 1697 Uniq = np.inner(refl[:3],SGMT) 1683 refl[5 ] = GetReflPos(refl,0.0,A,hfx,calcControls,parmDict) #corrected reflection position1684 Lorenz = sind(parmDict[hfx+'2-theta']/2)*refl[4 ]**4 #TOF Lorentz correction1685 # refl[5 ] += GetHStrainShift(refl,SGData,phfx,hfx,calcControls,parmDict) #apply hydrostatic strain shift1686 refl[6 :8] = GetReflSigGamTOF(refl,G,GB,phfx,calcControls,parmDict) #peak sig & gam1687 refl[12 :14] = GetReflAlpBet(refl,hfx,parmDict)1688 refl[11 ],refl[15],refl[16],refl[17] = GetIntensityCorr(refl,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict)1689 refl[11 ] *= Vst*Lorenz1698 refl[5+im] = GetReflPos(refl,im,0.0,A,hfx,calcControls,parmDict) #corrected reflection position 1699 Lorenz = sind(parmDict[hfx+'2-theta']/2)*refl[4+im]**4 #TOF Lorentz correction 1700 # refl[5+im] += GetHStrainShift(refl,im,SGData,phfx,hfx,calcControls,parmDict) #apply hydrostatic strain shift 1701 refl[6+im:8+im] = GetReflSigGamTOF(refl,im,G,GB,phfx,calcControls,parmDict) #peak sig & gam 1702 refl[12+im:14+im] = GetReflAlpBet(refl,im,hfx,parmDict) 1703 refl[11+im],refl[15+im],refl[16+im],refl[17+im] = GetIntensityCorr(refl,im,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 1704 refl[11+im] *= Vst*Lorenz 1690 1705 if Phase['General'].get('doPawley'): 1691 1706 try: 1692 pInd =pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 1693 refl[9] = parmDict[pInd] 1707 if im: 1708 pInd =pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d,%d'%(h,k,l,m)]) 1709 else: 1710 pInd =pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 1711 refl[9+im] = parmDict[pInd] 1694 1712 except KeyError: 1695 1713 # print ' ***Error %d,%d,%d missing from Pawley reflection list ***'%(h,k,l) 1696 1714 continue 1697 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5 ],refl[12],refl[13],refl[6],refl[7])1698 iBeg = np.searchsorted(x,refl[5 ]-fmin)1699 iFin = np.searchsorted(x,refl[5 ]+fmax)1715 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im]) 1716 iBeg = np.searchsorted(x,refl[5+im]-fmin) 1717 iFin = np.searchsorted(x,refl[5+im]+fmax) 1700 1718 if not iBeg+iFin: #peak below low limit - skip peak 1701 1719 continue … … 1705 1723 badPeak = True 1706 1724 continue 1707 yc[iBeg:iFin] += refl[11 ]*refl[9]*G2pwd.getEpsVoigt(refl[5],refl[12],refl[13],refl[6],refl[7],ma.getdata(x[iBeg:iFin]))/cw[iBeg:iFin]1725 yc[iBeg:iFin] += refl[11+im]*refl[9+im]*G2pwd.getEpsVoigt(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im],ma.getdata(x[iBeg:iFin]))/cw[iBeg:iFin] 1708 1726 # print 'profile calc time: %.3fs'%(time.time()-time0) 1709 1727 if badPeak: … … 1783 1801 SGData = Phase['General']['SGData'] 1784 1802 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1803 im = 0 1804 if Phase['General']['Type'] in ['modulated','magnetic']: 1805 SSGData = Phase['General']['SSGData'] 1806 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 1807 im = 1 #offset in SS reflection list 1808 #?? 1785 1809 pId = Phase['pId'] 1786 1810 pfx = '%d::'%(pId) … … 1800 1824 Uniq = np.inner(refl[:3],SGMT) 1801 1825 if 'T' in calcControls[hfx+'histType']: 1802 wave = refl[14 ]1803 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl, wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict)1826 wave = refl[14+im] 1827 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl,im,wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 1804 1828 if 'C' in calcControls[hfx+'histType']: #CW powder 1805 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5 ],refl[6],refl[7],shl)1829 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5+im],refl[6+im],refl[7+im],shl) 1806 1830 else: #'T'OF 1807 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5 ],refl[12],refl[13],refl[6],refl[7])1808 iBeg = np.searchsorted(x,refl[5 ]-fmin)1809 iFin = np.searchsorted(x,refl[5 ]+fmax)1831 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im]) 1832 iBeg = np.searchsorted(x,refl[5+im]-fmin) 1833 iFin = np.searchsorted(x,refl[5+im]+fmax) 1810 1834 if not iBeg+iFin: #peak below low limit - skip peak 1811 1835 continue 1812 1836 elif not iBeg-iFin: #peak above high limit - done 1813 1837 break 1814 pos = refl[5 ]1838 pos = refl[5+im] 1815 1839 if 'C' in calcControls[hfx+'histType']: 1816 1840 tanth = tand(pos/2.0) … … 1818 1842 lenBF = iFin-iBeg 1819 1843 dMdpk = np.zeros(shape=(6,lenBF)) 1820 dMdipk = G2pwd.getdFCJVoigt3(refl[5 ],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin]))1844 dMdipk = G2pwd.getdFCJVoigt3(refl[5+im],refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg:iFin])) 1821 1845 for i in range(5): 1822 dMdpk[i] += 100.*cw[iBeg:iFin]*refl[11 ]*refl[9]*dMdipk[i]1846 dMdpk[i] += 100.*cw[iBeg:iFin]*refl[11+im]*refl[9+im]*dMdipk[i] 1823 1847 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'sig':dMdpk[2],'gam':dMdpk[3],'shl':dMdpk[4],'L1/L2':np.zeros_like(dMdpk[0])} 1824 1848 if Ka2: 1825 pos2 = refl[5 ]+lamRatio*tanth # + 360/pi * Dlam/lam * tan(th)1849 pos2 = refl[5+im]+lamRatio*tanth # + 360/pi * Dlam/lam * tan(th) 1826 1850 iBeg2 = np.searchsorted(x,pos2-fmin) 1827 1851 iFin2 = np.searchsorted(x,pos2+fmax) … … 1829 1853 lenBF2 = iFin2-iBeg2 1830 1854 dMdpk2 = np.zeros(shape=(6,lenBF2)) 1831 dMdipk2 = G2pwd.getdFCJVoigt3(pos2,refl[6 ],refl[7],shl,ma.getdata(x[iBeg2:iFin2]))1855 dMdipk2 = G2pwd.getdFCJVoigt3(pos2,refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg2:iFin2])) 1832 1856 for i in range(5): 1833 dMdpk2[i] = 100.*cw[iBeg2:iFin2]*refl[11 ]*refl[9]*kRatio*dMdipk2[i]1834 dMdpk2[5] = 100.*cw[iBeg2:iFin2]*refl[11 ]*dMdipk2[0]1857 dMdpk2[i] = 100.*cw[iBeg2:iFin2]*refl[11+im]*refl[9+im]*kRatio*dMdipk2[i] 1858 dMdpk2[5] = 100.*cw[iBeg2:iFin2]*refl[11+im]*dMdipk2[0] 1835 1859 dervDict2 = {'int':dMdpk2[0],'pos':dMdpk2[1],'sig':dMdpk2[2],'gam':dMdpk2[3],'shl':dMdpk2[4],'L1/L2':dMdpk2[5]*refl[9]} 1836 1860 else: #'T'OF … … 1839 1863 break 1840 1864 dMdpk = np.zeros(shape=(6,lenBF)) 1841 dMdipk = G2pwd.getdEpsVoigt(refl[5 ],refl[12],refl[13],refl[6],refl[7],ma.getdata(x[iBeg:iFin]))1865 dMdipk = G2pwd.getdEpsVoigt(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im],ma.getdata(x[iBeg:iFin])) 1842 1866 for i in range(6): 1843 dMdpk[i] += refl[11 ]*refl[9]*dMdipk[i] #cw[iBeg:iFin]*1867 dMdpk[i] += refl[11+im]*refl[9+im]*dMdipk[i] #cw[iBeg:iFin]* 1844 1868 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4],'gam':dMdpk[5]} 1845 1869 if Phase['General'].get('doPawley'): 1846 1870 dMdpw = np.zeros(len(x)) 1847 1871 try: 1848 pIdx = pfx+'PWLref:'+str(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 1872 if im: 1873 pIdx = pfx+'PWLref:'+str(pawleyLookup[pfx+'%d,%d,%d,%d'%(h,k,l,m)]) 1874 else: 1875 pIdx = pfx+'PWLref:'+str(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 1849 1876 idx = varylist.index(pIdx) 1850 dMdpw[iBeg:iFin] = dervDict['int']/refl[9 ]1877 dMdpw[iBeg:iFin] = dervDict['int']/refl[9+im] 1851 1878 if Ka2: #not for TOF either 1852 dMdpw[iBeg2:iFin2] += dervDict2['int']/refl[9 ]1879 dMdpw[iBeg2:iFin2] += dervDict2['int']/refl[9+im] 1853 1880 dMdv[idx] = dMdpw 1854 1881 except: # ValueError: 1855 1882 pass 1856 1883 if 'C' in calcControls[hfx+'histType']: 1857 dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY = GetReflPosDerv(refl, wave,A,hfx,calcControls,parmDict)1884 dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY = GetReflPosDerv(refl,im,wave,A,hfx,calcControls,parmDict) 1858 1885 names = {hfx+'Scale':[dIdsh,'int'],hfx+'Polariz.':[dIdpola,'int'],phfx+'Scale':[dIdsp,'int'], 1859 1886 hfx+'U':[tanth**2,'sig'],hfx+'V':[tanth,'sig'],hfx+'W':[1.0,'sig'], … … 1871 1898 names = {hfx+'Scale':[dIdsh,'int'],phfx+'Scale':[dIdsp,'int'], 1872 1899 hfx+'difC':[dpdDC,'pos'],hfx+'difA':[dpdDA,'pos'],hfx+'difB':[dpdDB,'pos'], 1873 hfx+'Zero':[dpdZ,'pos'],hfx+'X':[refl[4 ],'gam'],hfx+'Y':[refl[4]**2,'gam'],1874 hfx+'alpha':[1./refl[4 ],'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[1./refl[4]**4,'bet'],1875 hfx+'beta-q':[1./refl[4 ]**2,'bet'],hfx+'sig-0':[1.0,'sig'],hfx+'sig-1':[refl[4]**2,'sig'],1876 hfx+'sig-2':[refl[4 ]**4,'sig'],hfx+'sig-q':[1./refl[4]**2,'sig'],1900 hfx+'Zero':[dpdZ,'pos'],hfx+'X':[refl[4+im],'gam'],hfx+'Y':[refl[4+im]**2,'gam'], 1901 hfx+'alpha':[1./refl[4+im],'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[1./refl[4+im]**4,'bet'], 1902 hfx+'beta-q':[1./refl[4+im]**2,'bet'],hfx+'sig-0':[1.0,'sig'],hfx+'sig-1':[refl[4+im]**2,'sig'], 1903 hfx+'sig-2':[refl[4+im]**4,'sig'],hfx+'sig-q':[1./refl[4+im]**2,'sig'], 1877 1904 hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],} 1878 1905 for name in names: … … 1924 1951 if Ka2: 1925 1952 depDerivDict[name][iBeg2:iFin2] += dpdA*dervDict2['pos'] 1926 dDijDict = GetHStrainShiftDerv(refl, SGData,phfx,hfx,calcControls,parmDict)1953 dDijDict = GetHStrainShiftDerv(refl,im,SGData,phfx,hfx,calcControls,parmDict) 1927 1954 for name in dDijDict: 1928 1955 if name in varylist: … … 1935 1962 depDerivDict[name][iBeg2:iFin2] += dDijDict[name]*dervDict2['pos'] 1936 1963 if 'C' in calcControls[hfx+'histType']: 1937 sigDict,gamDict = GetSampleSigGamDerv(refl, wave,G,GB,SGData,hfx,phfx,calcControls,parmDict)1964 sigDict,gamDict = GetSampleSigGamDerv(refl,im,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict) 1938 1965 else: #'T'OF 1939 sigDict,gamDict = GetSampleSigGamDerv(refl, 0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)1966 sigDict,gamDict = GetSampleSigGamDerv(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict) 1940 1967 for name in gamDict: 1941 1968 if name in varylist: … … 1957 1984 depDerivDict[name][iBeg2:iFin2] += sigDict[name]*dervDict2['sig'] 1958 1985 for name in ['BabA','BabU']: 1959 if refl[9 ]:1986 if refl[9+im]: 1960 1987 if phfx+name in varylist: 1961 dMdv[varylist.index(phfx+name)][iBeg:iFin] += dFdvDict[pfx+name][iref]*dervDict['int']/refl[9 ]1988 dMdv[varylist.index(phfx+name)][iBeg:iFin] += dFdvDict[pfx+name][iref]*dervDict['int']/refl[9+im] 1962 1989 if Ka2: 1963 dMdv[varylist.index(phfx+name)][iBeg2:iFin2] += dFdvDict[pfx+name][iref]*dervDict2['int']/refl[9 ]1990 dMdv[varylist.index(phfx+name)][iBeg2:iFin2] += dFdvDict[pfx+name][iref]*dervDict2['int']/refl[9+im] 1964 1991 elif phfx+name in dependentVars: 1965 depDerivDict[phfx+name][iBeg:iFin] += dFdvDict[pfx+name][iref]*dervDict['int']/refl[9 ]1992 depDerivDict[phfx+name][iBeg:iFin] += dFdvDict[pfx+name][iref]*dervDict['int']/refl[9+im] 1966 1993 if Ka2: 1967 depDerivDict[phfx+name][iBeg2:iFin2] += dFdvDict[pfx+name][iref]*dervDict2['int']/refl[9 ]1994 depDerivDict[phfx+name][iBeg2:iFin2] += dFdvDict[pfx+name][iref]*dervDict2['int']/refl[9+im] 1968 1995 if not Phase['General'].get('doPawley'): 1969 1996 #do atom derivatives - for RB,F,X & U so far 1970 corr = dervDict['int']/refl[9 ]1997 corr = dervDict['int']/refl[9+im] 1971 1998 if Ka2: 1972 corr2 = dervDict2['int']/refl[9 ]1999 corr2 = dervDict2['int']/refl[9+im] 1973 2000 for name in varylist+dependentVars: 1974 2001 if '::RBV;' in name: … … 2006 2033 phfx = '%d:%d:'%(Phase['pId'],hId) 2007 2034 SGData = Phase['General']['SGData'] 2035 im = 0 2036 if Phase['General']['Type'] in ['modulated','magnetic']: 2037 SSGData = Phase['General']['SSGData'] 2038 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 2039 im = 1 #offset in SS reflection list 2040 #?? 2008 2041 A = [parmDict[pfx+'A%d'%(i)] for i in range(6)] 2009 2042 G,g = G2lat.A2Gmat(A) #recip & real metric tensors … … 2019 2052 if calcControls['F**2']: 2020 2053 for iref,ref in enumerate(refDict['RefList']): 2021 if ref[6 ] > 0:2022 dervDict = SCExtinction(ref, phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1]2023 w = 1.0/ref[6 ]2024 if w*ref[5 ] >= calcControls['minF/sig']:2025 wdf[iref] = w*(ref[5 ]-ref[7])2054 if ref[6+im] > 0: 2055 dervDict = SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1] 2056 w = 1.0/ref[6+im] 2057 if w*ref[5+im] >= calcControls['minF/sig']: 2058 wdf[iref] = w*(ref[5+im]-ref[7+im]) 2026 2059 for j,var in enumerate(varylist): 2027 2060 if var in dFdvDict: 2028 dMdvh[j][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11 ]2061 dMdvh[j][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11+im] 2029 2062 for var in dependentVars: 2030 2063 if var in dFdvDict: 2031 depDerivDict[var][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11 ]2064 depDerivDict[var][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11+im] 2032 2065 if phfx+'Scale' in varylist: 2033 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9 ]*ref[11]2066 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9+im]*ref[11+im] 2034 2067 elif phfx+'Scale' in dependentVars: 2035 depDerivDict[phfx+'Scale'][iref] = w*ref[9 ]*ref[11]2068 depDerivDict[phfx+'Scale'][iref] = w*ref[9+im]*ref[11+im] 2036 2069 for item in ['Ep','Es','Eg']: 2037 2070 if phfx+item in varylist and phfx+item in dervDict: 2038 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]/ref[11 ] #OK2071 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]/ref[11+im] #OK 2039 2072 elif phfx+item in dependentVars and phfx+item in dervDict: 2040 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]/ref[11 ] #OK2073 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]/ref[11+im] #OK 2041 2074 for item in ['BabA','BabU']: 2042 2075 if phfx+item in varylist: 2043 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11 ]2076 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11+im] 2044 2077 elif phfx+item in dependentVars: 2045 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11 ]2078 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11+im] 2046 2079 else: 2047 2080 for iref,ref in enumerate(refDict['RefList']): 2048 if ref[5 ] > 0.:2081 if ref[5+im] > 0.: 2049 2082 dervDict = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1] 2050 Fo = np.sqrt(ref[5 ])2051 Fc = np.sqrt(ref[7 ])2052 w = 1.0/ref[6 ]2083 Fo = np.sqrt(ref[5+im]) 2084 Fc = np.sqrt(ref[7+im]) 2085 w = 1.0/ref[6+im] 2053 2086 if 2.0*Fo*w*Fo >= calcControls['minF/sig']: 2054 2087 wdf[iref] = 2.0*Fo*w*(Fo-Fc) 2055 2088 for j,var in enumerate(varylist): 2056 2089 if var in dFdvDict: 2057 dMdvh[j][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11 ]2090 dMdvh[j][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11+im] 2058 2091 for var in dependentVars: 2059 2092 if var in dFdvDict: 2060 depDerivDict[var][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11 ]2093 depDerivDict[var][iref] = w*dFdvDict[var][iref]*parmDict[phfx+'Scale']*ref[11+im] 2061 2094 if phfx+'Scale' in varylist: 2062 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9 ]*ref[11]2095 dMdvh[varylist.index(phfx+'Scale')][iref] = w*ref[9+im]*ref[11+im] 2063 2096 elif phfx+'Scale' in dependentVars: 2064 depDerivDict[phfx+'Scale'][iref] = w*ref[9 ]*ref[11]2097 depDerivDict[phfx+'Scale'][iref] = w*ref[9+im]*ref[11+im] 2065 2098 for item in ['Ep','Es','Eg']: 2066 2099 if phfx+item in varylist and phfx+item in dervDict: 2067 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]/ref[11 ] #correct2100 dMdvh[varylist.index(phfx+item)][iref] = w*dervDict[phfx+item]/ref[11+im] #correct 2068 2101 elif phfx+item in dependentVars and phfx+item in dervDict: 2069 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]/ref[11 ]2102 depDerivDict[phfx+item][iref] = w*dervDict[phfx+item]/ref[11+im] 2070 2103 for item in ['BabA','BabU']: 2071 2104 if phfx+item in varylist: 2072 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11 ]2105 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11+im] 2073 2106 elif phfx+item in dependentVars: 2074 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11 ]2107 depDerivDict[phfx+item][iref] = w*dFdvDict[pfx+item][iref]*parmDict[phfx+'Scale']*ref[11+im] 2075 2108 return dMdvh,depDerivDict,wdf 2076 2109 … … 2269 2302 phfx = '%d:%d:'%(Phase['pId'],hId) 2270 2303 SGData = Phase['General']['SGData'] 2304 im = 0 2305 if Phase['General']['Type'] in ['modulated','magnetic']: 2306 SSGData = Phase['General']['SSGData'] 2307 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 2308 im = 1 #offset in SS reflection list 2309 #?? 2271 2310 A = [parmDict[pfx+'A%d'%(i)] for i in range(6)] 2272 2311 G,g = G2lat.A2Gmat(A) #recip & real metric tensors … … 2284 2323 if calcControls['F**2']: 2285 2324 for i,ref in enumerate(refDict['RefList']): 2286 if ref[6 ] > 0:2287 ref[11 ] = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist)[0]2288 w = 1.0/ref[6 ]2289 ref[7 ] = parmDict[phfx+'Scale']*ref[9]*ref[11] #correct Fc^2 for extinction2290 ref[8 ] = ref[5]/(parmDict[phfx+'Scale']*ref[11])2291 if w*ref[5 ] >= calcControls['minF/sig']:2292 Fo = np.sqrt(ref[5 ])2325 if ref[6+im] > 0: 2326 ref[11+im] = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist)[0] 2327 w = 1.0/ref[6+im] 2328 ref[7+im] = parmDict[phfx+'Scale']*ref[9+im]*ref[11+im] #correct Fc^2 for extinction 2329 ref[8+im] = ref[5+im]/(parmDict[phfx+'Scale']*ref[11+im]) 2330 if w*ref[5+im] >= calcControls['minF/sig']: 2331 Fo = np.sqrt(ref[5+im]) 2293 2332 sumFo += Fo 2294 sumFo2 += ref[5 ]2295 sumdF += abs(Fo-np.sqrt(ref[7 ]))2296 sumdF2 += abs(ref[5 ]-ref[7])2333 sumFo2 += ref[5+im] 2334 sumdF += abs(Fo-np.sqrt(ref[7+im])) 2335 sumdF2 += abs(ref[5+im]-ref[7+im]) 2297 2336 nobs += 1 2298 df[i] = -w*(ref[5 ]-ref[7])2299 sumwYo += (w*ref[5 ])**22337 df[i] = -w*(ref[5+im]-ref[7+im]) 2338 sumwYo += (w*ref[5+im])**2 2300 2339 else: 2301 2340 for i,ref in enumerate(refDict['RefList']): 2302 if ref[5 ] > 0.:2303 ref[11 ] = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist)[0]2304 ref[7 ] = parmDict[phfx+'Scale']*ref[9]*ref[11] #correct Fc^2 for extinction2305 ref[8 ] = ref[5]/(parmDict[phfx+'Scale']*ref[11])2306 Fo = np.sqrt(ref[5 ])2307 Fc = np.sqrt(ref[7 ])2308 w = 2.0*Fo/ref[6 ]2341 if ref[5+im] > 0.: 2342 ref[11+im] = SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varylist)[0] 2343 ref[7+im] = parmDict[phfx+'Scale']*ref[9+im]*ref[11+im] #correct Fc^2 for extinction 2344 ref[8+im] = ref[5+im]/(parmDict[phfx+'Scale']*ref[11+im]) 2345 Fo = np.sqrt(ref[5+im]) 2346 Fc = np.sqrt(ref[7+im]) 2347 w = 2.0*Fo/ref[6+im] 2309 2348 if w*Fo >= calcControls['minF/sig']: 2310 2349 sumFo += Fo 2311 sumFo2 += ref[5 ]2350 sumFo2 += ref[5+im] 2312 2351 sumdF += abs(Fo-Fc) 2313 sumdF2 += abs(ref[5 ]-ref[7])2352 sumdF2 += abs(ref[5+im]-ref[7+im]) 2314 2353 nobs += 1 2315 2354 df[i] = -w*(Fo-Fc)
Note: See TracChangeset
for help on using the changeset viewer.