Ignore:
Timestamp:
Jun 4, 2015 1:49:58 PM (8 years ago)
Author:
vondreele
Message:

refactor DDataGUI - mostly move event routines to be inside respective sizer routines
Enable Flack parameter - function OK; derivatives need work
Allow inversion of noncentrosymmetric structures in SymOpDialog? - to test enantiomers
some work to make pdf stuff neutron TOF friendly - not complete
fix Debye background function - now works; refactor result printing for it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r1875 r1878  
    153153        return scaleSizer
    154154       
    155     def OnUseData(event):
    156         Obj = event.GetEventObject()
    157         UseList[G2frame.hist]['Use'] = Obj.GetValue()
    158        
    159155    def OnLGmixRef(event):
    160156        Obj = event.GetEventObject()
     
    212208        G2plt.PlotSizeStrainPO(G2frame,data,hist)
    213209       
    214     def OnSizeAxis(event):           
    215         Obj = event.GetEventObject()
    216         Saxis = Obj.GetValue().split()
    217         try:
    218             hkl = [int(Saxis[i]) for i in range(3)]
    219         except (ValueError,IndexError):
    220             hkl = UseList[G2frame.hist]['Size'][3]
    221         if not np.any(np.array(hkl)):
    222             hkl = UseList[G2frame.hist]['Size'][3]
    223         UseList[G2frame.hist]['Size'][3] = hkl
    224         h,k,l = hkl
    225         Obj.SetValue('%3d %3d %3d'%(h,k,l))
    226                    
    227     def OnResetSize(event):
    228         Obj = event.GetEventObject()
    229         Obj.SetValue(False)
    230         item,name = Indx[Obj.GetId()]
    231         if name == 'isotropic':
    232             UseList[item]['Size'][1][0] = 1.0
    233         elif name == 'uniaxial':
    234             UseList[item]['Size'][1][0] = 1.0
    235             UseList[item]['Size'][1][1] = 1.0
    236         elif name == 'ellipsoidal':
    237             for i in range(3):
    238                 UseList[item]['Size'][4][i] = 1.0
    239                 UseList[item]['Size'][4][i+3] = 0.0
    240         G2plt.PlotSizeStrainPO(G2frame,data,item)
    241         wx.CallLater(100,RepaintHistogramInfo)
    242            
    243210    def OnStrainType(event):
    244211        Obj = event.GetEventObject()
     
    377344        return newPOCoef
    378345       
    379     def OnExtRef(event):
    380         Obj = event.GetEventObject()
    381         UseList[G2frame.hist]['Extinction'][1] = Obj.GetValue()
    382        
    383     def OnExtVal(event):
    384         Obj = event.GetEventObject()
    385         try:
    386             ext = float(Obj.GetValue())
    387             if ext >= 0:
    388                 UseList[G2frame.hist]['Extinction'][0] = ext
    389         except ValueError:
    390             pass
    391         Obj.SetValue("%.2f"%(UseList[G2frame.hist]['Extinction'][0]))
    392 
    393     def OnBabRef(event):
    394         Obj = event.GetEventObject()
    395         item,bab = Indx[Obj.GetId()]
    396         UseList[item]['Babinet']['Bab'+bab][1] = Obj.GetValue()
    397        
    398     def OnFlackRef(event):
    399         Obj = event.GetEventObject()
    400         UseList[G2frame.hist]['Flack'][1] = Obj.GetValue()
    401        
    402     def OnBabVal(event):
    403         Obj = event.GetEventObject()
    404         item,bab = Indx[Obj.GetId()]
    405         try:
    406             val = float(Obj.GetValue())
    407             if val >= 0:
    408                 UseList[item]['Babinet']['Bab'+bab][0] = val
    409         except ValueError:
    410             pass
    411         Obj.SetValue("%.3f"%(UseList[item]['Babinet']['Bab'+bab][0]))
    412        
    413     def OnFlackVal(event):
    414         Obj = event.GetEventObject()
    415         try:
    416             flack = float(Obj.GetValue())
    417             UseList[G2frame.hist]['Flack'][0] = flack
    418         except ValueError:
    419             pass
    420         Obj.SetValue("%.3f"%(UseList[G2frame.hist]['Flack'][0]))
    421 
    422     def OnTbarVal(event):
    423         Obj = event.GetEventObject()
    424         try:
    425             tbar = float(Obj.GetValue())
    426             if tbar > 0:
    427                 UseList[G2frame.hist]['Extinction'][2]['Tbar'] = tbar
    428         except ValueError:
    429             pass
    430         Obj.SetValue("%.3f"%(UseList[G2frame.hist]['Extinction'][2]['Tbar']))
    431 
    432     def OnCos2TM(event):
    433         Obj = event.GetEventObject()
    434         try:
    435             val = float(Obj.GetValue())
    436             if 0. < val <= 1.:
    437                 UseList[G2frame.hist]['Extinction'][2]['Cos2TM'] = val
    438         except ValueError:
    439             pass
    440         Obj.SetValue("%.3f"%(UseList[G2frame.hist]['Extinction'][2]['Cos2TM']))
    441        
    442     def OnEval(event):
    443         Obj = event.GetEventObject()
    444         item = Indx[Obj.GetId()]
    445         try:
    446             val = float(Obj.GetValue())
    447             if val > 0:
    448                 UseList[item[0]]['Extinction'][2][item[1]][0] = val
    449         except ValueError:
    450             pass
    451         Obj.SetValue("%10.3e"%(UseList[item[0]]['Extinction'][2][item[1]][0]))
    452        
    453     def OnEref(event):
    454         Obj = event.GetEventObject()
    455         item = Indx[Obj.GetId()]
    456         UseList[item[0]]['Extinction'][2][item[1]][1] = Obj.GetValue()
    457 
    458     def OnSCExtType(event):
    459         Obj = event.GetEventObject()
    460         item = Indx[Obj.GetId()]
    461         UseList[item[0]]['Extinction'][item[1]] = Obj.GetValue()
    462         wx.CallLater(100,RepaintHistogramInfo)
    463            
    464346    def checkAxis(axis):
    465347        if not np.any(np.array(axis)):
     
    710592        return shPenalty   
    711593       
    712     def ExtSizer():           
    713         extSizer = wx.BoxSizer(wx.HORIZONTAL)
    714         extRef = wx.CheckBox(DData,wx.ID_ANY,label=' Extinction: ')
    715         extRef.SetValue(UseList[G2frame.hist]['Extinction'][1])
    716         extRef.Bind(wx.EVT_CHECKBOX, OnExtRef)
    717         extSizer.Add(extRef,0,WACV|wx.LEFT,5)
    718         extVal = wx.TextCtrl(DData,wx.ID_ANY,
    719             '%.2f'%(UseList[G2frame.hist]['Extinction'][0]),style=wx.TE_PROCESS_ENTER)
    720         extVal.Bind(wx.EVT_TEXT_ENTER,OnExtVal)
    721         extVal.Bind(wx.EVT_KILL_FOCUS,OnExtVal)
    722         extSizer.Add(extVal,0,WACV)
     594    def ExtSizer(Type):
     595       
     596        def OnSCExtType(event):
     597            Obj = event.GetEventObject()
     598            item = Indx[Obj.GetId()]
     599            UseList[item[0]]['Extinction'][item[1]] = Obj.GetValue()
     600            wx.CallLater(100,RepaintHistogramInfo)
     601               
     602        def OnTbarVal(event):
     603            Obj = event.GetEventObject()
     604            try:
     605                tbar = float(Obj.GetValue())
     606                if tbar > 0:
     607                    UseList[G2frame.hist]['Extinction'][2]['Tbar'] = tbar
     608            except ValueError:
     609                pass
     610            Obj.SetValue("%.3f"%(UseList[G2frame.hist]['Extinction'][2]['Tbar']))
     611   
     612        def OnCos2TM(event):
     613            Obj = event.GetEventObject()
     614            try:
     615                val = float(Obj.GetValue())
     616                if 0. < val <= 1.:
     617                    UseList[G2frame.hist]['Extinction'][2]['Cos2TM'] = val
     618            except ValueError:
     619                pass
     620            Obj.SetValue("%.3f"%(UseList[G2frame.hist]['Extinction'][2]['Cos2TM']))
     621       
     622        def OnEval(event):
     623            Obj = event.GetEventObject()
     624            item = Indx[Obj.GetId()]
     625            try:
     626                val = float(Obj.GetValue())
     627                if val > 0:
     628                    UseList[item[0]]['Extinction'][2][item[1]][0] = val
     629            except ValueError:
     630                pass
     631            Obj.SetValue("%10.3e"%(UseList[item[0]]['Extinction'][2][item[1]][0]))
     632       
     633        def OnEref(event):
     634            Obj = event.GetEventObject()
     635            item = Indx[Obj.GetId()]
     636            UseList[item[0]]['Extinction'][2][item[1]][1] = Obj.GetValue()
     637   
     638        def OnExtRef(event):
     639            Obj = event.GetEventObject()
     640            UseList[G2frame.hist]['Extinction'][1] = Obj.GetValue()
     641           
     642        def OnExtVal(event):
     643            Obj = event.GetEventObject()
     644            try:
     645                ext = float(Obj.GetValue())
     646                if ext >= 0:
     647                    UseList[G2frame.hist]['Extinction'][0] = ext
     648            except ValueError:
     649                pass
     650            Obj.SetValue("%.2f"%(UseList[G2frame.hist]['Extinction'][0]))
     651
     652        extSizer = wx.BoxSizer(wx.VERTICAL)
     653        if Type == 'HKLF':
     654            typeSizer = wx.BoxSizer(wx.HORIZONTAL)           
     655            typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Extinction type: '),0,WACV)
     656            Choices = ['None','Primary','Secondary Type I','Secondary Type II',]    # remove 'Secondary Type I & II'
     657            typeTxt = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][1],
     658                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     659            Indx[typeTxt.GetId()] = [G2frame.hist,1]
     660            typeTxt.Bind(wx.EVT_COMBOBOX,OnSCExtType)
     661            typeSizer.Add(typeTxt)
     662            typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Approx: '),0,WACV)
     663            Choices=['Lorentzian','Gaussian']
     664            approxTxT = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][0],
     665                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     666            Indx[approxTxT.GetId()] = [G2frame.hist,0]
     667            approxTxT.Bind(wx.EVT_COMBOBOX,OnSCExtType)
     668            typeSizer.Add(approxTxT)
     669            if UseList[G2frame.hist]['Extinction'][1] == 'None':
     670                extSizer.Add(typeSizer,0,WACV)
     671            else:
     672                extSizer.Add(typeSizer,0,WACV|wx.BOTTOM,5)       
     673                if 'Tbar' in UseList[G2frame.hist]['Extinction'][2]:       #skipped for TOF   
     674                    valSizer =wx.BoxSizer(wx.HORIZONTAL)
     675                    valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Tbar(mm):'),0,WACV)
     676                    tbarVal = wx.TextCtrl(DData,wx.ID_ANY,
     677                        '%.3f'%(UseList[G2frame.hist]['Extinction'][2]['Tbar']),style=wx.TE_PROCESS_ENTER)
     678                    tbarVal.Bind(wx.EVT_TEXT_ENTER,OnTbarVal)
     679                    tbarVal.Bind(wx.EVT_KILL_FOCUS,OnTbarVal)
     680                    valSizer.Add(tbarVal,0,WACV)
     681                    valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' cos(2ThM):'),0,WACV)
     682                    cos2tm = wx.TextCtrl(DData,wx.ID_ANY,
     683                        '%.3f'%(UseList[G2frame.hist]['Extinction'][2]['Cos2TM']),style=wx.TE_PROCESS_ENTER)
     684                    cos2tm.Bind(wx.EVT_TEXT_ENTER,OnCos2TM)
     685                    cos2tm.Bind(wx.EVT_KILL_FOCUS,OnCos2TM)
     686                    valSizer.Add(cos2tm,0,WACV)
     687                    extSizer.Add(valSizer,0,WACV)
     688                val2Sizer =wx.BoxSizer(wx.HORIZONTAL)
     689                if 'Primary' in UseList[G2frame.hist]['Extinction'][1]:
     690                    Ekey = ['Ep',]
     691                elif 'Secondary Type II' == UseList[G2frame.hist]['Extinction'][1]:
     692                    Ekey = ['Es',]
     693                elif 'Secondary Type I' == UseList[G2frame.hist]['Extinction'][1]:
     694                    Ekey = ['Eg',]
     695                else:
     696                    Ekey = ['Eg','Es']
     697                for ekey in Ekey:
     698                    Eref = wx.CheckBox(DData,wx.ID_ANY,label=ekey+' : ')
     699                    Eref.SetValue(UseList[G2frame.hist]['Extinction'][2][ekey][1])
     700                    Indx[Eref.GetId()] = [G2frame.hist,ekey]
     701                    Eref.Bind(wx.EVT_CHECKBOX, OnEref)
     702                    val2Sizer.Add(Eref,0,WACV|wx.LEFT,5)
     703                    Eval = wx.TextCtrl(DData,wx.ID_ANY,
     704                        '%10.3e'%(UseList[G2frame.hist]['Extinction'][2][ekey][0]),style=wx.TE_PROCESS_ENTER)
     705                    Indx[Eval.GetId()] = [G2frame.hist,ekey]
     706                    Eval.Bind(wx.EVT_TEXT_ENTER,OnEval)
     707                    Eval.Bind(wx.EVT_KILL_FOCUS,OnEval)
     708                    val2Sizer.Add(Eval,0,WACV)
     709                extSizer.Add(val2Sizer,0,WACV)
     710        else:   #PWDR
     711            extRef = wx.CheckBox(DData,wx.ID_ANY,label=' Extinction: ')
     712            extRef.SetValue(UseList[G2frame.hist]['Extinction'][1])
     713            extRef.Bind(wx.EVT_CHECKBOX, OnExtRef)
     714            extSizer.Add(extRef,0,WACV|wx.LEFT,5)
     715            extVal = wx.TextCtrl(DData,wx.ID_ANY,
     716                '%.2f'%(UseList[G2frame.hist]['Extinction'][0]),style=wx.TE_PROCESS_ENTER)
     717            extVal.Bind(wx.EVT_TEXT_ENTER,OnExtVal)
     718            extVal.Bind(wx.EVT_KILL_FOCUS,OnExtVal)
     719            extSizer.Add(extVal,0,WACV)
     720
    723721        return extSizer
    724    
    725     def SCExtSizer():
    726         extSizer = wx.BoxSizer(wx.VERTICAL)
    727         typeSizer = wx.BoxSizer(wx.HORIZONTAL)           
    728         typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Extinction type: '),0,WACV)
    729         Choices = ['None','Primary','Secondary Type I','Secondary Type II',]    # remove 'Secondary Type I & II'
    730         typeTxt = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][1],
    731             style=wx.CB_READONLY|wx.CB_DROPDOWN)
    732         Indx[typeTxt.GetId()] = [G2frame.hist,1]
    733         typeTxt.Bind(wx.EVT_COMBOBOX,OnSCExtType)
    734         typeSizer.Add(typeTxt)
    735         typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Approx: '),0,WACV)
    736         Choices=['Lorentzian','Gaussian']
    737         approxTxT = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][0],
    738             style=wx.CB_READONLY|wx.CB_DROPDOWN)
    739         Indx[approxTxT.GetId()] = [G2frame.hist,0]
    740         approxTxT.Bind(wx.EVT_COMBOBOX,OnSCExtType)
    741         typeSizer.Add(approxTxT)
    742         if UseList[G2frame.hist]['Extinction'][1] == 'None':
    743             extSizer.Add(typeSizer,0,WACV)
    744         else:
    745             extSizer.Add(typeSizer,0,WACV|wx.BOTTOM,5)       
    746             if 'Tbar' in UseList[G2frame.hist]['Extinction'][2]:       #skipped for TOF   
    747                 valSizer =wx.BoxSizer(wx.HORIZONTAL)
    748                 valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Tbar(mm):'),0,WACV)
    749                 tbarVal = wx.TextCtrl(DData,wx.ID_ANY,
    750                     '%.3f'%(UseList[G2frame.hist]['Extinction'][2]['Tbar']),style=wx.TE_PROCESS_ENTER)
    751                 tbarVal.Bind(wx.EVT_TEXT_ENTER,OnTbarVal)
    752                 tbarVal.Bind(wx.EVT_KILL_FOCUS,OnTbarVal)
    753                 valSizer.Add(tbarVal,0,WACV)
    754                 valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' cos(2ThM):'),0,WACV)
    755                 cos2tm = wx.TextCtrl(DData,wx.ID_ANY,
    756                     '%.3f'%(UseList[G2frame.hist]['Extinction'][2]['Cos2TM']),style=wx.TE_PROCESS_ENTER)
    757                 cos2tm.Bind(wx.EVT_TEXT_ENTER,OnCos2TM)
    758                 cos2tm.Bind(wx.EVT_KILL_FOCUS,OnCos2TM)
    759                 valSizer.Add(cos2tm,0,WACV)
    760                 extSizer.Add(valSizer,0,WACV)
    761             val2Sizer =wx.BoxSizer(wx.HORIZONTAL)
    762             if 'Primary' in UseList[G2frame.hist]['Extinction'][1]:
    763                 Ekey = ['Ep',]
    764             elif 'Secondary Type II' == UseList[G2frame.hist]['Extinction'][1]:
    765                 Ekey = ['Es',]
    766             elif 'Secondary Type I' == UseList[G2frame.hist]['Extinction'][1]:
    767                 Ekey = ['Eg',]
    768             else:
    769                 Ekey = ['Eg','Es']
    770             for ekey in Ekey:
    771                 Eref = wx.CheckBox(DData,wx.ID_ANY,label=ekey+' : ')
    772                 Eref.SetValue(UseList[G2frame.hist]['Extinction'][2][ekey][1])
    773                 Indx[Eref.GetId()] = [G2frame.hist,ekey]
    774                 Eref.Bind(wx.EVT_CHECKBOX, OnEref)
    775                 val2Sizer.Add(Eref,0,WACV|wx.LEFT,5)
    776                 Eval = wx.TextCtrl(DData,wx.ID_ANY,
    777                     '%10.3e'%(UseList[G2frame.hist]['Extinction'][2][ekey][0]),style=wx.TE_PROCESS_ENTER)
    778                 Indx[Eval.GetId()] = [G2frame.hist,ekey]
    779                 Eval.Bind(wx.EVT_TEXT_ENTER,OnEval)
    780                 Eval.Bind(wx.EVT_KILL_FOCUS,OnEval)
    781                 val2Sizer.Add(Eval,0,WACV)
    782 
    783             extSizer.Add(val2Sizer,0,WACV)
    784         return extSizer
    785722       
    786723    def BabSizer():
     724       
     725        def OnBabVal(event):
     726            Obj = event.GetEventObject()
     727            item,bab = Indx[Obj.GetId()]
     728            try:
     729                val = float(Obj.GetValue())
     730                if val >= 0:
     731                    UseList[item]['Babinet']['Bab'+bab][0] = val
     732            except ValueError:
     733                pass
     734            Obj.SetValue("%.3f"%(UseList[item]['Babinet']['Bab'+bab][0]))
     735       
     736        def OnBabRef(event):
     737            Obj = event.GetEventObject()
     738            item,bab = Indx[Obj.GetId()]
     739            UseList[item]['Babinet']['Bab'+bab][1] = Obj.GetValue()
     740       
    787741        babSizer = wx.BoxSizer(wx.HORIZONTAL)
    788742        for bab in ['A','U']:
     
    801755       
    802756    def FlackSizer():
     757       
     758        def OnFlackVal(event):
     759            Obj = event.GetEventObject()
     760            try:
     761                flack = float(Obj.GetValue())
     762                UseList[G2frame.hist]['Flack'][0] = flack
     763            except ValueError:
     764                pass
     765            Obj.SetValue("%.3f"%(UseList[G2frame.hist]['Flack'][0]))
     766
     767        def OnFlackRef(event):
     768            Obj = event.GetEventObject()
     769            UseList[G2frame.hist]['Flack'][1] = Obj.GetValue()
     770               
    803771        flackSizer = wx.BoxSizer(wx.HORIZONTAL)
    804772        flackRef = wx.CheckBox(DData,wx.ID_ANY,label=' Flack parameter: ')
     
    831799       
    832800    def ShowHistogramInfo():
     801       
     802        def OnUseData(event):
     803            Obj = event.GetEventObject()
     804            UseList[G2frame.hist]['Use'] = Obj.GetValue()
     805       
     806        def OnResetSize(event):
     807            Obj = event.GetEventObject()
     808            Obj.SetValue(False)
     809            item,name = Indx[Obj.GetId()]
     810            if name == 'isotropic':
     811                UseList[item]['Size'][1][0] = 1.0
     812            elif name == 'uniaxial':
     813                UseList[item]['Size'][1][0] = 1.0
     814                UseList[item]['Size'][1][1] = 1.0
     815            elif name == 'ellipsoidal':
     816                for i in range(3):
     817                    UseList[item]['Size'][4][i] = 1.0
     818                    UseList[item]['Size'][4][i+3] = 0.0
     819            G2plt.PlotSizeStrainPO(G2frame,data,item)
     820            wx.CallLater(100,RepaintHistogramInfo)
     821           
     822        def OnSizeAxis(event):           
     823            Obj = event.GetEventObject()
     824            Saxis = Obj.GetValue().split()
     825            try:
     826                hkl = [int(Saxis[i]) for i in range(3)]
     827            except (ValueError,IndexError):
     828                hkl = UseList[G2frame.hist]['Size'][3]
     829            if not np.any(np.array(hkl)):
     830                hkl = UseList[G2frame.hist]['Size'][3]
     831            UseList[G2frame.hist]['Size'][3] = hkl
     832            h,k,l = hkl
     833            Obj.SetValue('%3d %3d %3d'%(h,k,l))
     834                       
    833835        try:
    834836            histData = UseList[G2frame.hist]
     
    930932                   
    931933            bottomSizer.Add(poSizer,0,WACV|wx.TOP|wx.BOTTOM,5)
    932             bottomSizer.Add(ExtSizer(),0,WACV|wx.TOP|wx.BOTTOM,5)
     934            bottomSizer.Add(ExtSizer('PWDR'),0,WACV|wx.TOP|wx.BOTTOM,5)
    933935            bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
    934936        elif G2frame.hist[:4] == 'HKLF':
     
    937939                UseList[G2frame.hist]['Flack'] = [0.0,False]
    938940#end patch
    939             bottomSizer.Add(SCExtSizer(),0,WACV|wx.BOTTOM,5)
     941            bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5)
    940942            bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
    941 #            if not SGData['SGInv']:        #not operational yet - no test data
    942 #                bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5)
     943            if not SGData['SGInv']:        #not operational yet - no test data
     944                bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5)
    943945        return bottomSizer
    944946               
Note: See TracChangeset for help on using the changeset viewer.