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