Changeset 2995


Ignore:
Timestamp:
Aug 11, 2017 9:11:21 AM (4 years ago)
Author:
toby
Message:

fix potential unicode errors in GSASIIdtaGUI; addition parameter definition

Location:
branch/2frame
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branch/2frame/GSASIIdataGUI.py

    r2978 r2995  
    286286                return
    287287            except:
    288                 print "Install of '+package+' failed. Please report this information:"
     288                print u"Install of '+package+u' failed. Please report this information:"
    289289                import traceback
    290290                print traceback.format_exc()
     
    582582    def PreviewFile(self,filename,fp):
    583583        'confirm we have the right file'
    584         rdmsg = 'File '+ filename +' begins:\n\n'
     584        rdmsg = u'File '+ filename +u' begins:\n\n'
    585585        try:
    586586            rdmsg += fp.read(80)
     
    589589            rdmsg = None
    590590        if rdmsg is None or not all([ord(c) < 128 and ord(c) != 0 for c in rdmsg]): # show only if ASCII
    591             rdmsg = 'File '+ filename +' is a binary file. Do you want to read this file?'
     591            rdmsg = u'File '+ filename +u' is a binary file. Do you want to read this file?'
    592592        # it would be better to use something that
    593593        # would resize better, but this will do for now
     
    822822            else:
    823823                if singlereader:
    824                     print('The '+ rd.formatName+' reader was not able to read file '+filename+msg)
     824                    print(u'The '+ rd.formatName+u' reader was not able to read file '+filename+msg)
    825825                    try:
    826                         print('\n\nError message(s):\n\t'+errorReport)
     826                        print(u'\n\nError message(s):\n\t'+errorReport)
    827827                    except:
    828828                        pass
     
    847847        for reader in self.ImportPhaseReaderlist:
    848848            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,
    849                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     849                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    850850            self.ImportMenuId[item.GetId()] = reader
    851851            self.Bind(wx.EVT_MENU, self.OnImportPhase, id=item.GetId())
     
    10261026        for reader in self.ImportImageReaderlist:
    10271027            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,
    1028                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     1028                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    10291029            self.ImportMenuId[item.GetId()] = reader
    10301030            self.Bind(wx.EVT_MENU, self.OnImportImage, id=item.GetId())
     
    10591059        for reader in self.ImportSfactReaderlist:
    10601060            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,               
    1061                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     1061                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    10621062            self.ImportMenuId[item.GetId()] = reader
    10631063            self.Bind(wx.EVT_MENU, self.OnImportSfact, id=item.GetId())
     
    11091109                    valuesdict = {'wtFactor':1.0,'Dummy':False,'ranId':ran.randint(0,sys.maxint),}
    11101110                    HistName = G2obj.MakeUniqueLabel(HistName,HKLFlist)
    1111                     print 'Read structure factor table '+HistName+' from file '+self.lastimport
     1111                    print u'Read structure factor table '+HistName+u' from file '+self.lastimport
    11121112                    Id = self.GPXtree.AppendItem(parent=self.root,text=HistName)
    11131113                    if not Bank['RefDict'].get('FF'):
     
    11221122                valuesdict = {'wtFactor':1.0,'Dummy':False,'ranId':ran.randint(0,sys.maxint),}
    11231123                HistName = G2obj.MakeUniqueLabel(HistName,HKLFlist)
    1124                 print 'Read structure factor table '+HistName+' from file '+self.lastimport
     1124                print u'Read structure factor table '+HistName+u' from file '+self.lastimport
    11251125                if not rd.RefDict.get('FF'):
    11261126                    rd.RefDict['FF'] = {}
     
    12091209        for reader in self.ImportPowderReaderlist:
    12101210            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,
    1211                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     1211                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    12121212            self.ImportMenuId[item.GetId()] = reader
    12131213            self.Bind(wx.EVT_MENU, self.OnImportPowder, id=item.GetId())
     
    13661366            bank = 1 + G2IO.BlockSelector(
    13671367                choices, self,
    1368                 title='Select an instrument parameter bank for '+
    1369                 os.path.split(rd.powderentry[0])[1]+' BANK '+str(bank)+
    1370                 '\nOr use Cancel to select from the default parameter sets',
     1368                title=u'Select an instrument parameter bank for '+
     1369                os.path.split(rd.powderentry[0])[1]+u' BANK '+str(bank)+
     1370                u'\nOr use Cancel to select from the default parameter sets',
    13711371                header='Block Selector')
    13721372        if bank is None: return {}
     
    15151515                    return GetDefaultParms(self,rd)
    15161516            else:
    1517                 self.ErrorDialog('Open Error',u'Error opening instrument parameter file '   \
    1518                     +'{} requested by file '.format(instfile,filename))
     1517                self.ErrorDialog('Open Error',u'Error opening instrument parameter file '
     1518                    +u'{} requested by file '.format(instfile,filename))
    15191519        #Finally - ask user for Instrument parametrs file - seems it can't be in a zip file
    15201520        while True: # loop until we get a file that works or we get a cancel
     
    15231523            if not pth: pth = '.'
    15241524            dlg = wx.FileDialog(self,
    1525                 'Choose inst. param file for "'+rd.idstring+'" (or Cancel for default)',
     1525                u'Choose inst. param file for "'+rd.idstring+u'" (or Cancel for default)',
    15261526                pth, '',
    15271527                'GSAS iparm file (*.prm,*.inst,*.ins)|*.prm;*.inst;*.ins|'
     
    19641964        for reader in self.ImportSmallAngleReaderlist:
    19651965            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,
    1966                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     1966                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    19671967            self.ImportMenuId[item.GetId()] = reader
    19681968            self.Bind(wx.EVT_MENU, self.OnImportSmallAngle, id=item.GetId())
     
    20792079        for reader in self.ImportReflectometryReaderlist:
    20802080            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,
    2081                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     2081                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    20822082            self.ImportMenuId[item.GetId()] = reader
    20832083            self.Bind(wx.EVT_MENU, self.OnImportReflectometry, id=item.GetId())
     
    21962196        for reader in self.ImportPDFReaderlist:
    21972197            item = submenu.Append(wx.ID_ANY,help=reader.longFormatName,
    2198                 kind=wx.ITEM_NORMAL,text='from '+reader.formatName+' file')
     2198                kind=wx.ITEM_NORMAL,text=u'from '+reader.formatName+u' file')
    21992199            self.ImportMenuId[item.GetId()] = reader
    22002200            self.Bind(wx.EVT_MENU, self.OnImportPDF, id=item.GetId())
     
    23182318            defnam = os.path.splitext(
    23192319                os.path.split(self.GSASprojectfile)[1]
    2320                 )[0]+'.gcmd'
     2320                )[0]+u'.gcmd'
    23212321            dlg = wx.FileDialog(self,
    23222322                'Choose an file to save past actions', '.', defnam,
     
    23282328                    filename = dlg.GetPath()
    23292329                    # make sure extension is correct
    2330                     filename = os.path.splitext(filename)[0]+'.gcmd'
     2330                    filename = os.path.splitext(filename)[0]+u'.gcmd'
    23312331                else:
    23322332                    filename = None
     
    23492349            defnam = os.path.splitext(
    23502350                os.path.split(self.GSASprojectfile)[1]
    2351                 )[0]+'.gcmd'
     2351                )[0]+u'.gcmd'
    23522352            dlg = wx.FileDialog(self,
    23532353                'Choose an file to read saved actions', '.', defnam,
     
    23592359                    filename = dlg.GetPath()
    23602360                    # make sure extension is correct
    2361                     filename = os.path.splitext(filename)[0]+'.gcmd'
     2361                    filename = os.path.splitext(filename)[0]+u'.gcmd'
    23622362                else:
    23632363                    filename = None
     
    27712771        arg = sys.argv
    27722772        if len(arg) > 1 and arg[1]:
    2773             self.GSASprojectfile = os.path.splitext(arg[1])[0]+'.gpx'
     2773            self.GSASprojectfile = os.path.splitext(arg[1])[0]+u'.gpx'
    27742774            self.dirname = os.path.abspath(os.path.dirname(arg[1]))
    27752775            if self.dirname: os.chdir(self.dirname)
     
    31663166                    if lenX:
    31673167                        if lenX != len(x):
    3168                             self.ErrorDialog('Data length error','Data to be summed must have same number of points'+ \
    3169                                 '\nExpected:'+str(lenX)+ \
     3168                            self.ErrorDialog('Data length error','Data to be summed must have same number of points'+
     3169                                '\nExpected:'+str(lenX)+
    31703170                                '\nFound:   '+str(len(x))+'\nfor '+name)
    31713171                            self.OnCancel(event)
     
    31743174                    if Xminmax[1]:
    31753175                        if Xminmax != [x[0],x[-1]]:
    3176                             self.ErrorDialog('Data range error','Data to be summed must span same range'+ \
    3177                                 '\nExpected:'+str(Xminmax[0])+' '+str(Xminmax[1])+ \
     3176                            self.ErrorDialog('Data range error','Data to be summed must span same range'+
     3177                                '\nExpected:'+str(Xminmax[0])+' '+str(Xminmax[1])+
    31783178                                '\nFound:   '+str(x[0])+' '+str(x[-1])+'\nfor '+name)
    31793179                            self.OnCancel(event)
     
    35283528                    TextList.remove('PWDR'+pdfName[4:])
    35293529                except ValueError:
    3530                     print 'PWDR'+pdfName[4:]+' for '+pdfName+' not found'
     3530                    print u'PWDR'+pdfName[4:]+u' for '+pdfName+u' not found'
    35313531            dlg = G2G.G2MultiChoiceDialog(self, 'Which data to delete?', 'Delete data', TextList, wx.CHOICEDLG_STYLE)
    35323532            try:
     
    36133613            GetGPX()
    36143614        else:
    3615             self.GSASprojectfile = os.path.splitext(filename)[0]+'.gpx'
     3615            self.GSASprojectfile = os.path.splitext(filename)[0]+u'.gpx'
    36163616            self.dirname = os.path.split(filename)[0]
    36173617
     
    41534153                            Histograms[hist]['hId'] = hId
    41544154                        else: # would happen if a referenced histogram were renamed or deleted
    4155                             print('For phase "'+phase+
    4156                                   '" unresolved reference to histogram "'+hist+'"')
     4155                            print(u'For phase "'+phase+
     4156                                  u'" unresolved reference to histogram "'+hist+u'"')
    41574157        #G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
    41584158        G2obj.IndexAllIds(Histograms=Histograms,Phases=phaseData)
     
    42934293            lamMax = Msg.get('lamMax',0.001)
    42944294            lst = os.path.splitext(os.path.abspath(self.GSASprojectfile))[0]
    4295             text = u'Detailed results are in '+lst+'.lst\n\nLoad new result?'
     4295            text = u'Detailed results are in ' + lst + u'.lst\n\nLoad new result?'
    42964296            if lamMax >= 10.:
    42974297                text += '\nWARNING: Steepest descents dominates;'+   \
     
    43904390            return
    43914391        if warnmsg:
    4392             print('Conflict between refinment flag settings and constraints:\n'+
    4393                   warnmsg+'\nRefinement not possible')
     4392            print(u'Conflict between refinment flag settings and constraints:\n'+
     4393                  warnmsg+u'\nRefinement not possible')
    43944394            self.ErrorDialog('Refinement Flag Error',
    4395                              'Conflict between refinment flag settings and constraints:\n'+
    4396                              warnmsg+'\nRefinement not possible')
     4395                             u'Conflict between refinment flag settings and constraints:\n'+
     4396                             warnmsg+u'\nRefinement not possible')
    43974397            return
    43984398        self.GPXtree.SaveExposedItems()       
     
    60336033                ave = ma.mean(ma.compressed(info))
    60346034                sig = ma.std(ma.compressed(info))
    6035                 print ' Average for '+G2frame.SeqTable.GetColLabelValue(col)+': '+'%.6g'%(ave)+' +/- '+'%.6g'%(sig)
     6035                print u' Average for '+G2frame.SeqTable.GetColLabelValue(col)+u': '+'%.6g'%(ave)+u' +/- '+u'%.6g'%(sig)
    60366036        else:
    60376037            G2frame.ErrorDialog('Select columns',
     
    65406540            obj.UpdateVariedVars(varyList,values)
    65416541            ind = '      '
    6542             print('  '+obj.GetDepVar()+' = '+obj.expression)
     6542            print(u'  '+obj.GetDepVar()+u' = '+obj.expression)
    65436543            for var in obj.assgnVars:
    6544                 print(ind+var+' = '+obj.assgnVars[var])
     6544                print(ind+var+u' = '+obj.assgnVars[var])
    65456545            for var in obj.freeVars:
    65466546                avar = "::"+obj.freeVars[var][0]
    65476547                val = obj.freeVars[var][1]
    65486548                if obj.freeVars[var][2]:
    6549                     print(ind+var+' = '+avar + " = " + G2mth.ValEsd(val,esdDict[avar]))
     6549                    print(ind+var+u' = '+avar + " = " + G2mth.ValEsd(val,esdDict[avar]))
    65506550                else:
    6551                     print(ind+var+' = '+avar + " =" + G2mth.ValEsd(val,0))
     6551                    print(ind+var+u' = '+avar + u" =" + G2mth.ValEsd(val,0))
    65526552        # create a plot for each parametric variable
    65536553        for fitnum,obj in enumerate(eqObjList):
     
    73257325            print 'nothing to merge for %s reflections'%(mergeRef.shape[0])
    73267326        HKLFlist = []
    7327         newName = Name+' '+Laue
     7327        newName = Name+u' '+Laue
    73287328        if G2frame.GPXtree.GetCount():
    73297329            item, cookie = G2frame.GPXtree.GetFirstChild(G2frame.root)
     
    74397439                if 'SS' in value:
    74407440                    mainSizer.Add((5,5),)
    7441                     mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,' For incommensurate phase '+name+':'))
     7441                    mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,u' For incommensurate phase '+name+u':'))
    74427442                    for m,(Rf2,Rf,Nobs) in enumerate(zip(data[0][pfx+'Rf^2'],data[0][pfx+'Rf'],data[0][value])):
    74437443                        mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,
     
    74467446                else:
    74477447                    mainSizer.Add((5,5),)
    7448                     mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,' For phase '+name+':'))
     7448                    mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,u' For phase '+name+u':'))
    74497449                    mainSizer.Add(wx.StaticText(G2frame.dataWindow,-1,
    74507450                        u' Unweighted phase residuals RF\u00b2: %.3f%%, RF: %.3f%% on %d reflections  '% \
  • branch/2frame/GSASIIobj.py

    r2994 r2995  
    15321532        'int$': 'peak intensity',
    15331533        'WgtFrac':'phase weight fraction',
     1534        'C\([0-9]*,[0-9]*\)' : 'spherical harmonics preferred orientation coef.',
    15341535        }.items():
    15351536        VarDesc[key] = value
Note: See TracChangeset for help on using the changeset viewer.