Changeset 2777 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Apr 12, 2017 3:12:45 PM (5 years ago)
Author:
vondreele
Message:

implement import of getPDFx G(R) files NB: these have no matching PWDR entries
replace all scipy.fft with numpy.fft
add a plot SLD button for reflectometry
for PDF Peaks - Atom elements from periodic table - Bond No. still not working so doesn't really matter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r2776 r2777  
    2424import numpy.ma as ma
    2525import random as rand
    26 from numpy.fft import ifft, fft, fftshift
     26import numpy.fft as fft
    2727import scipy.interpolate as si
    2828import scipy.stats as st
     
    289289    '''
    290290    auxPlot = []
    291     import scipy.fftpack as ft
    292291    Ibeg = np.searchsorted(xydata['Sample'][1][0],limits[0])
    293292    Ifin = np.searchsorted(xydata['Sample'][1][0],limits[1])+1
     
    371370    mul = int(round(2.*np.pi*nR/(data.get('Rmax',100.)*qLimits[1])))
    372371    xydata['GofR'][1][0] = 2.*np.pi*np.linspace(0,nR,nR,endpoint=True)/(mul*qLimits[1])
    373     xydata['GofR'][1][1] = -dq*np.imag(ft.fft(xydata['FofQ'][1][1],mul*nR)[:nR])
     372    xydata['GofR'][1][1] = -dq*np.imag(fft.fft(xydata['FofQ'][1][1],mul*nR)[:nR])
    374373    if data.get('noRing',True):
    375374        xydata['GofR'][1][1] = np.where(xydata['GofR'][1][0]<0.5,0.,xydata['GofR'][1][1])
     
    452451   
    453452def MakeRDF(RDFcontrols,background,inst,pwddata):
    454     import scipy.fftpack as ft
    455453    import scipy.signal as signal
    456454    auxPlot = []
     
    484482#    auxPlot.append([Qpoints,Qdata,'interpolate:'+RDFcontrols['Smooth']])
    485483#    auxPlot.append([Qpoints,Qsmooth,'interpolate:'+RDFcontrols['Smooth']])
    486     DofR = dq*np.imag(ft.fft(Qsmooth,16*nR)[:nR])
     484    DofR = dq*np.imag(fft.fft(Qsmooth,16*nR)[:nR])
     485#    DofR = dq*np.imag(ft.fft(Qsmooth,16*nR)[:nR])
    487486    auxPlot.append([R[:iFin],DofR[:iFin],'D(R)'])   
    488487    return auxPlot
     
    692691    if len(np.nonzero(FCJ)[0])>5:
    693692        z = np.column_stack([Norm,Cauchy,FCJ]).T
    694         Z = fft(z)
    695         Df = ifft(Z.prod(axis=0)).real
     693        Z = fft.fft(z)
     694        Df = fft.ifft(Z.prod(axis=0)).real
    696695    else:
    697696        z = np.column_stack([Norm,Cauchy]).T
    698         Z = fft(z)
    699         Df = fftshift(ifft(Z.prod(axis=0))).real
     697        Z = fft.fft(z)
     698        Df = fft.fftshift(fft.ifft(Z.prod(axis=0))).real
    700699    Df /= np.sum(Df)
    701700    Df = si.interp1d(x,Df,bounds_error=False,fill_value=0.0)
     
    20272026                rho[ilay] += parmDict[cid+'Mag SLD']
    20282027        A,B = abeles(0.5*Q,depth,rho,irho,sigma[1:])     #Q --> k, offset roughness for abeles
    2029         Ic += (A**2+B**2)*Scale     
     2028        Ic += (A**2+B**2)*Scale
     2029        #TODO: smear Ic by instrument resolution Qsig
    20302030        return Ic
    20312031       
     
    20522052        return 1.5*(MMax-Mmin)
    20532053
    2054     Q,Io,wt,Ic,Ib,Ifb = Profile[:6]
     2054    Q,Io,wt,Ic,Ib,Qsig = Profile[:6]
    20552055    if data.get('2% weight'):
    20562056        wt = 1./(0.02*Io)**2
     
    21902190def REFDModelFxn(Profile,Inst,Limits,Substances,data):
    21912191   
    2192     Q,Io,wt,Ic,Ib,Ifb = Profile[:6]
     2192    Q,Io,wt,Ic,Ib,Qsig = Profile[:6]
    21932193    Qmin = Limits[1][0]
    21942194    Qmax = Limits[1][1]
     
    23072307
    23082308    return calc(kz, depth, rho, irho, sigma)
     2309   
     2310def makeRefdFFT(Limits,Profile):
     2311    print 'make fft'
     2312    Q,Io = Profile[:2]
     2313    Qmin = Limits[1][0]
     2314    Qmax = Limits[1][1]
     2315    iBeg = np.searchsorted(Q,Qmin)
     2316    iFin = np.searchsorted(Q,Qmax)+1    #include last point
     2317    Qf = np.linspace(0.,Q[iFin-1],5000)
     2318    QI = si.interp1d(Q[iBeg:iFin],Io[iBeg:iFin],bounds_error=False,fill_value=0.0)
     2319    If = QI(Qf)*Qf**4
     2320    R = np.linspace(0.,5000.,5000)
     2321    F = fft.rfft(If)
     2322    return R,F
     2323
    23092324   
    23102325################################################################################
Note: See TracChangeset for help on using the changeset viewer.