Changeset 3348


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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3346 r3348  
    14971497            pth = G2G.GetImportPath(self)
    14981498            if not pth: pth = '.'
     1499            extOrd = [0,1]
     1500            if GSASIIpath.GetConfigValue('Instprm_default',False):
     1501                extOrd = [1,0]
     1502            extList = ['GSAS iparm file (*.prm,*.inst,*.ins)|*.prm;*.inst;*.ins|','GSAS-II iparm file (*.instprm)|*.instprm|']
    14991503            dlg = wx.FileDialog(self,
    15001504                u'Choose inst. param file for "'+rd.idstring+u'" (or Cancel for default)',
    1501                 pth, '',
    1502                 'GSAS iparm file (*.prm,*.inst,*.ins)|*.prm;*.inst;*.ins|'
    1503                 'GSAS-II iparm file (*.instprm)|*.instprm|'
    1504                 'All files (*.*)|*.*', wx.FD_OPEN)
     1505                pth, '',extList[extOrd[0]]+extList[extOrd[1]]+'All files (*.*)|*.*', wx.FD_OPEN)
    15051506            if os.path.exists(lastIparmfile):
    15061507                dlg.SetFilename(lastIparmfile)
     
    49204921        # PDR / Peak List
    49214922        G2G.Define_wxId('wxID_UNDO', 'wxID_LSQPEAKFIT', 'wxID_LSQONECYCLE', 'wxID_RESETSIGGAM',
    4922             'wxID_CLEARPEAKS', 'wxID_AUTOSEARCH','wxID_PEAKSCOPY', 'wxID_SEQPEAKFIT',)
     4923            'wxID_CLEARPEAKS', 'wxID_AUTOSEARCH','wxID_PEAKSCOPY', 'wxID_SEQPEAKFIT','wxID_PEAKLOAD','wxID_PEAKSAVE')
    49234924        self.PeakMenu = wx.MenuBar()
    49244925        self.PrefillDataMenu(self.PeakMenu)
     
    49334934        self.PeakEdit.Append(G2G.wxID_RESETSIGGAM,'Reset sig and gam','Reset sigma and gamma to global fit' )
    49344935        self.PeakCopy = self.PeakEdit.Append(G2G.wxID_PEAKSCOPY,'Peak copy','Copy peaks to other histograms')
     4936        self.PeakEdit.Append(G2G.wxID_PEAKLOAD,'Load peaks...','Load peak list from file')
     4937        self.PeakEdit.Append(G2G.wxID_PEAKSAVE,'Save peaks...','Save peak list to file')
    49354938        self.SeqPeakFit = self.PeakEdit.Append(G2G.wxID_SEQPEAKFIT,'Seq PeakFit',
    49364939            'Sequential Peak fitting for all histograms' )
  • 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())
  • trunk/config_example.py

    r3286 r3348  
    184184information on how this is done.
    185185'''
     186
     187Instprm_default = False
     188'''when True, GSAS-II instprm file are shown as default; when False, old GSAS stype prm, etc files are default
     189'''
Note: See TracChangeset for help on using the changeset viewer.