Changeset 2118


Ignore:
Timestamp:
Jan 9, 2016 9:36:05 PM (6 years ago)
Author:
vondreele
Message:

Fix plotting error with mixed powder data types
Add refinement of modulation vector for TOF

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2116 r2118  
    29932993    G2frame.PatternTree.SetItemPyData(item,data)
    29942994    if kind in ['PWDR','SASD']:
    2995         if 'xylim' in dir(G2frame):
    2996             NewPlot = False
    2997         else:
    2998 
    2999             NewPlot = True
     2995        NewPlot = True
     2996#        if 'xylim' in dir(G2frame):
     2997#            NewPlot = False
     2998#
    30002999        G2plt.PlotPatterns(G2frame,plotType=kind,newPlot=NewPlot)
    30013000    elif kind == 'HKLF':
  • trunk/GSASIIindex.py

    r2117 r2118  
    631631    chisq = np.sum(errFitT(result[0],ibrav,Peaks[7],Peaks[4:7],Peaks[0],difC,Z,Zref)**2)
    632632    return True,chisq,A,Z,result
     633   
     634def errFitTSS(values,ibrav,d,H,tof,difC,vec,Vref,Z,Zref):
     635    Zero = Z
     636    if Zref:   
     637        Zero = values[-1]
     638    A = Values2A(ibrav,values)
     639    Vec = Values2Vec(ibrav,vec,Vref,values)
     640    Qo = 1./d**2
     641    Qc = G2lat.calc_rDsqTSS(H,A,Vec,Zero,tof,difC)
     642    return (Qo-Qc)
     643   
     644def dervFitTSS(values,ibrav,d,H,tof,difC,vec,Vref,Z,Zref):
     645    A = Values2A(ibrav,values)
     646    Vec = Values2Vec(ibrav,vec,Vref,values)
     647    HM = H[:3]+(H[3][:,np.newaxis]*Vec).T
     648    if ibrav in [3,4,]:
     649        derv = [HM[0]*HM[0]+HM[1]*HM[1]+HM[0]*HM[1],HM[2]*HM[2]]
     650    elif ibrav in [5,6]:
     651        derv = [HM[0]*HM[0]+HM[1]*HM[1],HM[2]*HM[2]]
     652    elif ibrav in [7,8,9,10]:
     653        derv = [HM[0]*HM[0],HM[1]*HM[1],HM[2]*HM[2]]
     654    elif ibrav in [11,12]:
     655        derv = [HM[0]*HM[0],HM[1]*HM[1],HM[2]*HM[2],HM[0]*HM[2]]
     656    else:
     657        derv = [HM[0]*HM[0],HM[1]*HM[1],HM[2]*HM[2],HM[0]*HM[1],HM[0]*HM[2],HM[1]*HM[2]]
     658    if Vref[0]:
     659        derv.append(2.*A[0]*HM[0]*H[3]+A[3]*HM[1]*H[3]+A[4]*HM[2]*H[3])
     660    if Vref[1]:
     661        derv.append(2.*A[1]*HM[1]*H[3]+A[3]*HM[0]*H[3]+A[5]*HM[2]*H[3])
     662    if Vref[2]:
     663        derv.append(2.*A[2]*HM[2]*H[3]+A[4]*HM[1]*H[3]+A[5]*HM[0]*H[3])   
     664    if Zref:
     665        derv.append(np.ones_like(d)/difC)
     666    derv = -np.array(derv)
     667    return derv.T
     668   
     669def FitHKLTSS(difC,ibrav,peaks,A,V,Vref,Z,Zref):
     670    'needs a doc string'
     671   
     672    Peaks = np.array(peaks).T   
     673    values = A2values(ibrav,A)
     674    for v,r in zip(V,Vref):
     675        if r:
     676            values.append(v)
     677    if Zref:
     678        values.append(Z)
     679    result = so.leastsq(errFitTSS,values,Dfun=dervFitTSS,full_output=True,ftol=0.0001,
     680        args=(ibrav,Peaks[8],Peaks[4:8],Peaks[0],difC,V,Vref,Z,Zref))
     681    A = Values2A(ibrav,result[0])
     682    Vec = Values2Vec(ibrav,V,Vref,result[0])
     683    if Zref:
     684        Z = result[0][-1]
     685    chisq = np.sum(errFitTSS(result[0],ibrav,Peaks[8],Peaks[4:8],Peaks[0],difC,V,Vref,Z,Zref)**2)
     686    return True,chisq,A,Vec,Z,result
    633687               
    634688def rotOrthoA(A):
     
    690744    return len(HKL),M20,X20,Aref,Z
    691745   
     746def refinePeaksT(peaks,difC,ibrav,A,Zero,ZeroRef):
     747    'needs a doc string'
     748    dmin = getDmin(peaks)
     749    OK,smin,Aref,Z,result = FitHKLT(difC,ibrav,peaks,A,Zero,ZeroRef)
     750    Peaks = np.array(peaks).T
     751    H = Peaks[4:7]
     752    Peaks[8] = 1./np.sqrt(G2lat.calc_rDsqT(H,Aref,Z,Peaks[0],difC))
     753    peaks = Peaks.T   
     754    HKL = G2lat.GenHBravais(dmin,ibrav,A)
     755    M20,X20 = calc_M20(peaks,HKL)
     756    return len(HKL),M20,X20,Aref,Z
     757   
    692758def refinePeaksZSS(peaks,wave,Inst,SGData,SSGData,maxH,ibrav,A,vec,vecRef,Zero,ZeroRef):
    693759    'needs a doc string'
     
    702768    return len(HKL),M20,X20,Aref,Vref,Z
    703769   
    704 def refinePeaksT(peaks,difC,ibrav,A,Zero,ZeroRef):
     770def refinePeaksTSS(peaks,difC,Inst,SGData,SSGData,maxH,ibrav,A,vec,vecRef,Zero,ZeroRef):
    705771    'needs a doc string'
    706772    dmin = getDmin(peaks)
    707     OK,smin,Aref,Z,result = FitHKLT(difC,ibrav,peaks,A,Zero,ZeroRef)
     773    OK,smin,Aref,Vref,Z,result = FitHKLTSS(difC,ibrav,peaks,A,vec,vecRef,Zero,ZeroRef)
    708774    Peaks = np.array(peaks).T
    709     H = Peaks[4:7]
    710     Peaks[8] = 1./np.sqrt(G2lat.calc_rDsqT(H,Aref,Z,Peaks[0],difC))
     775    H = Peaks[4:8]
     776    Peaks[9] = 1./np.sqrt(G2lat.calc_rDsqTSS(H,Aref,Vref,Z,Peaks[0],difC))
    711777    peaks = Peaks.T   
     778    HKL =  G2pwd.getHKLMpeak(dmin,Inst,SGData,SSGData,Vref,maxH,Aref)
    712779    HKL = G2lat.GenHBravais(dmin,ibrav,A)
    713     M20,X20 = calc_M20(peaks,HKL)
    714     return len(HKL),M20,X20,Aref,Z
     780    M20,X20 = calc_M20SS(peaks,HKL)
     781    return len(HKL),M20,X20,Aref,Vref,Z
    715782   
    716783def refinePeaks(peaks,ibrav,A,ifX20=True):
  • trunk/GSASIIpwdGUI.py

    r2117 r2118  
    27072707                Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksZ(peaks[0],wave,ibrav,A,controls[1],controls[0])
    27082708        else:   #'T'OF - doesn't seem to work
    2709             G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A,Inst)
    2710             peaks = [G2indx.IndexPeaks(peaks[0],G2frame.HKL)[1],peaks[1]]   #put peak fit esds back in peaks
    2711             Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksT(peaks[0],difC,ibrav,A,controls[1],controls[0])           
     2709            if ssopt.get('Use',False):
     2710                vecFlags = [True if x in ssopt['ssSymb'] else False for x in ['a','b','g']]
     2711                SSGData = G2spc.SSpcGroup(SGData,ssopt['ssSymb'])[1]
     2712                G2frame.HKL = G2pwd.getHKLMpeak(dmin,Inst,SGData,SSGData,ssopt['ModVec'],ssopt['maxH'],A)
     2713                peaks = [G2indx.IndexSSPeaks(peaks[0],G2frame.HKL)[1],peaks[1]]   #put peak fit esds back in peaks
     2714                Lhkl,M20,X20,Aref,Vec,Zero = \
     2715                    G2indx.refinePeaksTSS(peaks[0],difC,Inst,SGData,SSGData,ssopt['maxH'],ibrav,A,ssopt['ModVec'],vecFlags,controls[1],controls[0])
     2716            else:
     2717                G2frame.HKL = G2pwd.getHKLpeak(dmin,SGData,A,Inst)
     2718                peaks = [G2indx.IndexPeaks(peaks[0],G2frame.HKL)[1],peaks[1]]   #put peak fit esds back in peaks
     2719                Lhkl,M20,X20,Aref,Zero = G2indx.refinePeaksT(peaks[0],difC,ibrav,A,controls[1],controls[0])           
    27122720        G2frame.HKL = np.array(G2frame.HKL)
    27132721        controls[1] = Zero
Note: See TracChangeset for help on using the changeset viewer.