Changeset 3348 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
Apr 17, 2018 5:00:36 PM (4 years ago)
Author:
vondreele
Message:

add new configuration for selecting instprm first
add save.load for PWDR peak fits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r3338 r3348  
    501501            G2frame.GPXtree.SetItemPyData(
    502502                G2gd.GetGPXtreeItemId(G2frame,Id,'Peak List'),copy.deepcopy(data))
     503           
     504    def OnLoadPeaks(event):
     505        pth = G2G.GetExportPath(G2frame)
     506        dlg = wx.FileDialog(G2frame, 'Choose GSAS-II PWDR peaks list file', pth, '',
     507            'PWDR peak list files (*.pkslst)|*.pkslst',wx.FD_OPEN)
     508        try:
     509            if dlg.ShowModal() == wx.ID_OK:
     510                peaks = []
     511                filename = dlg.GetPath()
     512                File = open(filename,'r')
     513                S = File.readline()
     514                while S:
     515                    if '#' in S:
     516                        S = File.readline()
     517                        continue
     518                    try:
     519                        peaks.append(eval(S))
     520                    except:
     521                        break
     522                    S = File.readline()
     523                File.close()
     524        finally:
     525            dlg.Destroy()
     526        data = {'peaks':peaks,'sigDict':{}}
     527        UpdatePeakGrid(G2frame,data)
     528        G2plt.PlotPatterns(G2frame,plotType='PWDR')
     529       
     530    def OnSavePeaks(event):
     531        pth = G2G.GetExportPath(G2frame)
     532        dlg = wx.FileDialog(G2frame, 'Choose GSAS-II PWDR peaks list file', pth, '',
     533            'PWDR peak list files (*.pkslst)|*.pkslst',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
     534        try:
     535            if dlg.ShowModal() == wx.ID_OK:
     536                filename = dlg.GetPath()
     537                # make sure extension is .pkslst
     538                filename = os.path.splitext(filename)[0]+'.pkslst'
     539                File = open(filename,'w')
     540                File.write("#GSAS-II PWDR peaks list file; do not add/delete items!\n")
     541                for item in data:
     542                    if item == 'peaks':
     543                        for pk in data[item]:
     544                            File.write(str(pk)+'\n')
     545                File.close()
     546                print ('PWDR peaks list saved to: '+filename)
     547        finally:
     548            dlg.Destroy()
     549       
    503550   
    504551    def OnUnDo(event):
     
    826873    G2frame.Bind(wx.EVT_MENU, OnAutoSearch, id=G2G.wxID_AUTOSEARCH)
    827874    G2frame.Bind(wx.EVT_MENU, OnCopyPeaks, id=G2G.wxID_PEAKSCOPY)
     875    G2frame.Bind(wx.EVT_MENU, OnSavePeaks, id=G2G.wxID_PEAKSAVE)
     876    G2frame.Bind(wx.EVT_MENU, OnLoadPeaks, id=G2G.wxID_PEAKLOAD)
    828877    G2frame.Bind(wx.EVT_MENU, OnUnDo, id=G2G.wxID_UNDO)
    829878    G2frame.Bind(wx.EVT_MENU, OnRefineSelected, id=G2frame.dataWindow.peaksSel.GetId())
Note: See TracChangeset for help on using the changeset viewer.