Ignore:
Timestamp:
Mar 11, 2020 4:43:45 PM (21 months ago)
Author:
toby
Message:

fix hist CIF export, remove dev. ver of IntPDFtool

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
     15Independent-running GSAS-II based auto-integration program with minimal
    216GUI, no visualization but intended to implement significant levels of
    317parallelization.
     
    3246import GSASIIscriptable as G2sc
    3347import multiprocessing as mp
     48
     49try: # fails during doc build
     50    wxMainFrameStyle = wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX
     51except:
     52    wxMainFrameStyle = None
    3453
    3554class AutoIntFrame(wx.Frame):
     
    185204
    186205        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               
    188235            writingSomething = False
    189236            writingPDF = False
     
    431478        self.params['outdir'] = os.getcwd()
    432479        self.PDFformats = ('I(Q)', 'S(Q)', 'F(Q)', 'G(r)', 'PDFgui')
     480        self.multipleFmtChoices = {}
    433481        #GSASIIpath.IPyBreak_base()
    434482       
    435483        wx.Frame.__init__(self, None, title='Automatic Integration',
    436                           style=wx.DEFAULT_FRAME_STYLE)
     484                          style=wxMainFrameStyle)
    437485        self.Status = self.CreateStatusBar()
    438486        self.Status.SetStatusText('Press Start to load and integrate images matching filter')
     
    497545        sizer = wx.BoxSizer(wx.HORIZONTAL)
    498546        sizer.Add(wx.StaticText(mnpnl, wx.ID_ANY,'Select format(s):'))
    499         for dfmt in self.fmtlist:
     547        for dfmt in sorted(self.fmtlist):
    500548            sizer.Add((6,2)) # add a bit of extra space
    501549            fmt = dfmt[1:]
     
    712760                dir = os.path.join(self.params['outdir'],
    713761                                   fmt.replace("(","_").replace(")",""))
    714                 if not os.path.exists(dir): os.makedirs(dir)           
     762                if not os.path.exists(dir): os.makedirs(dir)
    715763        return False
    716764               
     
    734782            outputSelect = self.params['outsel']
    735783            PDFformats = self.PDFformats
    736             outputModes = (outputSelect,PDFformats,self.fmtlist,outdir)
     784            outputModes = (outputSelect,PDFformats,self.fmtlist,outdir,
     785                               self.multipleFmtChoices)
    737786            if PDFobj:
    738787                PDFdict = PDFobj.data
     
    833882    '''
    834883    (TableMode,ComputePDF,SeparateDir,optPDF) = calcModes
    835     (outputSelect,PDFformats,fmtlist,outdir) = outputModes           
     884    (outputSelect,PDFformats,fmtlist,outdir,multipleFmtChoices) = outputModes
    836885    if SeparateDir:
    837886        savedir = os.path.join(outdir,'gpx')
     
    872921            if not outputSelect[fmt]: continue
    873922            if fmtlist[dfmt] is None: continue
     923            hint = ''
     924            if fmt in multipleFmtChoices:
     925                hint = multipleFmtChoices[fmt]
    874926            if SeparateDir:
    875927                savedir = os.path.join(outdir,fmt)
     
    880932            for i,h in enumerate(hists):
    881933                fname = h.name[5:].replace(' ','_')
     934                #if len(hists) > 1:
     935                GSASIIpath.IPyBreak_base()
    882936                try:
    883937                    fil = os.path.join(savedir,fname)
    884                     print('Wrote',h.Export(fil,dfmt))
     938                    print('Wrote',h.Export(fil,dfmt,hint))
    885939                except Exception as msg:
    886940                    print('Failed to write {} as {}. Error msg\n{}'
Note: See TracChangeset for help on using the changeset viewer.