Changeset 2361 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Jul 3, 2016 3:59:57 PM (5 years ago)
Author:
vondreele
Message:

fix Debye scattering background fxns. & derivatives.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r2357 r2361  
    4545   
    4646# trig functions in degrees
    47 sind = lambda x: math.sin(x*math.pi/180.)
    48 asind = lambda x: 180.*math.asin(x)/math.pi
    4947tand = lambda x: math.tan(x*math.pi/180.)
    5048atand = lambda x: 180.*math.atan(x)/math.pi
     
    6159npatand = lambda x: 180.*np.arctan(x)/np.pi
    6260npatan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi
    63 npT2stl = lambda tth, wave: 2.0*npsind(tth/2.0)/wave
    64 npT2q = lambda tth,wave: 2.0*np.pi*npT2stl(tth,wave)
     61npT2stl = lambda tth, wave: 2.0*npsind(tth/2.0)/wave    #=d*
     62npT2q = lambda tth,wave: 2.0*np.pi*npT2stl(tth,wave)    #=2pi*d*
    6563ateln2 = 8.0*math.log(2.0)
    6664   
     
    346344def MakeRDF(RDFcontrols,background,inst,pwddata):
    347345    import scipy.fftpack as ft
     346    import scipy.signal as signal
    348347    auxPlot = []
    349348    if 'C' in inst['Type'][0]:
     
    364363        Qdata = si.griddata(powQ,pwddata[1]-pwddata[3],Qpoints,method=RDFcontrols['Smooth'],fill_value=0.)
    365364    else:
    366         Qdata = si.griddata(powQ,pwddata[1],Qpoints,method=RDFcontrols['Smooth'],fill_value=pwddata[1][0])
     365        Qdata = si.griddata(powQ,pwddata[1]-pwddata[4],Qpoints,method=RDFcontrols['Smooth'],fill_value=pwddata[1][0])
    367366    Qdata *= np.sin((Qpoints-minQ)*piDQ)/piDQ
    368367    Qdata *= 0.5*np.sqrt(Qpoints)       #Qbin normalization
    369     auxPlot.append([Qpoints,Qdata,'interp1d:'+RDFcontrols['Smooth']])
    370368#    GSASIIpath.IPyBreak()
    371369    dq = Qpoints[1]-Qpoints[0]
    372370    nR = len(Qdata)
    373     DofR = -dq*np.imag(ft.fft(Qdata,16*nR)[:nR])
    374371    R = 0.5*np.pi*np.linspace(0,nR,nR)/(4.*maxQ)
    375372    iFin = np.searchsorted(R,RDFcontrols['maxR'])
     373    bBut,aBut = signal.butter(4,0.01)
     374    Qsmooth = signal.filtfilt(bBut,aBut,Qdata)
     375#    auxPlot.append([Qpoints,Qdata,'interpolate:'+RDFcontrols['Smooth']])
     376#    auxPlot.append([Qpoints,Qsmooth,'interpolate:'+RDFcontrols['Smooth']])
     377    DofR = dq*np.imag(ft.fft(Qsmooth,16*nR)[:nR])
    376378    auxPlot.append([R[:iFin],DofR[:iFin],'D(R)'])   
    377379    return auxPlot
     
    598600    elif 'C' in dataType:
    599601        wave = parmDict.get(pfx+'Lam',parmDict.get(pfx+'Lam1',1.0))
    600         q = 2.*np.pi*npsind(xdata/2.)/wave
     602        q = npT2q(xdata,wave)
    601603    yb = np.zeros_like(xdata)
    602604    nBak = 0
     
    779781        ff = 1.
    780782    else:
    781         try:
    782             wave = parmDict[hfx+'Lam']
    783         except KeyError:
    784             wave = parmDict[hfx+'Lam1']
    785         q = 4.0*np.pi*npsind(xdata/2.0)/wave
     783        wave = parmDict.get(hfx+'Lam',parmDict.get(hfx+'Lam1',1.0))
     784        q = npT2q(xdata,wave)
    786785        SQ = (q/(4*np.pi))**2
    787786        FF = G2elem.GetFormFactorCoeff('Si')[0]
    788         ff = np.array(G2elem.ScatFac(FF,SQ)[0])
     787        ff = np.array(G2elem.ScatFac(FF,SQ)[0])*np.pi**2    #needs pi^2~10. for cw data (why?)
    789788    iD = 0       
    790789    while True:
     
    798797            cqr = np.cos(q*dbR)
    799798            temp = np.exp(-dbU*q**2)
    800             dyddb[3*iD] = ff*sqr*temp/(np.pi*cw)
    801             dyddb[3*iD+1] = ff*dbA*temp*(cqr-sqr)/(np.pi*dbR*cw)
    802             dyddb[3*iD+2] = -ff*dbA*sqr*temp*q**2/(np.pi*cw)
    803             iD += 1       #ff*dbA*np.sin(q*dbR)*np.exp(-dbU*q**2)/(q*dbR)
     799            dyddb[3*iD] = ff*sqr*temp
     800            dyddb[3*iD+1] = ff*dbA*temp*(cqr-sqr)/(dbR)
     801            dyddb[3*iD+2] = -ff*dbA*sqr*temp*q**2
     802            iD += 1
    804803        except KeyError:
    805804            break
Note: See TracChangeset for help on using the changeset viewer.