Changeset 4361 for trunk/GSASIIIntPDFtool.py
- Timestamp:
- Mar 11, 2020 4:43:45 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIntPDFtool.py
r4053 r4361 1 '''Independent-running GSAS-II based auto-integration program with minimal 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #GSAS-II autointegration routines 4 ########### SVN repository information ################### 5 # $Date: $ 6 # $Author: $ 7 # $Revision: $ 8 # $URL: $ 9 # $Id: $ 10 ########### SVN repository information ################### 11 ''' 12 *GSASIIautoint: autointegration routines* 13 --------------------------------------------- 14 15 Independent-running GSAS-II based auto-integration program with minimal 2 16 GUI, no visualization but intended to implement significant levels of 3 17 parallelization. … … 32 46 import GSASIIscriptable as G2sc 33 47 import multiprocessing as mp 48 49 try: # fails during doc build 50 wxMainFrameStyle = wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX 51 except: 52 wxMainFrameStyle = None 34 53 35 54 class AutoIntFrame(wx.Frame): … … 185 204 186 205 def TestInput(*args,**kwargs): 187 'Determine if the start button should be enabled' 206 '''Determine if the start button should be enabled and 207 ask for the exporter type with ambiguous extensions 208 ''' 209 for dfmt,obj in self.fmtlist.items(): 210 fmt = dfmt[1:] 211 if not self.params['outsel'][fmt]: continue 212 if fmt in self.multipleFmtChoices: continue 213 if type(obj) is not list: continue # only one exporter for this 214 choices = [] 215 for e in obj: 216 choices.append(e.formatName) 217 if len(choices) == 0: 218 print('Error: why 0 choices in TestInput?') 219 continue 220 if len(choices) == 1: 221 print('Error: why 1 choice in TestInput?') 222 self.multipleFmtChoices[fmt] = obj[0].formatName 223 continue 224 # select the format here 225 dlg = G2G.G2SingleChoiceDialog(self, 226 'There is more than one format with a '+ 227 '.{} output. Choose the one to use'.format(fmt), 228 'Choose output format',choices) 229 dlg.CenterOnParent() 230 dlg.clb.SetSelection(0) # force a selection 231 if dlg.ShowModal() == wx.ID_OK and dlg.GetSelection() >= 0: 232 self.multipleFmtChoices[fmt] = choices[dlg.GetSelection()] 233 dlg.Destroy() 234 188 235 writingSomething = False 189 236 writingPDF = False … … 431 478 self.params['outdir'] = os.getcwd() 432 479 self.PDFformats = ('I(Q)', 'S(Q)', 'F(Q)', 'G(r)', 'PDFgui') 480 self.multipleFmtChoices = {} 433 481 #GSASIIpath.IPyBreak_base() 434 482 435 483 wx.Frame.__init__(self, None, title='Automatic Integration', 436 style=wx .DEFAULT_FRAME_STYLE)484 style=wxMainFrameStyle) 437 485 self.Status = self.CreateStatusBar() 438 486 self.Status.SetStatusText('Press Start to load and integrate images matching filter') … … 497 545 sizer = wx.BoxSizer(wx.HORIZONTAL) 498 546 sizer.Add(wx.StaticText(mnpnl, wx.ID_ANY,'Select format(s):')) 499 for dfmt in s elf.fmtlist:547 for dfmt in sorted(self.fmtlist): 500 548 sizer.Add((6,2)) # add a bit of extra space 501 549 fmt = dfmt[1:] … … 712 760 dir = os.path.join(self.params['outdir'], 713 761 fmt.replace("(","_").replace(")","")) 714 if not os.path.exists(dir): os.makedirs(dir) 762 if not os.path.exists(dir): os.makedirs(dir) 715 763 return False 716 764 … … 734 782 outputSelect = self.params['outsel'] 735 783 PDFformats = self.PDFformats 736 outputModes = (outputSelect,PDFformats,self.fmtlist,outdir) 784 outputModes = (outputSelect,PDFformats,self.fmtlist,outdir, 785 self.multipleFmtChoices) 737 786 if PDFobj: 738 787 PDFdict = PDFobj.data … … 833 882 ''' 834 883 (TableMode,ComputePDF,SeparateDir,optPDF) = calcModes 835 (outputSelect,PDFformats,fmtlist,outdir ) = outputModes884 (outputSelect,PDFformats,fmtlist,outdir,multipleFmtChoices) = outputModes 836 885 if SeparateDir: 837 886 savedir = os.path.join(outdir,'gpx') … … 872 921 if not outputSelect[fmt]: continue 873 922 if fmtlist[dfmt] is None: continue 923 hint = '' 924 if fmt in multipleFmtChoices: 925 hint = multipleFmtChoices[fmt] 874 926 if SeparateDir: 875 927 savedir = os.path.join(outdir,fmt) … … 880 932 for i,h in enumerate(hists): 881 933 fname = h.name[5:].replace(' ','_') 934 #if len(hists) > 1: 935 GSASIIpath.IPyBreak_base() 882 936 try: 883 937 fil = os.path.join(savedir,fname) 884 print('Wrote',h.Export(fil,dfmt ))938 print('Wrote',h.Export(fil,dfmt,hint)) 885 939 except Exception as msg: 886 940 print('Failed to write {} as {}. Error msg\n{}'
Note: See TracChangeset
for help on using the changeset viewer.