Changeset 1548 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
Oct 30, 2014 4:07:50 PM (8 years ago)
Author:
vondreele
Message:

more super structure stuff - now some in unit cell indexing
now using pulldown ComboBoxes? for supersymmetry choices
continue building tables of supersymmetry codes
use deepcopy for peaks in various places; copy wasn't enough
get seq. peak fit to stop when a refinement goes bad; then allow display of results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r1547 r1548  
    353353            Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item)
    354354            G2frame.PatternTree.SetItemPyData(
    355                 G2gd.GetPatternTreeItemId(G2frame,Id,'Peak List'),copy.copy(data))
     355                G2gd.GetPatternTreeItemId(G2frame,Id,'Peak List'),copy.deepcopy(data))
    356356   
    357357    def OnUnDo(event):
     
    407407                names.append(histList[sel])
    408408        dlg.Destroy()
    409         SeqResult = {'histNames':names}
     409        SeqResult = {}
    410410        Reverse = False
    411411        CopyForward = False
     
    428428        FitPgm = 'LSQ'
    429429        prevVaryList = []
     430        Names = []
    430431        if Reverse:
    431432            names.reverse()
     
    438439                PatternId =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)
    439440                if i and CopyForward:
    440                     G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),copy.copy(peaks))
     441                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),copy.deepcopy(peaks))
    441442                    prevVaryList = varyList[:]
    442443                peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'))
     
    455456                        background,limits,inst,inst2,data,prevVaryList,oneCycle,controls,dlg2)
    456457                finally:
    457                     dlg2.Destroy()   
    458                 G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),copy.copy(peaks))
    459                 SeqResult[name] = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
    460                     'covMatrix':np.eye(len(result[0])),'title':name,'parmDict':parmDict,
    461                     'fullVary':fullvaryList,'badVary':badVary}
    462             else:
    463                 dlg.Destroy()
    464                 print ' ***** Sequential peak fit successful *****'
     458                    dlg2.Destroy()
     459                if len(result[0]) != len(fullvaryList):
     460                    print ' ***** Sequential peak fit stopped at '+name+' *****'
     461                    break
     462                else:
     463                    Names.append(name)   
     464                    G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),copy.deepcopy(peaks))
     465                    SeqResult[name] = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals,
     466                        'covMatrix':np.eye(len(result[0])),'title':name,'parmDict':parmDict,
     467                        'fullVary':fullvaryList,'badVary':badVary}
     468            dlg.Destroy()
     469            print ' ***** Sequential peak fit successful *****'
    465470        finally:
    466471            wx.EndBusyCursor()
     472        SeqResult['histNames'] = Names
    467473        Id =  G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential results')
    468474        if Id:
     
    21972203        controls[0] = zeroVar.GetValue()
    21982204       
     2205    def OnSSopt(event):
     2206        ssopt['Use'] = SSopt.GetValue()
     2207        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
     2208       
     2209    def OnSelMG(event):
     2210        ssopt['ssSymb'] = selMG.GetValue()
     2211        Vec = ssopt['ModVec']
     2212        modS = G2spc.splitSSsym(ssopt['ssSymb'])[0]
     2213        ssopt['ModVec'] = G2spc.SSGModCheck(Vec,modS)[0]
     2214        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
     2215       
     2216    def OnModVal(event):
     2217        pass
     2218       
     2219    def OnMoveMod(event):
     2220        Obj = event.GetEventObject()
     2221        ObjId = cellList.index(Obj.GetId())
     2222        valObj = valDict[Obj.GetId()]
     2223        move = Obj.GetValue()*0.01
     2224        Obj.SetValue(0)
     2225        value = float(valObj.GetValue())+move 
     2226#        SetCellValue(valObj,ObjId,value)
     2227#        OnHklShow(event)
     2228       
    21992229    def OnBravSel(event):
    22002230        brav = bravSel.GetString(bravSel.GetSelection())
     
    22732303        peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List'))[0]
    22742304        limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]
    2275         controls,bravais,cells,dmin = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
     2305        controls,bravais,cells,dmin,ssopt = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
    22762306        cell = controls[6:12]
    22772307        A = G2lat.cell2A(cell)
     
    23432373            return       
    23442374        print 'Refine cell'
    2345         controls,bravais,cells,dmin = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
     2375        controls,bravais,cells,dmin,ssopt = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
    23462376        cell = controls[6:12]
    23472377        A = G2lat.cell2A(cell)
     
    23822412        keepcells = []
    23832413        try:
    2384             controls,bravais,cells,dmin = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
     2414            controls,bravais,cells,dmin,ssopt = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
    23852415            for cell in cells:
    23862416                if cell[11]:
     
    24012431        cells[0][10] = True
    24022432        if OK:
    2403             data = [controls,bravais,cells,dmin]
     2433            data = [controls,bravais,cells,dmin,ssopt]
    24042434            G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'),data)
    24052435            bestCell = cells[0]
     
    24822512    G2frame.Bind(wx.EVT_MENU, MakeNewPhase, id=G2gd.wxID_MAKENEWPHASE)
    24832513   
    2484     controls,bravais,cells,dmin = data
     2514    controls,bravais,cells,dmin,ssopt = data
    24852515    if len(controls) < 13:              #add cell volume if missing
    24862516        controls.append(G2lat.calc_V(G2lat.cell2A(controls[6:12])))
     
    25722602    zeroVar.Bind(wx.EVT_CHECKBOX,OnZeroVar)
    25732603    littleSizer.Add(zeroVar,0,WACV)
     2604    SSopt = wx.CheckBox(G2frame.dataDisplay,label="Super lattice?")
     2605    SSopt.SetValue(ssopt['Use'])
     2606    SSopt.Bind(wx.EVT_CHECKBOX,OnSSopt)
     2607    littleSizer.Add(SSopt,0,WACV)
    25742608    hklShow = wx.Button(G2frame.dataDisplay,label="Show hkl positions")
    25752609    hklShow.Bind(wx.EVT_BUTTON,OnHklShow)
    25762610    littleSizer.Add(hklShow,0,WACV)
    2577     #Add super lattice option here
    25782611    mainSizer.Add(littleSizer,0)
    25792612   
     
    26082641            littleSizer.Add(volVal,0,WACV)
    26092642    mainSizer.Add(littleSizer,0)
     2643#ssopt = {'Use':False,'ModVec':[0,0,0.1],'maxH':1,'ssSymb':''})
     2644    if ssopt['Use']:
     2645        indChoice = ['1','2','3','4',]
     2646        SpSg = controls[13]
     2647        ssChoice = G2spc.ssdict[SpSg]
     2648        if ssopt['ssSymb'] not in ssChoice:
     2649            ssopt['ssSymb'] = ssChoice[0]
     2650        ssSizer = wx.BoxSizer(wx.HORIZONTAL)
     2651        ssSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Supersymmetry space group: '+SpSg+' '),0,WACV)
     2652        selMG = wx.ComboBox(G2frame.dataDisplay,value=ssopt['ssSymb'],
     2653                choices=ssChoice,style=wx.CB_READONLY|wx.CB_DROPDOWN)
     2654        selMG.Bind(wx.EVT_COMBOBOX, OnSelMG)
     2655        ssSizer.Add(selMG,0,WACV)
     2656        modS = G2spc.splitSSsym(ssopt['ssSymb'])[0]
     2657        Vec = ssopt['ModVec']
     2658        Vec,ifShow = G2spc.SSGModCheck(Vec,modS)
     2659        modList = []
     2660        modDict = {}
     2661        for val,show in zip(Vec,ifShow):
     2662            if show:
     2663                valSizer = wx.BoxSizer(wx.HORIZONTAL)
     2664                modVal = wx.TextCtrl(G2frame.dataDisplay,value=('%.3f'%(val)),style=wx.TE_PROCESS_ENTER)
     2665                modVal.Bind(wx.EVT_TEXT_ENTER,OnModVal)       
     2666                modVal.Bind(wx.EVT_KILL_FOCUS,OnModVal)
     2667                valSizer.Add(modVal,0,WACV)
     2668                modSpin = wx.SpinButton(G2frame.dataDisplay,style=wx.SP_VERTICAL,size=wx.Size(20,20))
     2669                modSpin.SetValue(0)
     2670                modSpin.SetRange(-1,1)
     2671                modSpin.Bind(wx.EVT_SPIN, OnMoveMod)
     2672                valSizer.Add(modSpin,0,WACV)
     2673                ssSizer.Add(valSizer,0,WACV)
     2674                modList.append(modVal.GetId())
     2675                modList.append(modSpin.GetId())
     2676                modDict[modSpin.GetId()] = modVal
     2677
     2678       
     2679       
     2680        mainSizer.Add(ssSizer,0)
    26102681    #if super lattice add super lattice choice based on space group & modulation values
    26112682    #based on super lattice choice - do refl gen following these choices as above
Note: See TracChangeset for help on using the changeset viewer.