Changeset 4910 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
May 20, 2021 11:19:53 AM (8 months ago)
Author:
vondreele
Message:

Add Wilson statistics to Reflection list menu - computes Wilson plot, <E2-1>, etc. Useful for detecting twins, inversion symmetry, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r4862 r4910  
    5858if '2' in platform.python_version_tuple()[0]:
    5959    GkDelta = unichr(0x0394)
     60    GkSigma = unichr(0x03a3)
     61    GkTheta = unichr(0x03f4)
     62    Gklambda = unichr(0x03bb)
    6063    Pwr10 = unichr(0x0b9)+unichr(0x2070)
    6164    Pwr20 = unichr(0x0b2)+unichr(0x2070)
     
    6871else:
    6972    GkDelta = chr(0x0394)
     73    GkSigma = chr(0x03a3)
     74    GkTheta = chr(0x03f4)
     75    Gklambda = chr(0x03bb)
    7076    Pwr10 = chr(0x0b9)+chr(0x2070)
    7177    Pwr20 = chr(0x0b2)+chr(0x2070)
     
    7480    Pwrm6 = chr(0x207b)+chr(0x2076)
    7581    Pwrm4 = chr(0x207b)+chr(0x2074)
    76     Angstr = chr(0x00c5)   
     82    Angstr = chr(0x00c5)
    7783    superMinusOne = chr(0xaf)+chr(0xb9)
    7884# trig functions in degrees
     
    48294835        G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName)
    48304836       
     4837    def OnWilsonStat(event):
     4838        ''' Show Wilson plot for PWDR and HKLF & return Wilson statistics <<E>, <E^2> & <E^2-1> to console
     4839        '''
     4840        phaseName = G2frame.RefList
     4841        if phaseName not in ['Unknown',]:
     4842            pId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Phases')
     4843            phaseId =  G2gd.GetGPXtreeItemId(G2frame,pId,phaseName)
     4844            General = G2frame.GPXtree.GetItemPyData(phaseId)['General']
     4845            Super = General.get('Super',0)
     4846        else:
     4847            Super = 0
     4848        if 'list' in str(type(data)):   #single crystal data is 2 dict in list
     4849            refList = data[1]['RefList']
     4850        else:                           #powder data is a dict of dicts; each same structure as SC 2nd dict
     4851            if 'RefList' in data[phaseName]:
     4852                refList = np.array(data[phaseName]['RefList'])
     4853            else:
     4854                wx.MessageBox('No reflection list - do Refine first',caption='Reflection plotting')
     4855                return
     4856       
     4857        PE = G2elemGUI.PickElement(G2frame,ifNone=False)
     4858        if PE.ShowModal() == wx.ID_OK:
     4859            normEle = PE.Elem.strip()
     4860        PE.Destroy()
     4861        Estat,Ehist = G2mth.DoWilsonStat(refList,Super,normEle,Inst)
     4862        print(' Wilson statistics   : <|E|>: %.3f, <|E^2|>: %.3f, <|E^2-1|>: %.3f'%(Estat[0]/Estat[1],1.,Estat[2]/Estat[1]))
     4863        print(' Expected: random P-1: <|E|>: 0.798, <|E^2|>: 1.000, <|E^2-1|>: 0.968')
     4864        print('           random P1 : <|E|>: 0.886, <|E^2|>: 1.000, <|E^2-1|>: 0.736')
     4865        XY = [[Ehist[0],Ehist[1]],[Ehist[0],Ehist[2]]]
     4866        G2plt.PlotXY(G2frame,XY,labelX='sin$^2$%s/%s$^2$'%(GkTheta,Gklambda),
     4867            labelY=r'ln(<|F$_o$|$^2$>/%sf$^2$)'%GkSigma,newPlot=True,Title='Wilson plot')
     4868       
     4869       
    48314870    def MakeReflectionTable(phaseName):
    48324871        '''Returns a wx.grid table (G2G.Table) containing a list of all reflections
     
    50205059        G2frame.Bind(wx.EVT_MENU, OnPlot1DHKL, id=G2G.wxID_1DHKLSTICKPLOT)
    50215060        G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
     5061        G2frame.Bind(wx.EVT_MENU, OnWilsonStat, id=G2G.wxID_WILSONSTAT)
    50225062        G2frame.Bind(wx.EVT_MENU, OnToggleExt, id=G2G.wxID_SHOWHIDEEXTINCT)
    50235063        G2frame.dataWindow.SelectPhase.Enable(False)
     
    50275067        G2frame.Bind(wx.EVT_MENU, OnPlotHKL, id=G2G.wxID_PWDHKLPLOT)
    50285068        G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
     5069        G2frame.Bind(wx.EVT_MENU, OnWilsonStat, id=G2G.wxID_WILSONSTAT)
    50295070        G2frame.dataWindow.SelectPhase.Enable(False)
    50305071           
Note: See TracChangeset for help on using the changeset viewer.