Changeset 2895 for branch


Ignore:
Timestamp:
Jul 2, 2017 7:27:09 PM (6 years ago)
Author:
toby
Message:

merge trunk changes to 2984

Location:
branch/2frame
Files:
1 added
5 edited
21 copied

Legend:

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

    r2893 r2895  
    41774177            Rw = Msg['Rwp']
    41784178            lamMax = Msg.get('lamMax',0.001)
    4179             text = 'Load new result?'
     4179            lst = os.path.splitext(os.path.abspath(self.GSASprojectfile))[0]
     4180            text = u'Detailed results are in '+lst+'.lst\n\nLoad new result?'
    41804181            if lamMax >= 10.:
    41814182                text += '\nWARNING: Steepest descents dominates;'+   \
     
    42894290        dlg.CenterOnParent()
    42904291        try:
    4291             OK,Msg = G2stMn.SeqRefine(self.GSASprojectfile,dlg)     #Msg is Rvals dict if Ok=True
     4292            OK,Msg = G2stMn.SeqRefine(self.GSASprojectfile,dlg,G2plt.SequentialPlotPattern,self)     #Msg is Rvals dict if Ok=True
    42924293        finally:
    42934294            dlg.Update(101.) # forces the Auto_Hide; needed after move w/Win & wx3.0
  • branch/2frame/GSASIIctrls.py

    r2890 r2895  
    27222722    else:
    27232723        return '.'
     2724
     2725################################################################################
     2726class SGMessageBox(wx.Dialog):
     2727    ''' Special version of MessageBox that displays space group & super space group text
     2728    in two blocks
     2729    '''
     2730    def __init__(self,parent,title,text,table,):
     2731        wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition,
     2732            style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     2733        self.text = text
     2734        self.table = table
     2735        self.panel = wx.Panel(self)
     2736        mainSizer = wx.BoxSizer(wx.VERTICAL)
     2737        mainSizer.Add((0,10))
     2738        for line in text:
     2739            mainSizer.Add(wx.StaticText(self.panel,label='     %s     '%(line)),0,WACV)
     2740        ncol = self.table[0].count(',')+1
     2741        tableSizer = wx.FlexGridSizer(0,2*ncol+3,0,0)
     2742        for j,item in enumerate(self.table):
     2743            num,flds = item.split(')')
     2744            tableSizer.Add(wx.StaticText(self.panel,label='     %s  '%(num+')')),0,WACV|wx.ALIGN_LEFT)           
     2745            flds = flds.replace(' ','').split(',')
     2746            for i,fld in enumerate(flds):
     2747                if i < ncol-1:
     2748                    tableSizer.Add(wx.StaticText(self.panel,label='%s, '%(fld)),0,WACV|wx.ALIGN_RIGHT)
     2749                else:
     2750                    tableSizer.Add(wx.StaticText(self.panel,label='%s'%(fld)),0,WACV|wx.ALIGN_RIGHT)
     2751            if not j%2:
     2752                tableSizer.Add((20,0))
     2753        mainSizer.Add(tableSizer,0,wx.ALIGN_LEFT)
     2754        btnsizer = wx.StdDialogButtonSizer()
     2755        OKbtn = wx.Button(self.panel, wx.ID_OK)
     2756        OKbtn.Bind(wx.EVT_BUTTON, self.OnOk)
     2757        OKbtn.SetDefault()
     2758        btnsizer.AddButton(OKbtn)
     2759        btnsizer.Realize()
     2760        mainSizer.Add((0,10))
     2761        mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER)
     2762        self.panel.SetSizer(mainSizer)
     2763        self.panel.Fit()
     2764        self.Fit()
     2765        size = self.GetSize()
     2766        self.SetSize([size[0]+20,size[1]])
     2767
     2768    def Show(self):
     2769        '''Use this method after creating the dialog to post it
     2770        '''
     2771        self.ShowModal()
     2772        return
     2773
     2774    def OnOk(self,event):
     2775        parent = self.GetParent()
     2776        parent.Raise()
     2777        self.EndModal(wx.ID_OK)
    27242778
    27252779################################################################################
  • branch/2frame/GSASIIgrid.py

    r2893 r2895  
    176176    'P->I','I->P','P->F','F->P','H->R','R->H','R->O','O->R','abc*','setting 1->2']          #don't put any new ones after the setting one!
    177177
    178 # Should SGMessageBox, SymOpDialog, DisAglDialog be moved?
    179 
    180178################################################################################
    181179#### GSAS-II class definitions
    182180################################################################################
    183181
    184 class SGMessageBox(wx.Dialog):
    185     ''' Special version of MessageBox that displays space group & super space group text
    186     in two blocks
    187     '''
    188     def __init__(self,parent,title,text,table,):
    189         wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition,
    190             style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    191         self.text = text
    192         self.table = table
    193         self.panel = wx.Panel(self)
    194         mainSizer = wx.BoxSizer(wx.VERTICAL)
    195         mainSizer.Add((0,10))
    196         for line in text:
    197             mainSizer.Add(wx.StaticText(self.panel,label='     %s     '%(line)),0,WACV)
    198         ncol = self.table[0].count(',')+1
    199         tableSizer = wx.FlexGridSizer(0,2*ncol+3,0,0)
    200         for j,item in enumerate(self.table):
    201             num,flds = item.split(')')
    202             tableSizer.Add(wx.StaticText(self.panel,label='     %s  '%(num+')')),0,WACV|wx.ALIGN_LEFT)           
    203             flds = flds.replace(' ','').split(',')
    204             for i,fld in enumerate(flds):
    205                 if i < ncol-1:
    206                     tableSizer.Add(wx.StaticText(self.panel,label='%s, '%(fld)),0,WACV|wx.ALIGN_RIGHT)
    207                 else:
    208                     tableSizer.Add(wx.StaticText(self.panel,label='%s'%(fld)),0,WACV|wx.ALIGN_RIGHT)
    209             if not j%2:
    210                 tableSizer.Add((20,0))
    211         mainSizer.Add(tableSizer,0,wx.ALIGN_LEFT)
    212         btnsizer = wx.StdDialogButtonSizer()
    213         OKbtn = wx.Button(self.panel, wx.ID_OK)
    214         OKbtn.Bind(wx.EVT_BUTTON, self.OnOk)
    215         OKbtn.SetDefault()
    216         btnsizer.AddButton(OKbtn)
    217         btnsizer.Realize()
    218         mainSizer.Add((0,10))
    219         mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER)
    220         self.panel.SetSizer(mainSizer)
    221         self.panel.Fit()
    222         self.Fit()
    223         size = self.GetSize()
    224         self.SetSize([size[0]+20,size[1]])
    225 
    226     def Show(self):
    227         '''Use this method after creating the dialog to post it
    228         '''
    229         self.ShowModal()
    230         return
    231 
    232     def OnOk(self,event):
    233         parent = self.GetParent()
    234         parent.Raise()
    235         self.EndModal(wx.ID_OK)
     182# Should SymOpDialog, DisAglDialog etc. be moved to GSASIIctrls?
    236183
    237184class SGMagSpinBox(wx.Dialog):
     
    581528                SGTxt.SetValue(self.Phase['General']['SGData']['SpGrp'])
    582529                msg = 'Space Group Information'
    583                 SGMessageBox(self.panel,msg,text,table).Show()
     530                G2G.SGMessageBox(self.panel,msg,text,table).Show()
    584531            if self.Phase['General']['Type'] == 'magnetic':
    585532                Nops = len(SGData['SGOps'])*len(SGData['SGCen'])
     
    30082955        return plotName,G2frame.colList[col],G2frame.colSigs[col]
    30092956           
    3010     def PlotSelect(event):
    3011         'Plots a row (covariance) or column on double-click'
     2957    def PlotSelectedColRow(calltyp=''):
     2958        '''Called to plot a selected column or row. This is called after the event is processed
     2959        so that the column or row gets selected.
     2960        Single click on row: plots histogram
     2961        Double click on row: plots V-C matrix
     2962        Single or double click on column: plots values in column
     2963        '''
    30122964        cols = G2frame.dataDisplay.GetSelectedCols()
    30132965        rows = G2frame.dataDisplay.GetSelectedRows()
    30142966        if cols:
    30152967            G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis)
     2968        elif rows and calltyp == 'single':
     2969            name = histNames[rows[0]]       #only does 1st one selected
     2970            if not name.startswith('PWDR'): return
     2971            pickId = G2frame.PickId
     2972            G2frame.PickId = G2frame.PatternId = GetPatternTreeItemId(G2frame, G2frame.root, name)
     2973            G2plt.PlotPatterns(G2frame,newPlot=True,plotType='PWDR')
     2974            G2frame.PickId = pickId
    30162975        elif rows:
    30172976            name = histNames[rows[0]]       #only does 1st one selected
     
    30222981                'Nothing selected in table. Click on column or row label(s) to plot. N.B. Grid selection can be a bit funky.'
    30232982                )
     2983       
     2984    def PlotSSelect(event):
     2985        'Called by a single click on a row or column label. '
     2986        event.Skip()
     2987        wx.CallAfter(PlotSelectedColRow,'single')
     2988       
     2989    def PlotSelect(event):
     2990        'Called by a double-click on a row or column label'
     2991        event.Skip()
     2992        wx.CallAfter(PlotSelectedColRow,'double')
    30242993           
    30252994    def OnPlotSelSeq(event):
     
    39833952        sigwtFrList = []
    39843953        for i,name in enumerate(histNames):
     3954            if name not in Phases[phase]['Histograms']:
     3955                wtFrList.append(None)
     3956                sigwtFrList.append(0.0)
     3957                continue
    39853958            wtFrSum = 0.
    39863959            for phase1 in Phases:
     3960                if name not in Phases[phase1]['Histograms']: continue
    39873961                wtFrSum += Phases[phase1]['Histograms'][name]['Scale'][0]*Phases[phase1]['General']['Mass']
    39883962            var = str(Phases[phase]['pId'])+':'+str(i)+':Scale'
     
    41414115        for r in range(nRows):
    41424116            G2frame.dataDisplay.SetCellReadOnly(r,c)
     4117    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK, PlotSSelect)
    41434118    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, PlotSelect)
    41444119    G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, SetLabelString)
  • branch/2frame/GSASIIphsGUI.py

    r2893 r2895  
    444444used (not recommended when alpha >> 120 or << 60, due to correlation.)
    445445
     446For standard settings of space groups, space group numbers (1-230) can alternately
     447be entered.
     448
    446449GSAS-II will accept non-standard settings of space groups. For example, space
    447450group "P -1" can be set to include face centering, using symbol "F -1" and "P 1 1 21/a"
     
    452455'''
    453456                dlg = G2G.SingleStringDialog(General,'Get Space Group',
    454                     '  Input the space group with spaces between axial fields  \n  (e.g. p 21/c, P 63/m m c, P 4/m m m',
     457                    '  Input the space group with spaces between axial fields  \n  (e.g. p 21/c, P 63/m m c, P 4/m m m) or enter a space\n  group number between 1 and 230.',
    455458                    value=generalData['SGData']['SpGrp'],help=helptext)
    456459                if not dlg.Show():
     
    458461                    return
    459462                else:
    460                     Flds = dlg.GetValue().split()
    461                     dlg.Destroy()
    462                 #get rid of extra spaces between fields first
    463                 for fld in Flds: fld = fld.strip()
    464                 SpcGp = ' '.join(Flds)
     463                    try:
     464                        # has a space group number been input?
     465                        spcnum = int(dlg.GetValue())
     466                        if 1 <= spcnum <= 230:
     467                            SpcGp = G2spc.spgbyNum[spcnum]
     468                        else:
     469                            msg = 'Space Group Error'
     470                            Style = wx.ICON_EXCLAMATION
     471                            wx.MessageBox('Invalid space group number',caption=msg,style=Style)
     472                            return
     473                    except:
     474                        #get rid of extra spaces between fields first
     475                        Flds = dlg.GetValue().split()
     476                        for fld in Flds: fld = fld.strip()
     477                        SpcGp = ' '.join(Flds)
     478                    finally:
     479                        dlg.Destroy()
    465480                # try a lookup on the user-supplied name
    466481                SpGrpNorm = G2spc.StandardizeSpcName(SpcGp)
     
    481496                    SGTxt.SetLabel(generalData['SGData']['SpGrp'])
    482497                    msg = 'Space Group Information'
    483                     G2gd.SGMessageBox(General,msg,text,table).Show()
     498                    G2G.SGMessageBox(General,msg,text,table).Show()
    484499                if generalData['Type'] == 'magnetic':
    485500                    Nops = len(SGData['SGOps'])*len(SGData['SGCen'])
     
    884899                    generalData['SuperSg'] = SSymbol
    885900                    msg = 'Superspace Group Information'
    886                     G2gd.SGMessageBox(General,msg,text,table).Show()
     901                    G2G.SGMessageBox(General,msg,text,table).Show()
    887902                else:
    888903                    text = [E+'\nSuperspace Group set to previous']
     
    57085723                    copyDict[name] = sourceDict[name][1]
    57095724            elif name in ['Size','Mustrain']:
    5710                 copyDict[name] = [sourceDict[name][0],sourceDict[name][2],sourceDict[name][4]]
     5725                copyDict[name] = [sourceDict[name][0],sourceDict[name][2],sourceDict[name][5]]
    57115726            elif name == 'Pref.Ori.':
    57125727                copyDict[name] = [sourceDict[name][0],sourceDict[name][2]]
     
    57495764                            data['Histograms'][item][name][0] = copy.deepcopy(copyDict[name][0])
    57505765                            data['Histograms'][item][name][2] = copy.deepcopy(copyDict[name][1])
    5751                             data['Histograms'][item][name][4] = copy.deepcopy(copyDict[name][2])
     5766                            data['Histograms'][item][name][5] = copy.deepcopy(copyDict[name][2])
    57525767                        elif name == 'Pref.Ori.':
    57535768                            data['Histograms'][item][name][0] = copy.deepcopy(copyDict[name][0])
  • branch/2frame/GSASIIplot.py

    r2891 r2895  
    11811181##### PlotPatterns
    11821182################################################################################
     1183def SequentialPlotPattern(G2frame,refdata,histogram):
     1184    '''This is passed into :func:`GSASIIstrMain.SeqRefine` where it is used to
     1185    provide a plot of the current powder histogram just after a refinement. It
     1186    takes the old refinement information (Rfactors, curve locations, etc.) and
     1187    combines it with the refinement results in refdata and passes that to
     1188    :func:`PlotPatterns`
     1189    '''
     1190    if not histogram.startswith('PWDR'): return
     1191    pickId = G2frame.PickId
     1192    G2frame.PickId = G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, histogram)
     1193    treedata = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
     1194    PlotPatterns(G2frame,newPlot=True,plotType='PWDR',data=[treedata[0],refdata])
     1195    wx.Yield() # force a plot update (needed on Windows?)
     1196    G2frame.PickId = pickId
     1197   
    11831198def ReplotPattern(G2frame,newPlot,plotType,PatternName=None,PickName=None):
    11841199    '''This does the same as PlotPatterns except that it expects the information
     
    11961211    PlotPatterns(G2frame,newPlot,plotType)
    11971212
    1198 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR'):
     1213def PlotPatterns(G2frame,newPlot=False,plotType='PWDR',data=None):
    11991214    '''Powder pattern plotting package - displays single or multiple powder patterns as intensity vs
    12001215    2-theta, q or TOF. Can display multiple patterns as "waterfall plots" or contour plots. Log I
     
    12201235        return
    12211236#patch
    1222     data = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
     1237    if data is None:
     1238        data = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)
    12231239    if 'Offset' not in data[0] and plotType in ['PWDR','SASD','REFD']:     #plot offset data
    12241240        Ymax = max(data[1][1])
     
    18241840        Page.canvas.mpl_connect('button_press_event',OnPress)
    18251841    if 'PWDR' in G2frame.PatternTree.GetItemText(G2frame.PickId):
     1842        Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     1843        refColors=['b','r','c','g','m','k']
     1844        Page.phaseColors = {p:refColors[i%len(refColors)] for i,p in enumerate(Phases)}
    18261845        Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Reflection Lists'))
    18271846        Page.phaseList = sorted(Phases.keys()) # define an order for phases (once!)
     
    22152234        elif G2frame.PatternTree.GetItemText(PickId) in ['Reflection Lists'] or \
    22162235            'PWDR' in G2frame.PatternTree.GetItemText(PickId):
    2217             refColors=['b','r','c','g','m','k']
    22182236            Phases = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    22192237            l = GSASIIpath.GetConfigValue('Tick_length',8.0)
     
    22302248                    peak = np.array([[peak[4],peak[5]] for peak in peaks])
    22312249                pos = Pattern[0]['refOffset']-pId*Pattern[0]['refDelt']*np.ones_like(peak)
     2250                plsym = Page.phaseColors.get(phase,'y')+'|' # yellow should never happen!
    22322251                if G2frame.plotStyle['qPlot']:
    2233                     Page.tickDict[phase],j = Plot.plot(2*np.pi/peak.T[0],pos,refColors[pId%6]+'|',mew=w,ms=l,picker=3.,label=phase)
     2252                    Page.tickDict[phase],j = Plot.plot(2*np.pi/peak.T[0],pos,plsym,mew=w,ms=l,picker=3.,label=phase)
    22342253                elif G2frame.plotStyle['dPlot']:
    2235                     Page.tickDict[phase],j = Plot.plot(peak.T[0],pos,refColors[pId%6]+'|',mew=w,ms=l,picker=3.,label=phase)
     2254                    Page.tickDict[phase],j = Plot.plot(peak.T[0],pos,plsym,mew=w,ms=l,picker=3.,label=phase)
    22362255                else:
    2237                     Page.tickDict[phase],j = Plot.plot(peak.T[1],pos,refColors[pId%6]+'|',mew=w,ms=l,picker=3.,label=phase)
     2256                    Page.tickDict[phase],j = Plot.plot(peak.T[1],pos,plsym,mew=w,ms=l,picker=3.,label=phase)
    22382257            if len(Phases):
    22392258                handles,legends = Plot.get_legend_handles_labels()  #got double entries in the legends for some reason
Note: See TracChangeset for help on using the changeset viewer.