Changeset 1390


Ignore:
Timestamp:
Jun 20, 2014 11:15:24 AM (7 years ago)
Author:
toby
Message:

revise start, sort out phase fraction vs scale factor label, add configurable label for columns in sequential refinements. Note: the dict (variableLabels) is not saved yet when a seq. refinement is repeated.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1386 r1390  
    7878wxInspector = False
    7979
    80 # print versions
    81 print "Python module versions loaded:"
    82 print "python:     ",sys.version[:5]
    83 print "wxpython:   ",wx.__version__
    84 print "matplotlib: ",mpl.__version__
    85 print "numpy:      ",np.__version__
    86 print "scipy:      ",sp.__version__
    87 print "OpenGL:     ",ogl.__version__
    88 try:
    89     import mkl
    90     print "Max threads ",mkl.get_max_threads()
    91 except:
    92     pass
    93 #    print "MKL module not present"
    9480__version__ = '0.2.0'
    9581G2gd.__version__ = __version__
    96 print "This is GSAS-II version:     ",__version__,' revision '+str(GSASIIpath.GetVersionNumber())
     82
     83# PATCH: for Mavericks (OS X 10.9.x), wx produces an annoying warning about LucidaGrandeUI.
     84# In case stderr has been suppressed there, redirect python error output to stdout. Nobody
     85# else should care much about this.
     86sys.stderr = sys.stdout
    9787
    9888# useful degree trig functions
     
    33883378   
    33893379if __name__ == '__main__':
     3380    # print versions
     3381    print "Python module versions loaded:"
     3382    print "python:     ",sys.version[:5]
     3383    print "wxpython:   ",wx.__version__
     3384    print "matplotlib: ",mpl.__version__
     3385    print "numpy:      ",np.__version__
     3386    print "scipy:      ",sp.__version__
     3387    print "OpenGL:     ",ogl.__version__
     3388    try:
     3389        import Image
     3390        print "Image (PIL):",Image.VERSION
     3391    except ImportError:
     3392        print "Image module not present; Note that PIL (Python Imaging Library) is needed for some image formats."
     3393    try:
     3394        import mkl
     3395        print "Max threads ",mkl.get_max_threads()
     3396    except:
     3397        pass
     3398    print "This is GSAS-II version:     ",__version__,' revision '+str(GSASIIpath.GetVersionNumber())
    33903399    main() # start the GUI
  • trunk/GSASIIconstrGUI.py

    r1378 r1390  
    407407                            choices.append([var,albl+plbl,meaning])
    408408        elif page[1] == 'hap':
     409            if FrstVarb.name == "Scale":
     410                meaning = "Phase fraction"
    409411            for nam in nameList:
    410412                for ph,plbl in zip(phaselist,phaselbl):
     
    421423                            choices.append([var,plbl+hlbl,meaning])
    422424        elif page[1] == 'hst':
     425            if FrstVarb.name == "Scale":
     426                meaning = "Scale factor"
    423427            for nam in nameList:
    424428                for hst,hlbl in zip(histlist,histlbl):
  • trunk/GSASIIgrid.py

    r1386 r1390  
    14081408        mainSizer = wx.BoxSizer(wx.VERTICAL)
    14091409        mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER)
    1410         self.valItem = wx.TextCtrl(self.panel,-1,value=str(self.value),size=size)
     1410        self.valItem = wx.TextCtrl(self.panel,-1,value=self.value,size=size)
    14111411        mainSizer.Add(self.valItem,0,wx.ALIGN_CENTER)
    14121412        btnsizer = wx.StdDialogButtonSizer()
     
    31463146        return None
    31473147
    3148     def InstallGridToolTip(self, rowcolhintcallback):
     3148    def InstallGridToolTip(self, rowcolhintcallback,
     3149                           colLblCallback=None,rowLblCallback=None):
    31493150        '''code to display a tooltip for each item on a grid
    3150         from http://wiki.wxpython.org/wxGrid%20ToolTips
     3151        from http://wiki.wxpython.org/wxGrid%20ToolTips (buggy!), expanded to
     3152        column and row labels using hints from
     3153        https://groups.google.com/forum/#!topic/wxPython-users/bm8OARRVDCs
    31513154
    31523155        :param function rowcolhintcallback: a routine that returns a text
    3153           string depending on the selected row and column
     3156          string depending on the selected row and column, to be used in
     3157          explaining grid entries.
     3158        :param function colLblCallback: a routine that returns a text
     3159          string depending on the selected column, to be used in
     3160          explaining grid columns (if None, the default), column labels
     3161          do not get a tooltip.
     3162        :param function rowLblCallback: a routine that returns a text
     3163          string depending on the selected row, to be used in
     3164          explaining grid rows (if None, the default), row labels
     3165          do not get a tooltip.
    31543166        '''
    3155         prev_rowcol = [None,None]
    3156         def OnMouseMotion(evt):
    3157             # evt.GetRow() and evt.GetCol() would be nice to have here,
     3167        prev_rowcol = [None,None,None]
     3168        def OnMouseMotion(event):
     3169            # event.GetRow() and event.GetCol() would be nice to have here,
    31583170            # but as this is a mouse event, not a grid event, they are not
    31593171            # available and we need to compute them by hand.
    3160             x, y = self.CalcUnscrolledPosition(evt.GetPosition())
     3172            x, y = self.CalcUnscrolledPosition(event.GetPosition())
    31613173            row = self.YToRow(y)
    31623174            col = self.XToCol(x)
    3163 
    3164             if (row,col) != prev_rowcol and row >= 0 and col >= 0:
    3165                 prev_rowcol[:] = [row,col]
     3175            hinttext = ''
     3176            win = event.GetEventObject()
     3177            if [row,col,win] == prev_rowcol: # no change from last position
     3178                event.Skip()
     3179                return
     3180            if win == self.GetGridWindow() and row >= 0 and col >= 0:
    31663181                hinttext = rowcolhintcallback(row, col)
    3167                 if hinttext is None:
    3168                     hinttext = ''
    3169                 self.GetGridWindow().SetToolTipString(hinttext)
    3170             evt.Skip()
     3182            elif win == self.GetGridColLabelWindow() and col >= 0:
     3183                if colLblCallback: hinttext = colLblCallback(col)
     3184            elif win == self.GetGridRowLabelWindow() and row >= 0:
     3185                if rowLblCallback: hinttext = rowLblCallback(row)
     3186            else: # this should be the upper left corner, which is empty
     3187                event.Skip()
     3188                return
     3189            if hinttext is None: hinttext = ''
     3190            win.SetToolTipString(hinttext)
     3191            prev_rowcol[:] = [row,col,win]
     3192            event.Skip()
    31713193
    31723194        wx.EVT_MOTION(self.GetGridWindow(), OnMouseMotion)
    3173                                                
     3195        if colLblCallback: wx.EVT_MOTION(self.GetGridColLabelWindow(), OnMouseMotion)
     3196        if rowLblCallback: wx.EVT_MOTION(self.GetGridRowLabelWindow(), OnMouseMotion)
     3197                                                   
    31743198################################################################################
    31753199#####  Table
     
    36133637            * 'varyList' - list of variables - identical over all refinements in sequence
    36143638              note that this is the original list of variables, prior to processing
    3615               constraints.
     3639              constraints.
     3640            * 'variableLabels' -- a dict of labels to be applied to each parameter
     3641              (this is created as an empty dict if not present in data).
    36163642            * keyed by histName - dictionaries for all data sets processed, which contains:
    36173643
     
    36593685        for plotting. The column label is reformatted from Unicode to MatPlotLib encoding
    36603686        '''
    3661         plotName = plotSpCharFix(G2frame.SeqTable.GetColLabelValue(col))
     3687        colName = G2frame.SeqTable.GetColLabelValue(col)
     3688        plotName = variableLabels.get(colName,colName)
     3689        plotName = plotSpCharFix(plotName)
    36623690        return plotName,colList[col],colSigs[col]
    36633691           
     
    41844212            return u'\u03c3 = '+str(colSigs[col][row])
    41854213        return ''
     4214    def GridColLblToolTip(col):
     4215        '''Define a tooltip for a column. This will be the user-entered value
     4216        (from data['variableLabels']) or the default name
     4217        '''
     4218        if col < 0 or col > len(colLabels):
     4219            print 'Illegal column #',col
     4220            return
     4221        var = colLabels[col]
     4222        return variableLabels.get(var,G2obj.fmtVarDescr(var))
     4223    def SetLabelString(event):
     4224        '''Define or edit the label for a column in the table, to be used
     4225        as a tooltip and for plotting
     4226        '''
     4227        col = event.GetCol()
     4228        if col < 0 or col > len(colLabels):
     4229            return
     4230        var = colLabels[col]
     4231        lbl = variableLabels.get(var,G2obj.fmtVarDescr(var))
     4232        dlg = SingleStringDialog(G2frame.dataFrame,'Set variable label',
     4233                                 'Set a name for variable '+var,lbl,size=(400,-1))
     4234        if dlg.Show():
     4235            variableLabels[var] = dlg.GetValue()
     4236            print variableLabels
     4237        dlg.Destroy()
     4238       
     4239    #def GridRowLblToolTip(row): return 'Row ='+str(row)
    41864240   
    41874241    # lookup table for unique cell parameters by symmetry
     
    42054259        print 'No sequential refinement results'
    42064260        return
     4261    variableLabels = data.get('variableLabels',{})
     4262    data['variableLabels'] = variableLabels
    42074263    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
    42084264    Controls = G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.root,'Controls'))
     
    44574513    G2frame.dataDisplay.EnableEditing(False)
    44584514    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, PlotSelect)
     4515    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, SetLabelString)
    44594516    G2frame.dataDisplay.SetRowLabelSize(8*len(histNames[0]))       #pretty arbitrary 8
    44604517    G2frame.dataDisplay.SetMargins(0,0)
     
    44694526            deltaChi = G2frame.SeqTable.GetValue(row,deltaChiCol)
    44704527            if deltaChi > 10.:
    4471                 G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Color(255,0,0))
     4528                G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,0,0))
    44724529            elif deltaChi > 1.0:
    4473                 G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Color(255,255,0))
    4474     G2frame.dataDisplay.InstallGridToolTip(GridSetToolTip)
     4530                G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,255,0))
     4531    G2frame.dataDisplay.InstallGridToolTip(GridSetToolTip,GridColLblToolTip)
    44754532    #======================================================================
    44764533    # end UpdateSeqResults; done processing sequential results
    44774534    #======================================================================
    4478 
    4479     # make dict with vars for use in PseudoVars
    4480     # name = histNames[0]
    4481     # parmDict = dict(zip(colLabels,zip(*colList)[0]))
    4482     # # create a dict with the refined Ax values for all phases (only)
    4483     # refCellDict = {var:val for var,val in data[name]['newCellDict'].values()}
    4484     # # compute the Ai values for each phase, updated with refined values and
    4485     # # with symmetry constraints applied
    4486     # for pId in Alist:     # loop over phases
    4487     #     Albls = [str(pId)+'::A'+str(i) for i in range(6)]
    4488     #     cellDict = {var:refCellDict.get(var,val) for var,val in zip(Albls,Alist[pId])}
    4489     #     zeroDict = {var:0.0 for var in Albls}
    4490     #     A,zeros = G2stIO.cellFill(str(pId)+'::',SGdata[pId],cellDict,zeroDict)
    4491     #     parmDict.update(dict(zip(Albls,A)))
    4492 
    4493 #    print data[name]['varyList']
    4494 #           
    4495     # print 'vars for PVar dict'
    4496     # for i,(var,val) in enumerate(zip(colLabels,zip(*colList)[0])):
    4497     #     if var in data[name]['varyList']:
    4498     #         print var,Dlookup.get(striphist(var),var),val,parmDict.get(Dlookup.get(striphist(var),var))
    4499     #         pass
    4500     #     #else:
    4501     #     #    print i,var,colSigs[i]
    4502     # print 'vars for PVar dict again'
    45034535   
    45044536################################################################################
  • trunk/GSASIIobj.py

    r1387 r1390  
    11391139    s = ""
    11401140    if l[0] is not None and l[1] is not None: # HAP: keep short
     1141        if l[2] == "Scale": # fix up ambigous name
     1142            l[5] = "Phase fraction"
    11411143        if l[0] == '*':
    11421144            lbl = 'all'
     
    11541156            hlbl = 'Hist='+hlbl
    11551157        s = "Ph="+str(lbl)+" * "+str(hlbl)
    1156     elif l[2] == 'Back': # background parameters are "special", alas
    1157         s = 'Hist='+ShortHistNames.get(l[1],'? #'+str(l[1]))
    1158         l[-1] += ' #'+str(l[3])
    1159     elif l[4] is not None: # rigid body parameter
    1160         lbl = ShortPhaseNames.get(l[0],'phase?')
    1161         s = "Res #"+str(l[3])+" body #"+str(l[4])+" in "+str(lbl)
    1162     elif l[3] is not None: # atom parameter,
    1163         lbl = ShortPhaseNames.get(l[0],'phase?')
    1164         try:
    1165             albl = LookupAtomLabel(l[0],l[3])[0]
    1166         except KeyError:
    1167             albl = 'Atom?'
    1168         s = "Atom "+str(albl)+" in "+str(lbl)
    1169     elif l[0] == '*':
    1170         s = "All phases "
    1171     elif l[0] is not None:
    1172         lbl = ShortPhaseNames.get(l[0],'phase?')
    1173         s = "Phase "+str(lbl)
    1174     elif l[1] == '*':
    1175         s = 'All hists'
    1176     elif l[1] is not None:
    1177         hlbl = ShortHistNames.get(l[1],'? #'+str(l[1]))
    1178         if hlbl[:4] == 'HKLF':
    1179             hlbl = 'Xtl='+hlbl[5:]
    1180         elif hlbl[:4] == 'PWDR':
    1181             hlbl = 'Pwd='+hlbl[5:]
    1182         else:
    1183             hlbl = 'Hist='+hlbl
    1184         s = str(hlbl)
     1158    else:
     1159        if l[2] == "Scale": # fix up ambigous name: must be scale factor, since not HAP
     1160            l[5] = "Scale factor"
     1161        if l[2] == 'Back': # background parameters are "special", alas
     1162            s = 'Hist='+ShortHistNames.get(l[1],'? #'+str(l[1]))
     1163            l[-1] += ' #'+str(l[3])
     1164        elif l[4] is not None: # rigid body parameter
     1165            lbl = ShortPhaseNames.get(l[0],'phase?')
     1166            s = "Res #"+str(l[3])+" body #"+str(l[4])+" in "+str(lbl)
     1167        elif l[3] is not None: # atom parameter,
     1168            lbl = ShortPhaseNames.get(l[0],'phase?')
     1169            try:
     1170                albl = LookupAtomLabel(l[0],l[3])[0]
     1171            except KeyError:
     1172                albl = 'Atom?'
     1173            s = "Atom "+str(albl)+" in "+str(lbl)
     1174        elif l[0] == '*':
     1175            s = "All phases "
     1176        elif l[0] is not None:
     1177            lbl = ShortPhaseNames.get(l[0],'phase?')
     1178            s = "Phase "+str(lbl)
     1179        elif l[1] == '*':
     1180            s = 'All hists'
     1181        elif l[1] is not None:
     1182            hlbl = ShortHistNames.get(l[1],'? #'+str(l[1]))
     1183            if hlbl[:4] == 'HKLF':
     1184                hlbl = 'Xtl='+hlbl[5:]
     1185            elif hlbl[:4] == 'PWDR':
     1186                hlbl = 'Pwd='+hlbl[5:]
     1187            else:
     1188                hlbl = 'Hist='+hlbl
     1189            s = str(hlbl)
    11851190    if not s:
    11861191        s = 'Global'
     
    13011306        'Mean' : 'Particle mean radius',
    13021307        'StdDev' : 'Standard deviation in Mean',
    1303         'G': 'Guinier prefactor',
    1304         'Rg': 'Guinier radius of gyration',
    1305         'B': 'Porod prefactor',
    1306         'P': 'Porod power',
     1308        'G$': 'Guinier prefactor',
     1309        'Rg$': 'Guinier radius of gyration',
     1310        'B$': 'Porod prefactor',
     1311        'P$': 'Porod power',
    13071312        'Cutoff': 'Porod cutoff',
    13081313        'PkInt': 'Bragg peak intensity',
     
    13101315        'PkSig': 'Bragg peak sigma',
    13111316        'PkGam': 'Bragg peak gamma',
    1312         # strain vars e11, e22, e12
    1313         'e11' : 'strain tensor e11',
    1314         'e22' : 'strain tensor e22',
    1315         'e12' : 'strain tensor e12',
     1317        'e([12][12])' : 'strain tensor e\1',   # strain vars e11, e22, e12
    13161318        }.items():
    13171319        VarDesc[key] = value
Note: See TracChangeset for help on using the changeset viewer.