Changeset 2561 for trunk/GSASIIIO.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/GSASIIIO.py

    r2555 r2561  
    968968def PDFSave(G2frame,exports):
    969969    'Save a PDF G(r) and F(Q), S(Q) in column formats'
     970    import scipy.interpolate as scintp
    970971    for export in exports:
    971972        PickId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, export)
     
    979980        fqId = G2gd.GetPatternTreeItemId(G2frame, PickId, FQname)
    980981        grId = G2gd.GetPatternTreeItemId(G2frame, PickId, GRname)
    981         sqdata = np.array(G2frame.PatternTree.GetItemPyData(sqId)[1][:2]).T
    982         fqdata = np.array(G2frame.PatternTree.GetItemPyData(fqId)[1][:2]).T
    983         grdata = np.array(G2frame.PatternTree.GetItemPyData(grId)[1][:2]).T
     982        sqdata = np.array(G2frame.PatternTree.GetItemPyData(sqId)[1][:2])
     983        sqfxn = scintp.interp1d(sqdata[0],sqdata[1],kind='linear')
     984        fqdata = np.array(G2frame.PatternTree.GetItemPyData(fqId)[1][:2])
     985        fqfxn = scintp.interp1d(fqdata[0],fqdata[1],kind='linear')
     986        grdata = np.array(G2frame.PatternTree.GetItemPyData(grId)[1][:2])
     987        grfxn = scintp.interp1d(grdata[0],grdata[1],kind='linear')
    984988        sqfile = open(sqfilename,'w')
    985989        fqfile = open(sqfilename,'w')
     
    989993        grfile.write('#T G(R) %s\n'%(export))
    990994        sqfile.write('#L Q     S(Q)\n')
    991         sqfile.write('#L Q     F(Q)\n')
     995        fqfile.write('#L Q     F(Q)\n')
    992996        grfile.write('#L R     G(R)\n')
    993         for q,sq in sqdata:
     997        qnew = np.arange(sqdata[0][0],sqdata[0][-1],0.005)
     998        rnew = np.arange(grdata[0][0],grdata[0][-1],0.010)
     999        sqnew = zip(qnew,sqfxn(qnew))
     1000        for q,sq in sqnew:
    9941001            sqfile.write("%15.6g %15.6g\n" % (q,sq))
    9951002        sqfile.close()
    9961003        print ' S(Q) saved to: ',sqfilename
    997         for q,fq in fqdata:
     1004        fqnew = zip(qnew,fqfxn(qnew))
     1005        for q,fq in fqnew:
    9981006            fqfile.write("%15.6g %15.6g\n" % (q,fq))
    9991007        fqfile.close()
    10001008        print ' F(Q) saved to: ',fqfilename
    1001         for r,gr in grdata:
     1009        grnew = zip(rnew,grfxn(rnew))
     1010        for r,gr in grnew:
    10021011            grfile.write("%15.6g %15.6g\n" % (r,gr))
    10031012        grfile.close()
Note: See TracChangeset for help on using the changeset viewer.