source: branch/2frame/GSASIIddataGUI.py @ 2931

Last change on this file since 2931 was 2931, checked in by vondreele, 6 years ago

remove duplicate code from G2dataGUI lines 5922-3; same thing is done on next line
Add a selectuse option for sequential results table - Use column no longer editable.
Use selects plottable points for seq results plots.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 46.8 KB
Line 
1# -*- coding: utf-8 -*-
2#GSASII - phase data display routines
3########### SVN repository information ###################
4# $Date: 2017-07-13 18:08:24 +0000 (Thu, 13 Jul 2017) $
5# $Author: vondreele $
6# $Revision: 2931 $
7# $URL: branch/2frame/GSASIIddataGUI.py $
8# $Id: GSASIIddataGUI.py 2931 2017-07-13 18:08:24Z vondreele $
9########### SVN repository information ###################
10'''
11*GSASIIddataGUI: Phase Diffraction Data GUI*
12--------------------------------------------
13
14Module to create the GUI for display of diffraction data * phase
15information that is shown in the data display window
16(when a phase is selected.)
17
18'''
19import wx
20import GSASIIpath
21GSASIIpath.SetVersionNumber("$Revision: 2931 $")
22import GSASIIlattice as G2lat
23import GSASIIspc as G2spc
24import GSASIIplot as G2plt
25import GSASIIpwd as G2pwd
26import GSASIIphsGUI as G2phsGUI
27import GSASIIctrlGUI as G2G
28import numpy as np
29
30WACV = wx.ALIGN_CENTER_VERTICAL
31VERY_LIGHT_GREY = wx.Colour(235,235,235)
32WHITE = wx.Colour(255,255,255)
33BLACK = wx.Colour(0,0,0)
34mapDefault = {'MapType':'','RefList':'','Resolution':0.5,'Show bonds':True,
35                'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False}
36
37################################################################################
38##### DData routines
39################################################################################       
40def UpdateDData(G2frame,DData,data,hist='',Scroll=0):
41    '''Display the Diffraction Data associated with a phase
42    (items where there is a value for each histogram and phase)
43
44    :param wx.frame G2frame: the main GSAS-II frame object
45    :param wx.ScrolledWindow DData: notebook page to be used for the display
46    :param dict data: all the information on the phase in a dictionary
47    :param str hist: histogram name
48    :param int Scroll: previous scroll position
49
50    '''
51    def PlotSizer():
52
53        def OnPlotSel(event):
54            Obj = event.GetEventObject()
55            generalData['Data plot type'] = Obj.GetStringSelection()
56            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
57            wx.CallLater(100,UpdateDData,G2frame,DData,data,G2frame.hist)
58           
59        def OnPOhkl(event):
60            event.Skip()
61            Obj = event.GetEventObject()
62            Saxis = Obj.GetValue().split()
63            try:
64                hkl = [int(Saxis[i]) for i in range(3)]
65            except (ValueError,IndexError):
66                hkl = generalData['POhkl']
67            if not np.any(np.array(hkl)):
68                hkl = generalData['POhkl']
69            generalData['POhkl'] = hkl
70            h,k,l = hkl
71            Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
72            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
73       
74        plotSizer = wx.BoxSizer(wx.VERTICAL)
75        choice = ['None','Mustrain','Size','Preferred orientation','Inv. pole figure']
76        plotSel = wx.RadioBox(DData,wx.ID_ANY,'Select plot type:',choices=choice,
77            majorDimension=1,style=wx.RA_SPECIFY_COLS)
78        plotSel.SetStringSelection(generalData['Data plot type'])
79        plotSel.Bind(wx.EVT_RADIOBOX,OnPlotSel)   
80        plotSizer.Add(plotSel)
81        if generalData['Data plot type'] == 'Preferred orientation':
82            POhklSizer = wx.BoxSizer(wx.HORIZONTAL)
83            POhklSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Plot preferred orientation for H K L: '),0,WACV)
84            h,k,l = generalData['POhkl']
85            poAxis = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(h,k,l),style=wx.TE_PROCESS_ENTER)
86            poAxis.Bind(wx.EVT_TEXT_ENTER,OnPOhkl)
87            poAxis.Bind(wx.EVT_KILL_FOCUS,OnPOhkl)
88            POhklSizer.Add(poAxis,0,WACV)
89            plotSizer.Add(POhklSizer)
90        elif generalData['Data plot type'] == 'Inv. pole figure':
91            pass    #might need something here?     
92        return plotSizer
93       
94    def ScaleSizer():
95       
96        def OnScaleRef(event):
97            Obj = event.GetEventObject()
98            UseList[G2frame.hist]['Scale'][1] = Obj.GetValue()
99           
100        scaleSizer = wx.BoxSizer(wx.HORIZONTAL)
101        if 'PWDR' in G2frame.hist:
102            scaleRef = wx.CheckBox(DData,wx.ID_ANY,label=' Phase fraction: ')
103        elif 'HKLF' in G2frame.hist:
104            scaleRef = wx.CheckBox(DData,wx.ID_ANY,label=' Scale factor: ')               
105        scaleRef.SetValue(UseList[G2frame.hist]['Scale'][1])
106        scaleRef.Bind(wx.EVT_CHECKBOX, OnScaleRef)
107        scaleSizer.Add(scaleRef,0,WACV|wx.LEFT,5)
108        scaleVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Scale'],0,
109            min=0.,nDig=(10,4),typeHint=float)
110        scaleSizer.Add(scaleVal,0,WACV)
111        if 'PWDR' in G2frame.hist and generalData['Type'] != 'magnetic':
112            wtSum = G2pwd.PhaseWtSum(G2frame,G2frame.hist)
113            weightFr = UseList[G2frame.hist]['Scale'][0]*generalData['Mass']/wtSum
114            scaleSizer.Add(wx.StaticText(DData,label=' Wt. fraction: %.3f'%(weightFr)),0,WACV)
115        return scaleSizer
116       
117    def OnLGmixRef(event):
118        Obj = event.GetEventObject()
119        hist,name = Indx[Obj.GetId()]
120        UseList[G2frame.hist][name][2][2] = Obj.GetValue()
121       
122    def OnLGmixVal(event):
123        event.Skip()
124        Obj = event.GetEventObject()
125        hist,name = Indx[Obj.GetId()]
126        try:
127            value = float(Obj.GetValue())
128            UseList[G2frame.hist][name][1][2] = value
129#            if 0 <= value <= 1:
130#                UseList[G2frame.hist][name][1][2] = value
131#            else:
132#                raise ValueError
133        except ValueError:
134            pass
135        Obj.SetValue("%.4f"%(UseList[G2frame.hist][name][1][2]))          #reset in case of error
136
137    def OnSizeType(event):
138        Obj = event.GetEventObject()
139        UseList[G2frame.hist]['Size'][0] = Obj.GetValue()
140        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
141        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
142       
143    def OnSizeRef(event):
144        Obj = event.GetEventObject()
145        hist,pid = Indx[Obj.GetId()]
146        if UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
147            UseList[G2frame.hist]['Size'][5][pid] = Obj.GetValue()               
148        else:
149            UseList[G2frame.hist]['Size'][2][pid] = Obj.GetValue()
150       
151    def OnSizeVal(event):
152        event.Skip()
153        Obj = event.GetEventObject()
154        hist,pid = Indx[Obj.GetId()]
155        if UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
156            try:
157                size = float(Obj.GetValue())
158                if pid < 3 and size <= 0.001:            #10A lower limit!
159                    raise ValueError
160                UseList[G2frame.hist]['Size'][4][pid] = size                   
161            except ValueError:
162                pass
163            Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][4][pid]))          #reset in case of error
164        else:
165            try:
166                size = float(Obj.GetValue())
167                if size <= 0.001:            #10A lower limit!
168                    raise ValueError
169                UseList[G2frame.hist]['Size'][1][pid] = size
170            except ValueError:
171                pass
172            Obj.SetValue("%.5f"%(UseList[G2frame.hist]['Size'][1][pid]))          #reset in case of error
173        wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist)
174       
175    def OnStrainType(event):
176        Obj = event.GetEventObject()
177        UseList[G2frame.hist]['Mustrain'][0] = Obj.GetValue()
178        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
179        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
180       
181    def OnStrainRef(event):
182        Obj = event.GetEventObject()
183        hist,pid = Indx[Obj.GetId()]
184        if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
185            UseList[G2frame.hist]['Mustrain'][5][pid] = Obj.GetValue()
186        else:
187            UseList[G2frame.hist]['Mustrain'][2][pid] = Obj.GetValue()
188       
189    def OnStrainVal(event):
190        event.Skip()
191        Snames = G2spc.MustrainNames(SGData)
192        Obj = event.GetEventObject()
193        hist,pid = Indx[Obj.GetId()]
194        try:
195            strain = float(Obj.GetValue())
196            if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
197                if '4' in Snames[pid] and strain < 0:
198                    raise ValueError
199                UseList[G2frame.hist]['Mustrain'][4][pid] = strain
200            else:
201                if strain <= 0:
202                    raise ValueError
203                UseList[G2frame.hist]['Mustrain'][1][pid] = strain
204        except ValueError:
205            pass
206        if UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
207            Obj.SetValue("%.1f"%(UseList[G2frame.hist]['Mustrain'][4][pid]))          #reset in case of error
208        else:
209            Obj.SetValue("%.1f"%(UseList[G2frame.hist]['Mustrain'][1][pid]))          #reset in case of error
210        wx.CallAfter(G2plt.PlotSizeStrainPO,G2frame,data,hist)
211       
212    def OnStrainAxis(event):
213        event.Skip()
214        Obj = event.GetEventObject()
215        Saxis = Obj.GetValue().split()
216        try:
217            hkl = [int(Saxis[i]) for i in range(3)]
218        except (ValueError,IndexError):
219            hkl = UseList[G2frame.hist]['Mustrain'][3]
220        if not np.any(np.array(hkl)):
221            hkl = UseList[G2frame.hist]['Mustrain'][3]
222        UseList[G2frame.hist]['Mustrain'][3] = hkl
223        h,k,l = hkl
224        Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
225        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
226       
227    def OnResetStrain(event):
228        Obj = event.GetEventObject()
229        Obj.SetValue(False)
230        item,name = Indx[Obj.GetId()]
231        if name == 'isotropic':
232            UseList[item]['Mustrain'][1][0] = 1000.0
233        elif name == 'uniaxial':
234            UseList[item]['Mustrain'][1][0] = 1000.0
235            UseList[item]['Mustrain'][1][1] = 1000.0
236        elif name == 'generalized':
237            muiso = 1000.
238            cell = generalData['Cell'][1:7]
239            vals = G2spc.Muiso2Shkl(muiso,SGData,cell)
240            nTerm = len(UseList[item]['Mustrain'][4])
241            for i in range(nTerm):
242                UseList[item]['Mustrain'][4][i] = vals[i]
243        G2plt.PlotSizeStrainPO(G2frame,data,item)
244        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
245           
246    def OnHstrainRef(event):
247        Obj = event.GetEventObject()
248        hist,pid = Indx[Obj.GetId()]
249        UseList[G2frame.hist]['HStrain'][1][pid] = Obj.GetValue()
250       
251    def OnHstrainVal(event):
252        event.Skip()
253        Obj = event.GetEventObject()
254        hist,pid = Indx[Obj.GetId()]
255        try:
256            strain = float(Obj.GetValue())
257            UseList[G2frame.hist]['HStrain'][0][pid] = strain
258        except ValueError:
259            pass
260        Obj.SetValue("%.3g"%(UseList[G2frame.hist]['HStrain'][0][pid]))          #reset in case of error
261
262    def OnPOAxis(event):
263        event.Skip()
264        Obj = event.GetEventObject()
265        Saxis = Obj.GetValue().split()
266        try:
267            hkl = [int(Saxis[i]) for i in range(3)]
268        except (ValueError,IndexError):
269            hkl = UseList[G2frame.hist]['Pref.Ori.'][3]
270        if not np.any(np.array(hkl)):
271            hkl = UseList[G2frame.hist]['Pref.Ori.'][3]
272        UseList[G2frame.hist]['Pref.Ori.'][3] = hkl
273        h,k,l = hkl
274        Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
275       
276    def OnPOOrder(event):
277        Obj = event.GetEventObject()
278        Order = int(Obj.GetValue())
279        UseList[G2frame.hist]['Pref.Ori.'][4] = Order
280        UseList[G2frame.hist]['Pref.Ori.'][5] = SetPOCoef(Order,G2frame.hist)
281        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
282
283    def OnPOType(event):
284        Obj = event.GetEventObject()
285        if 'March' in Obj.GetValue():
286            UseList[G2frame.hist]['Pref.Ori.'][0] = 'MD'
287        else:
288            UseList[G2frame.hist]['Pref.Ori.'][0] = 'SH'
289        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
290
291    def OnPORef(event):
292        Obj = event.GetEventObject()
293        UseList[G2frame.hist]['Pref.Ori.'][2] = Obj.GetValue()
294           
295    def SetPOCoef(Order,hist):
296        cofNames = G2lat.GenSHCoeff(SGData['SGLaue'],'0',Order,False)     #cylindrical & no M
297        newPOCoef = dict(zip(cofNames,np.zeros(len(cofNames))))
298        POCoeff = UseList[G2frame.hist]['Pref.Ori.'][5]
299        for cofName in POCoeff:
300            if cofName in  cofNames:
301                newPOCoef[cofName] = POCoeff[cofName]
302        return newPOCoef
303       
304    def checkAxis(axis):
305        if not np.any(np.array(axis)):
306            return False
307        return axis
308       
309    def TopSizer(name,choices,parm,OnType):
310        topSizer = wx.BoxSizer(wx.HORIZONTAL)
311        topSizer.Add(wx.StaticText(DData,wx.ID_ANY,name),0,WACV)
312        sizeType = wx.ComboBox(DData,wx.ID_ANY,value=UseList[G2frame.hist][parm][0],choices=choices,
313            style=wx.CB_READONLY|wx.CB_DROPDOWN)
314        sizeType.Bind(wx.EVT_COMBOBOX, OnType)
315        topSizer.Add(sizeType,0,WACV|wx.BOTTOM,5)
316        return topSizer
317       
318    def LGmixSizer(name,OnVal,OnRef):
319        lgmixSizer = wx.BoxSizer(wx.HORIZONTAL)
320        lgmixRef = wx.CheckBox(DData,wx.ID_ANY,label='LGmix')
321        lgmixRef.thisown = False
322        lgmixRef.SetValue(UseList[G2frame.hist][name][2][2])
323        Indx[lgmixRef.GetId()] = [G2frame.hist,name]
324        lgmixRef.Bind(wx.EVT_CHECKBOX, OnRef)
325        lgmixSizer.Add(lgmixRef,0,WACV|wx.LEFT,5)
326#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
327        lgmixVal = wx.TextCtrl(DData,wx.ID_ANY,
328            '%.4f'%(UseList[G2frame.hist][name][1][2]),style=wx.TE_PROCESS_ENTER)
329        Indx[lgmixVal.GetId()] = [G2frame.hist,name]
330        lgmixVal.Bind(wx.EVT_TEXT_ENTER,OnVal)
331        lgmixVal.Bind(wx.EVT_KILL_FOCUS,OnVal)
332        lgmixSizer.Add(lgmixVal,0,WACV|wx.LEFT,5)
333        return lgmixSizer
334                   
335    def ResetSizer(name,OnReset):
336        resetSizer = wx.BoxSizer(wx.HORIZONTAL)
337        reset = wx.CheckBox(DData,wx.ID_ANY,label='Reset?')
338        reset.thisown = False
339        reset.SetValue(False)
340        Indx[reset.GetId()] = [G2frame.hist,name]
341        reset.Bind(wx.EVT_CHECKBOX,OnReset)
342        resetSizer.Add(reset,0,WACV|wx.TOP|wx.LEFT,5)
343        return resetSizer
344       
345    def IsoSizer(name,parm,fmt,OnVal,OnRef):
346        isoSizer = wx.BoxSizer(wx.HORIZONTAL)
347        sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=name)
348        sizeRef.thisown = False
349        sizeRef.SetValue(UseList[G2frame.hist][parm][2][0])
350        Indx[sizeRef.GetId()] = [G2frame.hist,0]
351        sizeRef.Bind(wx.EVT_CHECKBOX, OnRef)
352        isoSizer.Add(sizeRef,0,WACV|wx.LEFT,5)
353#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
354        sizeVal = wx.TextCtrl(DData,wx.ID_ANY,
355            fmt%(UseList[G2frame.hist][parm][1][0]),style=wx.TE_PROCESS_ENTER)
356        Indx[sizeVal.GetId()] = [G2frame.hist,0]
357        sizeVal.Bind(wx.EVT_TEXT_ENTER,OnVal)
358        sizeVal.Bind(wx.EVT_KILL_FOCUS,OnVal)
359        isoSizer.Add(sizeVal,0,WACV)
360        return isoSizer
361       
362    def UniSizer(parm,OnAxis):
363        uniSizer = wx.BoxSizer(wx.HORIZONTAL)
364        uniSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Unique axis, H K L: '),0,WACV)
365        h,k,l = UseList[G2frame.hist][parm][3]
366        Axis = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(h,k,l),style=wx.TE_PROCESS_ENTER)
367        Axis.Bind(wx.EVT_TEXT_ENTER,OnAxis)
368        Axis.Bind(wx.EVT_KILL_FOCUS,OnAxis)
369        uniSizer.Add(Axis,0,WACV|wx.LEFT,5)
370        return uniSizer
371       
372    def UniDataSizer(parmName,parm,fmt,OnVal,OnRef):
373        dataSizer = wx.BoxSizer(wx.HORIZONTAL)
374        parms = zip([' Equatorial '+parmName,' Axial '+parmName],
375            UseList[G2frame.hist][parm][1],UseList[G2frame.hist][parm][2],range(2))
376        for Pa,val,ref,id in parms:
377            sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
378            sizeRef.thisown = False
379            sizeRef.SetValue(ref)
380            Indx[sizeRef.GetId()] = [G2frame.hist,id]
381            sizeRef.Bind(wx.EVT_CHECKBOX, OnRef)
382            dataSizer.Add(sizeRef,0,WACV|wx.LEFT,5)
383#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
384            sizeVal = wx.TextCtrl(DData,wx.ID_ANY,fmt%(val),style=wx.TE_PROCESS_ENTER)
385            Indx[sizeVal.GetId()] = [G2frame.hist,id]
386            sizeVal.Bind(wx.EVT_TEXT_ENTER,OnVal)
387            sizeVal.Bind(wx.EVT_KILL_FOCUS,OnVal)
388            dataSizer.Add(sizeVal,0,WACV|wx.BOTTOM,5)
389        return dataSizer
390       
391    def EllSizeDataSizer():
392        parms = zip(['S11','S22','S33','S12','S13','S23'],UseList[G2frame.hist]['Size'][4],
393            UseList[G2frame.hist]['Size'][5],range(6))
394        dataSizer = wx.FlexGridSizer(0,6,5,5)
395        for Pa,val,ref,id in parms:
396            sizeRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
397            sizeRef.thisown = False
398            sizeRef.SetValue(ref)
399            Indx[sizeRef.GetId()] = [G2frame.hist,id]
400            sizeRef.Bind(wx.EVT_CHECKBOX, OnSizeRef)
401            dataSizer.Add(sizeRef,0,WACV)
402#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
403            sizeVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3f'%(val),style=wx.TE_PROCESS_ENTER)
404            Indx[sizeVal.GetId()] = [G2frame.hist,id]
405            sizeVal.Bind(wx.EVT_TEXT_ENTER,OnSizeVal)
406            sizeVal.Bind(wx.EVT_KILL_FOCUS,OnSizeVal)
407            dataSizer.Add(sizeVal,0,WACV)
408        return dataSizer
409       
410    def GenStrainDataSizer():
411        Snames = G2spc.MustrainNames(SGData)
412        numb = len(Snames)
413        if len(UseList[G2frame.hist]['Mustrain'][4]) < numb:
414            UseList[G2frame.hist]['Mustrain'][4] = numb*[0.0,]
415            UseList[G2frame.hist]['Mustrain'][5] = numb*[False,]
416        parms = zip(Snames,UseList[G2frame.hist]['Mustrain'][4],UseList[G2frame.hist]['Mustrain'][5],range(numb))
417        dataSizer = wx.FlexGridSizer(0,6,5,5)
418        for Pa,val,ref,id in parms:
419            strainRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
420            strainRef.thisown = False
421            strainRef.SetValue(ref)
422            Indx[strainRef.GetId()] = [G2frame.hist,id]
423            strainRef.Bind(wx.EVT_CHECKBOX, OnStrainRef)
424            dataSizer.Add(strainRef,0,WACV)
425#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
426            strainVal = wx.TextCtrl(DData,wx.ID_ANY,'%.1f'%(val),style=wx.TE_PROCESS_ENTER)
427            Indx[strainVal.GetId()] = [G2frame.hist,id]
428            strainVal.Bind(wx.EVT_TEXT_ENTER,OnStrainVal)
429            strainVal.Bind(wx.EVT_KILL_FOCUS,OnStrainVal)
430            dataSizer.Add(strainVal,0,WACV)
431        return dataSizer
432
433    def HstrainSizer():
434        hstrainSizer = wx.FlexGridSizer(0,6,5,5)
435        Hsnames = G2spc.HStrainNames(SGData)
436        parms = zip(Hsnames,UseList[G2frame.hist]['HStrain'][0],UseList[G2frame.hist]['HStrain'][1],range(len(Hsnames)))
437        for Pa,val,ref,id in parms:
438            hstrainRef = wx.CheckBox(DData,wx.ID_ANY,label=Pa)
439            hstrainRef.thisown = False
440            hstrainRef.SetValue(ref)
441            Indx[hstrainRef.GetId()] = [G2frame.hist,id]
442            hstrainRef.Bind(wx.EVT_CHECKBOX, OnHstrainRef)
443            hstrainSizer.Add(hstrainRef,0,WACV|wx.LEFT,5)
444#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
445            hstrainVal = wx.TextCtrl(DData,wx.ID_ANY,'%.3g'%(val),style=wx.TE_PROCESS_ENTER)
446            Indx[hstrainVal.GetId()] = [G2frame.hist,id]
447            hstrainVal.Bind(wx.EVT_TEXT_ENTER,OnHstrainVal)
448            hstrainVal.Bind(wx.EVT_KILL_FOCUS,OnHstrainVal)
449            hstrainSizer.Add(hstrainVal,0,WACV)
450        return hstrainSizer
451       
452    def PoTopSizer(POData):
453        poSizer = wx.FlexGridSizer(0,6,5,5)
454        choice = ['March-Dollase','Spherical harmonics']
455        POtype = choice[['MD','SH'].index(POData[0])]
456        poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Preferred orientation model '),0,WACV)
457        POType = wx.ComboBox(DData,wx.ID_ANY,value=POtype,choices=choice,
458            style=wx.CB_READONLY|wx.CB_DROPDOWN)
459        POType.Bind(wx.EVT_COMBOBOX, OnPOType)
460        poSizer.Add(POType)
461        if POData[0] == 'SH':
462            poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Harmonic order: '),0,WACV)
463            poOrder = wx.ComboBox(DData,wx.ID_ANY,value=str(POData[4]),choices=[str(2*i) for i in range(18)],
464                style=wx.CB_READONLY|wx.CB_DROPDOWN)
465            poOrder.Bind(wx.EVT_COMBOBOX,OnPOOrder)
466            poSizer.Add(poOrder,0,WACV)
467            poRef = wx.CheckBox(DData,wx.ID_ANY,label=' Refine? ')
468            poRef.SetValue(POData[2])
469            poRef.Bind(wx.EVT_CHECKBOX,OnPORef)
470            poSizer.Add(poRef,0,WACV)
471        return poSizer
472       
473    def MDDataSizer(POData):
474        poSizer = wx.BoxSizer(wx.HORIZONTAL)
475        poRef = wx.CheckBox(DData,wx.ID_ANY,label=' March-Dollase ratio: ')
476        poRef.SetValue(POData[2])
477        poRef.Bind(wx.EVT_CHECKBOX,OnPORef)
478        poSizer.Add(poRef,0,WACV|wx.LEFT,5)
479        poVal = G2G.ValidatedTxtCtrl(DData,POData,1,nDig=(10,3),typeHint=float,min=0.)
480        poSizer.Add(poVal,0,WACV)
481        poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Unique axis, H K L: '),0,WACV)
482        h,k,l =POData[3]
483        poAxis = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(h,k,l),style=wx.TE_PROCESS_ENTER)
484        poAxis.Bind(wx.EVT_TEXT_ENTER,OnPOAxis)
485        poAxis.Bind(wx.EVT_KILL_FOCUS,OnPOAxis)
486        poSizer.Add(poAxis,0,WACV)
487        return poSizer
488       
489    def SHDataSizer(POData):
490       
491        def OnODFValue(invalid,value,tc):
492            G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
493   
494        ODFSizer = wx.FlexGridSizer(0,8,2,2)
495        ODFkeys = POData[5].keys()
496        ODFkeys.sort()
497        for odf in ODFkeys:
498            ODFSizer.Add(wx.StaticText(DData,wx.ID_ANY,odf),0,WACV)
499            ODFval = G2G.ValidatedTxtCtrl(DData,POData[5],odf,nDig=(8,3),typeHint=float,OnLeave=OnODFValue)
500            ODFSizer.Add(ODFval,0,WACV|wx.LEFT,5)
501        return ODFSizer
502       
503    def SHPenalty(POData):
504       
505        def OnHKLList(event):
506            dlg = G2G.G2MultiChoiceDialog(G2frame, 'Select penalty hkls',
507                'Penalty hkls',hkls,filterBox=False)
508            try:
509                if dlg.ShowModal() == wx.ID_OK:
510                    POData[6] = [hkls[i] for i in dlg.GetSelections()]
511                    if not POData[6]:
512                        POData[6] = ['',]
513                else:
514                    return
515            finally:
516                dlg.Destroy()
517            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
518           
519        A = G2lat.cell2A(generalData['Cell'][1:7])
520        hkls = G2lat.GenPfHKLs(10,SGData,A)   
521        shPenalty = wx.BoxSizer(wx.HORIZONTAL)
522        shPenalty.Add(wx.StaticText(DData,wx.ID_ANY,' Negative MRD penalty list: '),0,WACV)
523        shPenalty.Add(wx.ComboBox(DData,value=POData[6][0],choices=POData[6],
524            style=wx.CB_DROPDOWN),0,WACV|wx.LEFT,5)
525        hklList = wx.Button(DData,label='Select penalty hkls')
526        hklList.Bind(wx.EVT_BUTTON,OnHKLList)
527        shPenalty.Add(hklList,0,WACV)
528        shPenalty.Add(wx.StaticText(DData,wx.ID_ANY,' Zero MRD tolerance: '),0,WACV)
529        shToler = G2G.ValidatedTxtCtrl(DData,POData,7,nDig=(10,2),typeHint=float)
530        shPenalty.Add(shToler,0,WACV)
531        return shPenalty   
532       
533    def ExtSizer(Type):
534       
535        def OnSCExtType(event):
536            Obj = event.GetEventObject()
537            item = Indx[Obj.GetId()]
538            UseList[item[0]]['Extinction'][item[1]] = Obj.GetValue()
539            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
540               
541        def OnEref(event):
542            Obj = event.GetEventObject()
543            item = Indx[Obj.GetId()]
544            UseList[item[0]]['Extinction'][2][item[1]][1] = Obj.GetValue()
545   
546        def OnExtRef(event):
547            Obj = event.GetEventObject()
548            UseList[G2frame.hist]['Extinction'][1] = Obj.GetValue()
549           
550        if Type == 'HKLF':
551            extSizer = wx.BoxSizer(wx.VERTICAL)
552            typeSizer = wx.BoxSizer(wx.HORIZONTAL)           
553            typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Extinction type: '),0,WACV)
554            Choices = ['None','Primary','Secondary Type I','Secondary Type II',]    # remove 'Secondary Type I & II'
555            typeTxt = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][1],
556                style=wx.CB_READONLY|wx.CB_DROPDOWN)
557            Indx[typeTxt.GetId()] = [G2frame.hist,1]
558            typeTxt.Bind(wx.EVT_COMBOBOX,OnSCExtType)
559            typeSizer.Add(typeTxt)
560            typeSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Approx: '),0,WACV)
561            Choices=['Lorentzian','Gaussian']
562            approxTxT = wx.ComboBox(DData,wx.ID_ANY,choices=Choices,value=UseList[G2frame.hist]['Extinction'][0],
563                style=wx.CB_READONLY|wx.CB_DROPDOWN)
564            Indx[approxTxT.GetId()] = [G2frame.hist,0]
565            approxTxT.Bind(wx.EVT_COMBOBOX,OnSCExtType)
566            typeSizer.Add(approxTxT)
567            if UseList[G2frame.hist]['Extinction'][1] == 'None':
568                extSizer.Add(typeSizer,0,WACV)
569            else:
570                extSizer.Add(typeSizer,0,WACV|wx.BOTTOM,5)       
571                if 'Tbar' in UseList[G2frame.hist]['Extinction'][2]:       #skipped for TOF   
572                    valSizer =wx.BoxSizer(wx.HORIZONTAL)
573                    valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Tbar(mm):'),0,WACV)
574                    tbarVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'][2],'Tbar',
575                        min=0.,nDig=(10,3),typeHint=float)
576                    valSizer.Add(tbarVal,0,WACV)
577                    valSizer.Add(wx.StaticText(DData,wx.ID_ANY,' cos(2ThM):'),0,WACV)
578                    cos2tm = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'][2],'Cos2TM',
579                        min=0.,max=1.,nDig=(10,3),typeHint=float)
580                    valSizer.Add(cos2tm,0,WACV)
581                    extSizer.Add(valSizer,0,WACV)
582                val2Sizer =wx.BoxSizer(wx.HORIZONTAL)
583                if 'Primary' in UseList[G2frame.hist]['Extinction'][1]:
584                    Ekey = ['Ep',]
585                elif 'Secondary Type II' == UseList[G2frame.hist]['Extinction'][1]:
586                    Ekey = ['Es',]
587                elif 'Secondary Type I' == UseList[G2frame.hist]['Extinction'][1]:
588                    Ekey = ['Eg',]
589                else:
590                    Ekey = ['Eg','Es']
591                for ekey in Ekey:
592                    Eref = wx.CheckBox(DData,wx.ID_ANY,label=ekey+' : ')
593                    Eref.SetValue(UseList[G2frame.hist]['Extinction'][2][ekey][1])
594                    Indx[Eref.GetId()] = [G2frame.hist,ekey]
595                    Eref.Bind(wx.EVT_CHECKBOX, OnEref)
596                    val2Sizer.Add(Eref,0,WACV|wx.LEFT,5)
597                    Eval = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'][2][ekey],0,
598                        min=0.,nDig=(10,3,'g'),typeHint=float)
599                    val2Sizer.Add(Eval,0,WACV)
600                extSizer.Add(val2Sizer,0,WACV)
601        else:   #PWDR
602            extSizer = wx.BoxSizer(wx.HORIZONTAL)
603            extRef = wx.CheckBox(DData,wx.ID_ANY,label=' Extinction: ')
604            extRef.SetValue(UseList[G2frame.hist]['Extinction'][1])
605            extRef.Bind(wx.EVT_CHECKBOX, OnExtRef)
606            extSizer.Add(extRef,0,WACV|wx.LEFT,5)
607            extVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Extinction'],0,
608                min=0.,nDig=(10,2),typeHint=float)
609            extSizer.Add(extVal,0,WACV)
610
611        return extSizer
612       
613    def BabSizer():
614       
615        def OnBabRef(event):
616            Obj = event.GetEventObject()
617            item,bab = Indx[Obj.GetId()]
618            UseList[item]['Babinet']['Bab'+bab][1] = Obj.GetValue()
619       
620        babSizer = wx.BoxSizer(wx.HORIZONTAL)
621        for bab in ['A','U']:
622            babRef = wx.CheckBox(DData,wx.ID_ANY,label=' Babinet '+bab+': ')
623            babRef.SetValue(UseList[G2frame.hist]['Babinet']['Bab'+bab][1])
624            Indx[babRef.GetId()] = [G2frame.hist,bab]
625            babRef.Bind(wx.EVT_CHECKBOX, OnBabRef)
626            babSizer.Add(babRef,0,WACV|wx.LEFT,5)
627            babVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Babinet']['Bab'+bab],0,
628                nDig=(10,3),min=0.,typeHint=float)
629            babSizer.Add(babVal,0,WACV)
630        return babSizer
631       
632    def FlackSizer():
633       
634        def OnFlackRef(event):
635            Obj = event.GetEventObject()
636            UseList[G2frame.hist]['Flack'][1] = Obj.GetValue()
637               
638        flackSizer = wx.BoxSizer(wx.HORIZONTAL)
639        flackRef = wx.CheckBox(DData,wx.ID_ANY,label=' Flack parameter: ')
640        flackRef.SetValue(UseList[G2frame.hist]['Flack'][1])
641        flackRef.Bind(wx.EVT_CHECKBOX, OnFlackRef)
642        flackSizer.Add(flackRef,0,WACV|wx.LEFT,5)
643        flackVal = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Flack'],0,nDig=(10,3),typeHint=float)
644        flackSizer.Add(flackVal,0,WACV)
645        return flackSizer
646       
647    def twinSizer():
648       
649        def OnAddTwin(event):
650            twinMat = np.array([[-1,0,0],[0,-1,0],[0,0,-1]])    #inversion by default
651            twinVal = 0.0
652            UseList[G2frame.hist]['Twins'].append([twinMat,twinVal])
653            nNonM = UseList[G2frame.hist]['Twins'][0][1][2]
654            for i in range(nNonM):
655                UseList[G2frame.hist]['Twins'].append([False,0.0])
656            addtwin.SetValue(False)
657            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
658           
659        def OnMat(event):
660            event.Skip()
661            Obj = event.GetEventObject()
662            it,im = Indx[Obj.GetId()]
663            newMat = Obj.GetValue().split()
664            try:
665                uvw = [int(newMat[i]) for i in range(3)]
666            except ValueError:
667                uvw = UseList[G2frame.hist]['Twins'][it][0][im]
668            UseList[G2frame.hist]['Twins'][it][0][im] = uvw
669            Obj.SetValue('%3d %3d %3d'%(uvw[0],uvw[1],uvw[2]))
670           
671        def OnTwinVal(invalid,value,tc):
672            it = Indx[tc.GetId()]
673            sumTw = 0.
674            for it,twin in enumerate(UseList[G2frame.hist]['Twins']):
675                if it:
676                    sumTw += twin[1]
677            UseList[G2frame.hist]['Twins'][0][1][0] = 1.-sumTw
678            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
679           
680        def OnTwinRef(event):
681            Obj = event.GetEventObject()
682            UseList[G2frame.hist]['Twins'][0][1][1] = Obj.GetValue()
683           
684        def OnTwinInv(event):
685            Obj = event.GetEventObject()
686            it = Indx[Obj.GetId()]
687            UseList[G2frame.hist]['Twins'][it][0] = Obj.GetValue()
688                       
689        def OnTwinDel(event):
690            Obj = event.GetEventObject()
691            it = Indx[Obj.GetId()]
692            nNonM = UseList[G2frame.hist]['Twins'][0][1][2]
693            for i in range(nNonM):
694                del UseList[G2frame.hist]['Twins'][1+i+it]
695            del UseList[G2frame.hist]['Twins'][it]
696            sumTw = 0.
697            for it,twin in enumerate(UseList[G2frame.hist]['Twins']):
698                if it:
699                    sumTw += twin[1]
700            UseList[G2frame.hist]['Twins'][0][1][0] = 1.-sumTw
701            if len(UseList[G2frame.hist]['Twins']) == 1:
702                UseList[G2frame.hist]['Twins'][0][1][1] = False
703            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))           
704           
705        nTwin = len(UseList[G2frame.hist]['Twins'])
706        twinsizer = wx.BoxSizer(wx.VERTICAL)
707        topsizer = wx.BoxSizer(wx.HORIZONTAL)         
708        topsizer.Add(wx.StaticText(DData,wx.ID_ANY,' Merohedral twins: '),0,WACV)
709        #temporary - add twin not allowed if nonmerohedral twins present
710#        if nTwin == 1 or 'bool' not in str(type(UseList[G2frame.hist]['Twins'][1][0])):
711        addtwin = wx.CheckBox(DData,wx.ID_ANY,label=' Add Twin Law')
712        addtwin.Bind(wx.EVT_CHECKBOX, OnAddTwin)
713        topsizer.Add(addtwin,0,WACV|wx.LEFT,5)
714        twinsizer.Add(topsizer)
715        Indx = {}
716        if nTwin > 1:
717            for it,Twin in enumerate(UseList[G2frame.hist]['Twins']):
718                twinMat,twinVal = Twin
719                matSizer = wx.BoxSizer(wx.HORIZONTAL)
720                if it:
721                    Style = wx.TE_PROCESS_ENTER
722                    TwVal = Twin[1]
723                else:
724                    Style = wx.TE_READONLY
725                    TwVal = Twin[1][0]
726                if 'bool' not in str(type(Twin[0])):
727                    matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV|wx.LEFT,5)
728                    for im,Mat in enumerate(twinMat):
729                        mat = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(Mat[0],Mat[1],Mat[2]),
730                            style=Style)
731                        if it:
732                            Indx[mat.GetId()] = [it,im]
733                            mat.Bind(wx.EVT_TEXT_ENTER,OnMat)
734                            mat.Bind(wx.EVT_KILL_FOCUS,OnMat)
735                        else:
736                            mat.SetBackgroundColour(VERY_LIGHT_GREY)
737                        matSizer.Add(mat,0,WACV|wx.LEFT,5)
738                else:
739                    matSizer.Add(wx.StaticText(DData,-1,' Nonmerohedral twin component %d: '%(it)),0,WACV|wx.LEFT,5)
740                    if not SGData['SGInv']:
741                        twinv = wx.CheckBox(DData,wx.ID_ANY,label=' Use enantiomorph?')
742                        twinv.SetValue(Twin[0])
743                        Indx[twinv.GetId()] = it
744                        twinv.Bind(wx.EVT_CHECKBOX, OnTwinInv)
745                        matSizer.Add(twinv,0,WACV)
746                twinsizer.Add(matSizer,0,WACV|wx.LEFT,5)
747                valSizer = wx.BoxSizer(wx.HORIZONTAL)
748                valSizer.Add(wx.StaticText(DData,-1,label=' Twin element fraction:'),0,WACV)
749                if it:
750                    twinval = G2G.ValidatedTxtCtrl(DData,UseList[G2frame.hist]['Twins'][it],1,nDig=(10,3),
751                        min=0.,max=1.,typeHint=float,OnLeave=OnTwinVal)
752                    Indx[twinval.GetId()] = it
753                else:
754                    twinval = wx.TextCtrl(DData,-1,'%.3f'%(TwVal),style=Style)
755                    twinval.SetBackgroundColour(VERY_LIGHT_GREY)
756                valSizer.Add(twinval,0,WACV)
757                if it and 'bool' not in str(type(Twin[0])):
758                    twindel = wx.CheckBox(DData,wx.ID_ANY,label=' Delete?')
759                    Indx[twindel.GetId()] = it
760                    twindel.Bind(wx.EVT_CHECKBOX, OnTwinDel)
761                    valSizer.Add(twindel,0,WACV)
762                elif not it:
763                    twinref = wx.CheckBox(DData,wx.ID_ANY,label=' Refine?')
764                    twinref.SetValue(Twin[1][1])
765                    twinref.Bind(wx.EVT_CHECKBOX, OnTwinRef)
766                    valSizer.Add(twinref,0,WACV)
767                twinsizer.Add(valSizer,0,WACV|wx.LEFT,5)
768        return twinsizer
769       
770    def OnSelect(event):
771        G2frame.hist = G2frame.dataWindow.HistsInPhase[select.GetSelection()]
772        oldFocus = wx.Window.FindFocus()
773        G2plt.PlotSizeStrainPO(G2frame,data,G2frame.hist)
774        wx.CallLater(100,RepaintHistogramInfo)
775        wx.CallAfter(oldFocus.SetFocus)
776       
777    def RepaintHistogramInfo(Scroll=0):
778        G2frame.bottomSizer.DeleteWindows()
779        Indx.clear()
780        G2frame.bottomSizer = ShowHistogramInfo()
781        mainSizer.Add(G2frame.bottomSizer)
782        mainSizer.Layout()
783        G2frame.dataWindow.Refresh()
784        DData.SetVirtualSize(mainSizer.GetMinSize())
785        DData.Scroll(0,Scroll)
786        G2frame.dataWindow.SendSizeEvent()
787       
788    def ShowHistogramInfo():
789        '''This creates a sizer with all the information pulled out from the Phase/data dict
790        '''
791       
792        def OnUseData(event):
793            Obj = event.GetEventObject()
794            UseList[G2frame.hist]['Use'] = Obj.GetValue()
795
796        def OnLeBail(event):
797            Obj = event.GetEventObject()
798            if not UseList[G2frame.hist]['LeBail']:
799                UseList[G2frame.hist]['newLeBail'] = True
800            UseList[G2frame.hist]['LeBail'] = Obj.GetValue()
801
802        def OnResetSize(event):
803            Obj = event.GetEventObject()
804            Obj.SetValue(False)
805            item,name = Indx[Obj.GetId()]
806            if name == 'isotropic':
807                UseList[item]['Size'][1][0] = 1.0
808            elif name == 'uniaxial':
809                UseList[item]['Size'][1][0] = 1.0
810                UseList[item]['Size'][1][1] = 1.0
811            elif name == 'ellipsoidal':
812                for i in range(3):
813                    UseList[item]['Size'][4][i] = 1.0
814                    UseList[item]['Size'][4][i+3] = 0.0
815            G2plt.PlotSizeStrainPO(G2frame,data,item)
816            wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
817           
818        def OnSizeAxis(event):           
819            event.Skip()
820            Obj = event.GetEventObject()
821            Saxis = Obj.GetValue().split()
822            try:
823                hkl = [int(Saxis[i]) for i in range(3)]
824            except (ValueError,IndexError):
825                hkl = UseList[G2frame.hist]['Size'][3]
826            if not np.any(np.array(hkl)):
827                hkl = UseList[G2frame.hist]['Size'][3]
828            UseList[G2frame.hist]['Size'][3] = hkl
829            h,k,l = hkl
830            Obj.SetValue('%3d %3d %3d'%(h,k,l)) 
831
832        if G2frame.hist not in UseList:               
833            G2frame.ErrorDialog('Missing data error',
834                    G2frame.hist+' not in GSAS-II data tree')
835            return
836        if 'Use' not in UseList[G2frame.hist]:      #patch
837            UseList[G2frame.hist]['Use'] = True
838        if 'LeBail' not in UseList[G2frame.hist]:
839            UseList[G2frame.hist]['LeBail'] = False
840        if 'newLeBail' not in UseList[G2frame.hist]:
841            UseList[G2frame.hist]['newLeBail'] = True
842        if 'Babinet' not in UseList[G2frame.hist]:
843            UseList[G2frame.hist]['Babinet'] = {'BabA':[0.0,False],'BabU':[0.0,False]}
844        bottomSizer = wx.BoxSizer(wx.VERTICAL)
845        useBox = wx.BoxSizer(wx.HORIZONTAL)
846        useData = wx.CheckBox(DData,wx.ID_ANY,label='Use Histogram: '+G2frame.hist+' ?')
847        useData.Bind(wx.EVT_CHECKBOX, OnUseData)
848        useData.SetValue(UseList[G2frame.hist]['Use'])
849        useBox.Add(useData,0,WACV)
850        if not generalData['doPawley'] and 'PWDR' in G2frame.hist[:4]:
851            lebail = wx.CheckBox(DData,wx.ID_ANY,label='Do LeBail extraction?')
852            lebail.Bind(wx.EVT_CHECKBOX, OnLeBail)
853            lebail.SetValue(UseList[G2frame.hist]['LeBail'])
854            useBox.Add(lebail,0,WACV)
855            if UseList[G2frame.hist]['LeBail']:
856                G2frame.SetStatusText('To reset LeBail, cycle LeBail check box.',1)
857        bottomSizer.Add(useBox,0,WACV|wx.TOP|wx.BOTTOM|wx.LEFT,5)
858       
859        bottomSizer.Add(ScaleSizer(),0,WACV|wx.BOTTOM,5)
860           
861        if G2frame.hist[:4] == 'PWDR':
862            if UseList[G2frame.hist]['Size'][0] == 'isotropic':
863                isoSizer = wx.BoxSizer(wx.HORIZONTAL)
864                isoSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
865                    'Size',OnSizeType),0,WACV)
866                isoSizer.Add(LGmixSizer('Size',OnLGmixVal,OnLGmixRef))
867                isoSizer.Add(ResetSizer('isotropic',OnResetSize),0,WACV)
868                bottomSizer.Add(isoSizer)
869                bottomSizer.Add(IsoSizer(u'size(\xb5m): ','Size','%.3f',
870                    OnSizeVal,OnSizeRef),0,WACV|wx.BOTTOM,5)
871            elif UseList[G2frame.hist]['Size'][0] == 'uniaxial':
872                uniSizer = wx.BoxSizer(wx.HORIZONTAL)
873                uniSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
874                    'Size',OnSizeType),0,WACV)
875                uniSizer.Add(LGmixSizer('Size',OnLGmixVal,OnLGmixRef))
876                uniSizer.Add(ResetSizer('uniaxial',OnResetSize),0,WACV)
877                bottomSizer.Add(UniSizer('Size',OnSizeAxis),0,WACV)
878                bottomSizer.Add(uniSizer)
879                bottomSizer.Add(UniDataSizer(u'size(\xb5m): ','Size','%.3f',OnSizeVal,OnSizeRef)
880                    ,0,WACV|wx.BOTTOM,5)
881            elif UseList[G2frame.hist]['Size'][0] == 'ellipsoidal':
882                ellSizer = wx.BoxSizer(wx.HORIZONTAL)
883                ellSizer.Add(TopSizer(' Domain size model: ',['isotropic','uniaxial','ellipsoidal'],
884                    'Size',OnSizeType),0,WACV)
885                ellSizer.Add(LGmixSizer('Size',OnLGmixVal,OnLGmixRef))
886                ellSizer.Add(ResetSizer('ellipsoidal',OnResetSize),0,WACV)
887                bottomSizer.Add(ellSizer)
888                bottomSizer.Add(EllSizeDataSizer(),0,WACV|wx.BOTTOM,5)
889           
890            if UseList[G2frame.hist]['Mustrain'][0] == 'isotropic':
891                isoSizer = wx.BoxSizer(wx.HORIZONTAL)
892                isoSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
893                    'Mustrain',OnStrainType),0,WACV)
894                isoSizer.Add(LGmixSizer('Mustrain',OnLGmixVal,OnLGmixRef))
895                isoSizer.Add(ResetSizer('isotropic',OnResetStrain),0,WACV)
896                bottomSizer.Add(isoSizer)
897                bottomSizer.Add(IsoSizer(' microstrain: ','Mustrain','%.1f',
898                    OnStrainVal,OnStrainRef),0,WACV|wx.BOTTOM,5)
899            elif UseList[G2frame.hist]['Mustrain'][0] == 'uniaxial':
900                uniSizer = wx.BoxSizer(wx.HORIZONTAL)
901                uniSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
902                    'Mustrain',OnStrainType),0,WACV)
903                uniSizer.Add(LGmixSizer('Mustrain',OnLGmixVal,OnLGmixRef))
904                uniSizer.Add(ResetSizer('uniaxial',OnResetStrain),0,WACV)
905                bottomSizer.Add(uniSizer)
906                bottomSizer.Add(UniSizer('Mustrain',OnStrainAxis),0,WACV)
907                bottomSizer.Add(UniDataSizer('mustrain: ','Mustrain','%.1f',OnStrainVal,OnStrainRef)
908                                ,0,WACV|wx.BOTTOM,5)
909            elif UseList[G2frame.hist]['Mustrain'][0] == 'generalized':
910                genSizer = wx.BoxSizer(wx.HORIZONTAL)
911                genSizer.Add(TopSizer(' Mustrain model: ',['isotropic','uniaxial','generalized',],
912                    'Mustrain',OnStrainType),0,WACV)
913                genSizer.Add(LGmixSizer('Mustrain',OnLGmixVal,OnLGmixRef))
914                genSizer.Add(ResetSizer('generalized',OnResetStrain),0,WACV)
915                bottomSizer.Add(genSizer)
916                bottomSizer.Add(GenStrainDataSizer(),0,WACV|wx.BOTTOM,5)
917           
918            bottomSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Hydrostatic/elastic strain:'))
919            bottomSizer.Add(HstrainSizer())
920               
921            poSizer = wx.BoxSizer(wx.VERTICAL)
922            POData = UseList[G2frame.hist]['Pref.Ori.']
923# patch - add penalty items
924            if len(POData) < 7:
925                POData.append(['',])
926                POData.append(0.1)
927            if not POData[6]:
928                POData[6] = ['',]
929# end patch
930            poSizer.Add(PoTopSizer(POData))
931            if POData[0] == 'MD':
932                poSizer.Add(MDDataSizer(POData))
933            else:           #'SH'
934                if POData[4]:       #SH order > 0
935                    textJ = G2lat.textureIndex(POData[5])
936                    poSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Spherical harmonic coefficients: '+'Texture index: %.3f'%(textJ))
937                        ,0,WACV|wx.TOP|wx.BOTTOM,5)
938                    poSizer.Add(SHDataSizer(POData),0,WACV|wx.TOP|wx.BOTTOM,5)
939                    poSizer.Add(SHPenalty(POData),0,WACV|wx.TOP|wx.BOTTOM,5)
940                   
941            bottomSizer.Add(poSizer,0,WACV|wx.TOP|wx.BOTTOM,5)
942            bottomSizer.Add(ExtSizer('PWDR'),0,WACV|wx.TOP|wx.BOTTOM,5)
943            if generalData['Type'] != 'magnetic': 
944                bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
945        elif G2frame.hist[:4] == 'HKLF':
946#patch
947            if 'Flack' not in UseList[G2frame.hist]:
948                UseList[G2frame.hist]['Flack'] = [0.0,False]
949            if 'Twins' not in UseList[G2frame.hist]:
950                UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
951#end patch
952            bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5)
953            bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
954            if not SGData['SGInv'] and len(UseList[G2frame.hist]['Twins']) < 2:
955                bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5)
956            bottomSizer.Add(twinSizer(),0,WACV|wx.BOTTOM,5)
957        return bottomSizer
958
959    ######################################################################
960    # Beginning of UpdateDData execution here
961    ######################################################################
962    G2frame.SetStatusText('',1)
963    keyList = G2frame.GetHistogramNames(['PWDR','HKLF'])
964    UseList = data['Histograms']
965    if UseList:
966        G2frame.dataWindow.DataMenu.Enable(G2G.wxID_DATADELETE,True)
967        for item in G2frame.Refine: item.Enable(True)
968    else:
969        G2frame.dataWindow.DataMenu.Enable(G2G.wxID_DATADELETE,False)
970        for item in G2frame.Refine: item.Enable(False)
971    # make a list of histograms (any type) used in this phase, ordered as in tree
972    G2frame.dataWindow.HistsInPhase = [name for name in keyList if name in UseList]
973    generalData = data['General']
974    PhaseName = generalData['Name']       
975    SGData = generalData['SGData']
976    if len(G2frame.dataWindow.HistsInPhase) == 0: # no associated histograms, nothing to display here
977        G2frame.hist = ''
978    elif hist and hist in G2frame.dataWindow.HistsInPhase: # something was input as a selection as an argument
979        G2frame.hist = hist
980    elif (not G2frame.hist) or (G2frame.hist not in G2frame.dataWindow.HistsInPhase): # no or bad selection but have data, take the first
981        G2frame.hist = G2frame.dataWindow.HistsInPhase[0]
982    Indx = {}
983   
984    if DData.GetSizer():
985        DData.GetSizer().Clear(True)
986    mainSizer = wx.BoxSizer(wx.VERTICAL)
987    mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,' Histogram data for '+PhaseName+':'),0,WACV|wx.LEFT,5)
988    if G2frame.hist:
989        topSizer = wx.FlexGridSizer(1,2,5,5)
990        select = wx.ListBox(DData,choices=G2frame.dataWindow.HistsInPhase,
991                            style=wx.LB_SINGLE,size=(-1,120))
992        select.SetSelection(G2frame.dataWindow.HistsInPhase.index(G2frame.hist))
993        select.SetFirstItem(G2frame.dataWindow.HistsInPhase.index(G2frame.hist))
994        select.Bind(wx.EVT_LISTBOX,OnSelect)
995        topSizer.Add(select,0,WACV|wx.LEFT,5)
996        if any(['PWDR' in item for item in keyList]):
997            topSizer.Add(PlotSizer())
998        mainSizer.Add(topSizer)       
999        G2frame.bottomSizer = ShowHistogramInfo()
1000        mainSizer.Add(G2frame.bottomSizer)
1001    elif not keyList:
1002        mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,'  (This project has no data; use Import to read it)'),
1003                      0,WACV|wx.TOP,10)
1004    elif not UseList in G2frame.dataWindow.HistsInPhase:
1005        mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,'  (This phase has no associated data; use appropriate Edit/Add... menu item)'),
1006                      0,WACV|wx.TOP,10)
1007    else:
1008        mainSizer.Add(wx.StaticText(DData,wx.ID_ANY,'  (Strange, how did we get here?)'),
1009                      0,WACV|wx.TOP,10)
1010       
1011    G2phsGUI.SetPhaseWindow(DData,mainSizer,Scroll=Scroll)
Note: See TracBrowser for help on using the repository browser.