Changeset 2710


Ignore:
Timestamp:
Feb 16, 2017 4:31:20 PM (5 years ago)
Author:
vondreele
Message:

improve ExportPDF with G2file selector & allow selection of I(Q), S(Q), F(Q) & G(R)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2703 r2710  
    35443544    def OnExportPDF(self,event):
    35453545        #need S(Q) and G(R) to be saved here - probably best from selection?
    3546         names = ['All']
     3546        names = G2pdG.GetFileList(self,'PDF')
    35473547        exports = []
    3548         item, cookie = self.PatternTree.GetFirstChild(self.root)
    3549         while item:
    3550             name = self.PatternTree.GetItemText(item)
    3551             if 'PDF' in name:
    3552                 names.append(name)
    3553             item, cookie = self.PatternTree.GetNextChild(self.root, cookie)
    35543548        if names:
    3555             dlg = wx.MultiChoiceDialog(self,'Select','PDF patterns to export',names)
     3549            od = {'label_1':'Export I(Q)','value_1':False,'label_2':'Export S(Q)','value_2':False,
     3550                  'label_3':'Export F(Q)','value_3':False,'label_4':'Export G(R)','value_4':True}
     3551            dlg = G2G.G2MultiChoiceDialog(self,'Select','PDF patterns to export',names,extraOpts=od)
    35563552            if dlg.ShowModal() == wx.ID_OK:
    35573553                sel = dlg.GetSelections()
    3558                 if sel[0] == 0:
    3559                     exports = names[1:]
    3560                 else:
    3561                     for x in sel:
    3562                         exports.append(names[x])
     3554                for x in sel:
     3555                    exports.append(names[x])
    35633556            dlg.Destroy()
    35643557        if exports:
    3565             G2IO.PDFSave(self,exports)
     3558            PDFsaves = [od['value_1'],od['value_2'],od['value_3'],od['value_4']]
     3559            G2IO.PDFSave(self,exports,PDFsaves)
    35663560       
    35673561    def OnMakePDFs(self,event):
  • trunk/GSASIIIO.py

    r2703 r2710  
    991991    print ' XY data saved to: ',filename
    992992           
    993 def PDFSave(G2frame,exports):
    994     'Save a PDF G(r) and F(Q), S(Q) in column formats'
     993def PDFSave(G2frame,exports,PDFsaves):
     994    'Save a PDF I(Q), S(Q), F(Q) and G(r) in column formats'
    995995    import scipy.interpolate as scintp
    996996    for export in exports:
    997997        PickId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, export)
    998998        PDFControls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame, PickId,'PDF Controls'))
    999         sqfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.sq')
    1000         fqfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.fq')
    1001         grfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.gr')
    1002         sqdata = PDFControls['S(Q)'][1]
    1003         sqfxn = scintp.interp1d(sqdata[0],sqdata[1],kind='linear')
    1004         fqdata = PDFControls['F(Q)'][1]
    1005         fqfxn = scintp.interp1d(fqdata[0],fqdata[1],kind='linear')
    1006         grdata = PDFControls['G(R)'][1]
    1007         grfxn = scintp.interp1d(grdata[0],grdata[1],kind='linear')
    1008         sqfile = open(sqfilename,'w')
    1009         fqfile = open(sqfilename,'w')
    1010         grfile = open(grfilename,'w')
    1011         sqfile.write('#T S(Q) %s\n'%(export))
    1012         fqfile.write('#T F(Q) %s\n'%(export))
    1013         grfile.write('#T G(R) %s\n'%(export))
    1014         sqfile.write('#L Q     S(Q)\n')
    1015         fqfile.write('#L Q     F(Q)\n')
    1016         grfile.write('#L R     G(R)\n')
    1017         qnew = np.arange(sqdata[0][0],sqdata[0][-1],0.005)
    1018         rnew = np.arange(grdata[0][0],grdata[0][-1],0.010)
    1019         sqnew = zip(qnew,sqfxn(qnew))
    1020         for q,sq in sqnew:
    1021             sqfile.write("%15.6g %15.6g\n" % (q,sq))
    1022         sqfile.close()
    1023         print ' S(Q) saved to: ',sqfilename
    1024         fqnew = zip(qnew,fqfxn(qnew))
    1025         for q,fq in fqnew:
    1026             fqfile.write("%15.6g %15.6g\n" % (q,fq))
    1027         fqfile.close()
    1028         print ' F(Q) saved to: ',fqfilename
    1029         grnew = zip(rnew,grfxn(rnew))
    1030         for r,gr in grnew:
    1031             grfile.write("%15.6g %15.6g\n" % (r,gr))
    1032         grfile.close()
    1033         print ' G)R) saved to: ',grfilename
     999        if PDFsaves[0]:     #I(Q)
     1000            iqfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.iq')
     1001            iqdata = PDFControls['I(Q)'][0]
     1002            iqfxn = scintp.interp1d(iqdata[0],iqdata[1],kind='linear')
     1003            iqfile = open(iqfilename,'w')
     1004            iqfile.write('#T I(Q) %s\n'%(export))
     1005            iqfile.write('#L Q     I(Q)\n')
     1006            qnew = np.arange(iqdata[0][0],iqdata[0][-1],0.005)
     1007            iqnew = zip(qnew,iqfxn(qnew))
     1008            for q,iq in iqnew:
     1009                iqfile.write("%15.6g %15.6g\n" % (q,iq))
     1010            iqfile.close()
     1011            print ' I(Q) saved to: ',iqfilename
     1012           
     1013        if PDFsaves[1]:     #S(Q)
     1014            sqfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.sq')
     1015            sqdata = PDFControls['S(Q)'][1]
     1016            sqfxn = scintp.interp1d(sqdata[0],sqdata[1],kind='linear')
     1017            sqfile = open(sqfilename,'w')
     1018            sqfile.write('#T S(Q) %s\n'%(export))
     1019            sqfile.write('#L Q     S(Q)\n')
     1020            qnew = np.arange(sqdata[0][0],sqdata[0][-1],0.005)
     1021            sqnew = zip(qnew,sqfxn(qnew))
     1022            for q,sq in sqnew:
     1023                sqfile.write("%15.6g %15.6g\n" % (q,sq))
     1024            sqfile.close()
     1025            print ' S(Q) saved to: ',sqfilename
     1026           
     1027           
     1028        if PDFsaves[2]:     #F(Q)
     1029            fqfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.fq')
     1030            fqdata = PDFControls['F(Q)'][1]
     1031            fqfxn = scintp.interp1d(fqdata[0],fqdata[1],kind='linear')
     1032            fqfile = open(sqfilename,'w')
     1033            fqfile.write('#T F(Q) %s\n'%(export))
     1034            fqfile.write('#L Q     F(Q)\n')
     1035            qnew = np.arange(sqdata[0][0],sqdata[0][-1],0.005)
     1036            fqnew = zip(qnew,fqfxn(qnew))
     1037            for q,fq in fqnew:
     1038                fqfile.write("%15.6g %15.6g\n" % (q,fq))
     1039            fqfile.close()
     1040            print ' F(Q) saved to: ',fqfilename
     1041           
     1042
     1043        if PDFsaves[3]:     #G(R)
     1044            grfilename = ospath.join(G2frame.dirname,export.replace(' ','_')[5:]+'.gr')
     1045            grdata = PDFControls['G(R)'][1]
     1046            grfxn = scintp.interp1d(grdata[0],grdata[1],kind='linear')
     1047            grfile = open(grfilename,'w')
     1048            grfile.write('#T G(R) %s\n'%(export))
     1049            grfile.write('#L R     G(R)\n')
     1050            rnew = np.arange(grdata[0][0],grdata[0][-1],0.010)
     1051            grnew = zip(rnew,grfxn(rnew))
     1052            for r,gr in grnew:
     1053                grfile.write("%15.6g %15.6g\n" % (r,gr))
     1054            grfile.close()
     1055            print ' G)R) saved to: ',grfilename
    10341056   
    10351057def PeakListSave(G2frame,file,peaks):
  • trunk/GSASIIpwdGUI.py

    r2708 r2710  
    941941            return
    942942        copyList = []
    943         dlg = G2G.G2MultiChoiceDialog(
    944             G2frame.dataFrame,
    945             'Copy bkg params from\n'+str(hst[5:])+' to...',
     943        dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame,'Copy bkg params from\n'+str(hst[5:])+' to...',
    946944            'Copy parameters', histList)
    947945        try:
Note: See TracChangeset for help on using the changeset viewer.