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