Changeset 2561 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Dec 6, 2016 10:43:26 AM (5 years ago)
Author:
vondreele
Message:

add Rmax to PDF Controls; default = 100.; will not be exact
PDF always generates 5000 points for 0-Rmax; independent of chosen Qmax or image binning.
Trap attempt to calculate PDF without chemical formula - now get error message.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r2546 r2561  
    288288    #subtract backgrounds - if any & use PWDR limits
    289289#    GSASIIpath.IPyBreak()
    290     xydata['IofQ'] = copy.deepcopy(xydata['Sample'])
    291     xydata['IofQ'][1] = np.array(xydata['IofQ'][1])[:,Ibeg:Ifin]
     290    IofQ = copy.deepcopy(xydata['Sample'])
     291    IofQ[1] = np.array(IofQ[1])[:,Ibeg:Ifin]
    292292    if data['Sample Bkg.']['Name']:
    293         xydata['IofQ'][1][1] += (xydata['Sample Bkg.'][1][1][Ibeg:Ifin]+
     293        IofQ[1][1] += (xydata['Sample Bkg.'][1][1][Ibeg:Ifin]+
    294294            data['Sample Bkg.']['Add'])*data['Sample Bkg.']['Mult']
    295295    if data['Container']['Name']:
     
    298298            xycontainer += (xydata['Container Bkg.'][1][1][Ibeg:Ifin]+
    299299                data['Container Bkg.']['Add'])*data['Container Bkg.']['Mult']
    300         xydata['IofQ'][1][1] += xycontainer[Ibeg:Ifin]
     300        IofQ[1][1] += xycontainer[Ibeg:Ifin]
    301301    #get element data & absorption coeff.
    302302    ElList = data['ElList']
    303303    Abs = G2lat.CellAbsorption(ElList,data['Form Vol'])
    304304    #Apply angle dependent corrections
    305     Tth = xydata['IofQ'][1][0]
     305    Tth = IofQ[1][0]
    306306    MuR = Abs*data['Diam']/20.0
    307     xydata['IofQ'][1][1] /= Absorb(data['Geometry'],MuR,Tth)
     307    IofQ[1][1] /= Absorb(data['Geometry'],MuR,Tth)
    308308    if 'X' in inst['Type'][0]:
    309         xydata['IofQ'][1][1] /= Polarization(inst['Polariz.'][1],Tth,Azm=inst['Azimuth'][1])[0]
     309        IofQ[1][1] /= Polarization(inst['Polariz.'][1],Tth,Azm=inst['Azimuth'][1])[0]
    310310    if data['DetType'] == 'Image plate':
    311         xydata['IofQ'][1][1] *= Oblique(data['ObliqCoeff'],Tth)
    312     XY = xydata['IofQ'][1]   
     311        IofQ[1][1] *= Oblique(data['ObliqCoeff'],Tth)
     312    XY = IofQ[1]   
    313313    #convert to Q
     314#    nQpoints = len(XY[0])     #points for Q interpolation
     315    nQpoints = 5000
    314316    if 'C' in inst['Type'][0]:
    315317        wave = G2mth.getWave(inst)
    316318        minQ = npT2q(Tth[0],wave)
    317319        maxQ = npT2q(Tth[-1],wave)   
    318         Qpoints = np.linspace(0.,maxQ,len(XY[0]),endpoint=True)
     320        Qpoints = np.linspace(0.,maxQ,nQpoints,endpoint=True)
    319321        dq = Qpoints[1]-Qpoints[0]
    320322        XY[0] = npT2q(XY[0],wave)
     
    323325        minQ = 2.*np.pi*difC/Tth[-1]
    324326        maxQ = 2.*np.pi*difC/Tth[0]
    325         Qpoints = np.linspace(0.,maxQ,len(XY[0]),endpoint=True)
     327        Qpoints = np.linspace(0.,maxQ,nQpoints,endpoint=True)
    326328        dq = Qpoints[1]-Qpoints[0]
    327329        XY[0] = 2.*np.pi*difC/XY[0]
    328     Qdata = si.griddata(XY[0],XY[1],Qpoints,method='linear',fill_value=XY[1][0])
     330    Qdata = si.griddata(XY[0],XY[1],Qpoints,method='linear',fill_value=XY[1][0])    #interpolate I(Q)
    329331    Qdata -= np.min(Qdata)*data['BackRatio']
    330332   
     
    333335    maxQ = np.searchsorted(Qpoints,qLimits[1])
    334336    newdata = []
    335     xydata['IofQ'][1][0] = Qpoints
    336     xydata['IofQ'][1][1] = Qdata
     337    xydata['IofQ'] = [IofQ[0],[Qpoints,Qdata],IofQ[2]]
    337338    for item in xydata['IofQ'][1]:
    338339        newdata.append(item[:maxQ])
     
    359360    xydata['GofR'] = copy.deepcopy(xydata['FofQ'])
    360361    nR = len(xydata['GofR'][1][1])
    361     xydata['GofR'][1][1] = -dq*np.imag(ft.fft(xydata['FofQ'][1][1],8*nR)[:nR])
    362     xydata['GofR'][1][0] = 0.25*np.pi*np.linspace(0,nR,nR)/qLimits[1]
     362#    mul = 12
     363    mul = int(round(2.*np.pi*nR/(data['Rmax']*qLimits[1])))
     364    xydata['GofR'][1][0] = 2.*np.pi*np.linspace(0,nR,nR)/(mul*qLimits[1])
     365    xydata['GofR'][1][1] = -dq*np.imag(ft.fft(xydata['FofQ'][1][1],mul*nR)[:nR])
    363366    if data.get('noRing',True):
    364367        xydata['GofR'][1][1] = np.where(xydata['GofR'][1][0]<0.5,0.,xydata['GofR'][1][1])
Note: See TracChangeset for help on using the changeset viewer.