1 | # -*- coding: utf-8 -*- |
---|
2 | #GSASIIgrid - data display routines |
---|
3 | ########### SVN repository information ################### |
---|
4 | # $Date: 2017-01-24 19:58:38 +0000 (Tue, 24 Jan 2017) $ |
---|
5 | # $Author: vondreele $ |
---|
6 | # $Revision: 2659 $ |
---|
7 | # $URL: trunk/GSASIIgrid.py $ |
---|
8 | # $Id: GSASIIgrid.py 2659 2017-01-24 19:58:38Z vondreele $ |
---|
9 | ########### SVN repository information ################### |
---|
10 | ''' |
---|
11 | *GSASIIgrid: Basic GUI routines* |
---|
12 | -------------------------------- |
---|
13 | |
---|
14 | ''' |
---|
15 | import wx |
---|
16 | import wx.grid as wg |
---|
17 | #import wx.wizard as wz |
---|
18 | #import wx.aui |
---|
19 | import wx.lib.scrolledpanel as wxscroll |
---|
20 | import time |
---|
21 | import copy |
---|
22 | import sys |
---|
23 | import os |
---|
24 | import random as ran |
---|
25 | import numpy as np |
---|
26 | import scipy.optimize as so |
---|
27 | import GSASIIpath |
---|
28 | GSASIIpath.SetVersionNumber("$Revision: 2659 $") |
---|
29 | import GSASIImath as G2mth |
---|
30 | import GSASIIIO as G2IO |
---|
31 | import GSASIIstrIO as G2stIO |
---|
32 | import GSASIIlattice as G2lat |
---|
33 | import GSASIIplot as G2plt |
---|
34 | import GSASIIpwdGUI as G2pdG |
---|
35 | import GSASIIimgGUI as G2imG |
---|
36 | import GSASIIphsGUI as G2phG |
---|
37 | import GSASIIspc as G2spc |
---|
38 | import GSASIImapvars as G2mv |
---|
39 | import GSASIIconstrGUI as G2cnstG |
---|
40 | import GSASIIrestrGUI as G2restG |
---|
41 | import GSASIIpy3 as G2py3 |
---|
42 | import GSASIIobj as G2obj |
---|
43 | import GSASIIexprGUI as G2exG |
---|
44 | import GSASIIlog as log |
---|
45 | import GSASIIctrls as G2G |
---|
46 | |
---|
47 | # trig functions in degrees |
---|
48 | sind = lambda x: np.sin(x*np.pi/180.) |
---|
49 | tand = lambda x: np.tan(x*np.pi/180.) |
---|
50 | cosd = lambda x: np.cos(x*np.pi/180.) |
---|
51 | |
---|
52 | # Define a short name for convenience |
---|
53 | WACV =Â wx.ALIGN_CENTER_VERTICAL |
---|
54 | |
---|
55 | [ wxID_FOURCALC, wxID_FOURSEARCH, wxID_FOURCLEAR, wxID_PEAKSMOVE, wxID_PEAKSCLEAR, |
---|
56 |   wxID_CHARGEFLIP, wxID_PEAKSUNIQUE, wxID_PEAKSDELETE, wxID_PEAKSDA, |
---|
57 |   wxID_PEAKSDISTVP, wxID_PEAKSVIEWPT, wxID_FINDEQVPEAKS,wxID_SHOWBONDS,wxID_MULTIMCSA, |
---|
58 | Â Â wxID_SINGLEMCSA,wxID_4DCHARGEFLIP,wxID_TRANSFORMSTRUCTURE, |
---|
59 | ] = [wx.NewId() for item in range(17)] |
---|
60 | |
---|
61 | [ wxID_PWDRADD, wxID_HKLFADD, wxID_PWDANALYSIS, wxID_PWDCOPY, wxID_PLOTCTRLCOPY, |
---|
62 | Â Â wxID_DATADELETE,wxID_DATACOPY,wxID_DATACOPYFLAGS,wxID_DATASELCOPY,wxID_DATAUSE, |
---|
63 | ] = [wx.NewId() for item in range(10)] |
---|
64 | |
---|
65 | [ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, |
---|
66 |   wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT, |
---|
67 | Â Â wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE,wxID_MAKEMOLECULE, |
---|
68 |   wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP,wxID_ADDHATOM,wxID_UPDATEHATOM, |
---|
69 |   wxID_WAVEVARY,wxID_ATOMSROTATE, wxID_ATOMSDENSITY, |
---|
70 |   wxID_ATOMSSETALL, wxID_ATOMSSETSEL, |
---|
71 | ] = [wx.NewId() for item in range(21)] |
---|
72 | |
---|
73 | [ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR, |
---|
74 |   wxID_DRAWVIEWPOINT, wxID_DRAWTRANSFORM, wxID_DRAWDELETE, wxID_DRAWFILLCELL, |
---|
75 |   wxID_DRAWADDEQUIV, wxID_DRAWFILLCOORD, wxID_DRAWDISAGLTOR, wxID_DRAWPLANE, |
---|
76 |   wxID_DRAWDISTVP, wxID_DRAWADDSPHERE,wxID_DRWAEDITRADII, |
---|
77 | ] = [wx.NewId() for item in range(15)] |
---|
78 | |
---|
79 | [ wxID_DRAWRESTRBOND, wxID_DRAWRESTRANGLE, wxID_DRAWRESTRPLANE, wxID_DRAWRESTRCHIRAL, |
---|
80 | ] = [wx.NewId() for item in range(4)] |
---|
81 | |
---|
82 | [Â wxID_ADDMCSAATOM,wxID_ADDMCSARB,wxID_CLEARMCSARB,wxID_MOVEMCSA,wxID_MCSACLEARRESULTS, |
---|
83 | ] = [wx.NewId() for item in range(5)] |
---|
84 | |
---|
85 | [Â wxID_CLEARTEXTURE,wxID_REFINETEXTURE, |
---|
86 | ] = [wx.NewId() for item in range(2)] |
---|
87 | |
---|
88 | [ wxID_LOADDIFFAX,wxID_LAYERSIMULATE,wxID_SEQUENCESIMULATE, wxID_LAYERSFIT, wxID_COPYPHASE, |
---|
89 | ] = [wx.NewId() for item in range(5)] |
---|
90 | |
---|
91 | [ wxID_PAWLEYLOAD, wxID_PAWLEYESTIMATE, wxID_PAWLEYUPDATE, wxID_PAWLEYSELALL, wxID_PAWLEYSELNONE, |
---|
92 |  wxID_PAWLEYSELTOGGLE, wxID_PAWLEYSET, |
---|
93 | ] = [wx.NewId() for item in range(7)] |
---|
94 | |
---|
95 | [ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB,wxID_IMRECALIBALL, |
---|
96 |   wxID_IMCOPYCONTROLS, wxID_INTEGRATEALL, wxID_IMSAVECONTROLS, wxID_IMLOADCONTROLS, wxID_IMAUTOINTEG, |
---|
97 |   wxID_IMCOPYSELECTED, wxID_SAVESELECTEDCONTROLS, wxID_IMXFERCONTROLS, |
---|
98 | ] = [wx.NewId() for item in range(13)] |
---|
99 | |
---|
100 | [ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD, wxID_NEWMASKSPOT,wxID_NEWMASKARC,wxID_NEWMASKRING, |
---|
101 |   wxID_NEWMASKFRAME, wxID_NEWMASKPOLY,wxID_MASKLOADNOT,wxID_FINDSPOTS, |
---|
102 | ] = [wx.NewId() for item in range(10)] |
---|
103 | |
---|
104 | [ wxID_STRSTACOPY, wxID_STRSTAFIT, wxID_STRSTASAVE, wxID_STRSTALOAD,wxID_STRSTSAMPLE, |
---|
105 | Â Â wxID_APPENDDZERO,wxID_STRSTAALLFIT,wxID_UPDATEDZERO,wxID_STRSTAPLOT, |
---|
106 | ] = [wx.NewId() for item in range(9)] |
---|
107 | |
---|
108 | [ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_SAMPLECOPYSOME, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY, |
---|
109 |   wxID_SAMPLESAVE, wxID_SAMPLELOAD,wxID_ADDEXCLREGION,wxID_SETSCALE,wxID_SAMPLE1VAL,wxID_ALLSAMPLELOAD, |
---|
110 | Â Â wxID_MAKEBACKRDF, |
---|
111 | ] = [wx.NewId() for item in range(13)] |
---|
112 | |
---|
113 | [ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY, wxID_INSTFLAGCOPY, wxID_INSTLOAD, |
---|
114 |   wxID_INSTSAVE, wxID_INST1VAL, wxID_INSTCALIB,wxID_INSTSAVEALL, |
---|
115 | ] = [wx.NewId() for item in range(9)] |
---|
116 | |
---|
117 | [Â wxID_UNDO,wxID_LSQPEAKFIT,wxID_LSQONECYCLE,wxID_RESETSIGGAM,wxID_CLEARPEAKS,wxID_AUTOSEARCH, |
---|
118 |   wxID_PEAKSCOPY, wxID_SEQPEAKFIT, |
---|
119 | ] = [wx.NewId() for item in range(8)] |
---|
120 | |
---|
121 | [ wxID_INDXRELOAD, wxID_INDEXPEAKS, wxID_REFINECELL, wxID_COPYCELL, wxID_MAKENEWPHASE, |
---|
122 | Â Â wxID_EXPORTCELLS, |
---|
123 | ] = [wx.NewId() for item in range(6)] |
---|
124 | |
---|
125 | [Â wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD,wxID_ADDRIDING, |
---|
126 |  wxID_CONSPHASE, wxID_CONSHIST, wxID_CONSHAP, wxID_CONSGLOBAL,wxID_EQUIVALANCEATOMS, |
---|
127 | ] = [wx.NewId() for item in range(10)] |
---|
128 | |
---|
129 | [ wxID_RESTRAINTADD, wxID_RESTSELPHASE,wxID_RESTDELETE, wxID_RESRCHANGEVAL, |
---|
130 | Â Â wxID_RESTCHANGEESD,wxID_AARESTRAINTADD,wxID_AARESTRAINTPLOT, |
---|
131 | ] = [wx.NewId() for item in range(7)] |
---|
132 | |
---|
133 | [Â wxID_RIGIDBODYADD,wxID_DRAWDEFINERB,wxID_RIGIDBODYIMPORT,wxID_RESIDUETORSSEQ, |
---|
134 | Â Â wxID_AUTOFINDRESRB,wxID_GLOBALRESREFINE,wxID_RBREMOVEALL,wxID_COPYRBPARMS, |
---|
135 | Â Â wxID_GLOBALTHERM,wxID_VECTORBODYADD |
---|
136 | ] = [wx.NewId() for item in range(10)] |
---|
137 | |
---|
138 | [Â wxID_RENAMESEQSEL,wxID_SAVESEQSEL,wxID_SAVESEQSELCSV,wxID_SAVESEQCSV,wxID_PLOTSEQSEL, |
---|
139 | Â wxID_ORGSEQSEL,wxADDSEQVAR,wxDELSEQVAR,wxEDITSEQVAR,wxCOPYPARFIT,wxID_AVESEQSEL, |
---|
140 | Â wxADDPARFIT,wxDELPARFIT,wxEDITPARFIT,wxDOPARFIT,wxADDSEQDIST,wxADDSEQANGLE |
---|
141 | ] = [wx.NewId() for item in range(17)] |
---|
142 | |
---|
143 | [Â wxID_MODELCOPY,wxID_MODELFIT,wxID_MODELADD,wxID_ELEMENTADD,wxID_ELEMENTDELETE, |
---|
144 | Â Â wxID_ADDSUBSTANCE,wxID_LOADSUBSTANCE,wxID_DELETESUBSTANCE,wxID_COPYSUBSTANCE, |
---|
145 | Â Â wxID_MODELUNDO,wxID_MODELFITALL,wxID_MODELCOPYFLAGS, |
---|
146 | ] = [wx.NewId() for item in range(12)] |
---|
147 | |
---|
148 | [Â wxID_SELECTPHASE,wxID_PWDHKLPLOT,wxID_PWD3DHKLPLOT,wxID_3DALLHKLPLOT,wxID_MERGEHKL, |
---|
149 | ] = [wx.NewId() for item in range(5)] |
---|
150 | |
---|
151 | [ wxID_PDFCOPYCONTROLS, wxID_PDFSAVECONTROLS, wxID_PDFLOADCONTROLS, wxID_PDFCOMPUTE, wxID_PDFCOMPUTEALL, |
---|
152 |   wxID_PDFADDELEMENT, wxID_PDFDELELEMENT, wxID_PDFPKSFIT,wxID_PDFPKSFITALL,wxID_PDFCOPYPEAKS, |
---|
153 | ] = [wx.NewId() for item in range(10)] |
---|
154 | |
---|
155 | [Â wxID_MCRON,wxID_MCRLIST,wxID_MCRSAVE,wxID_MCRPLAY, |
---|
156 | ] = [wx.NewId() for item in range(4)] |
---|
157 | |
---|
158 | VERY_LIGHT_GREY =Â wx.Colour(235,235,235) |
---|
159 | |
---|
160 | commonTrans =Â {'abc':np.eye(3),'a-cb':np.array([[1,0,0],[0,0,-1],[0,1,0]]), |
---|
161 | Â Â 'ba-c':np.array([[0,1,0],[1,0,0],[0,0,-1]]),'-cba':np.array([[0,0,-1],[0,1,0],[1,0,0]]), |
---|
162 | Â Â 'bca':np.array([[0,1,0],[0,0,1],[1,0,0]]),'cab':np.array([[0,0,1],[1,0,0],[0,1,0]]), |
---|
163 | Â Â 'P->R':np.array([[1,-1,0],[0,1,-1],[1,1,1]]),'R->P':np.array([[2./3,1./3,1./3],[-1./3,1./3,1./3],[-1./3,-2./3,1./3]]), |
---|
164 | Â Â 'P->A':np.array([[-1,0,0],[0,-1,1],[0,1,1]]),'R->O':np.array([[-1,0,0],[0,-1,0],[0,0,1]]), |
---|
165 | Â Â 'P->B':np.array([[-1,0,1],[0,-1,0],[1,0,1]]),'B->P':np.array([[-.5,0,.5],[0,-1,0],[.5,0,.5]]), |
---|
166 | Â Â 'P->C':np.array([[1,1,0],[1,-1,0],[0,0,-1]]),'C->P':np.array([[.5,.5,0],[.5,-.5,0],[0,0,-1]]), |
---|
167 |   'P->F':np.array([[-1,1,1],[1,-1,1],[1,1,-1]]),'F->P':np.array([[0,.5,.5],[.5,0,.5],[.5,.5,0]]),  |
---|
168 |   'P->I':np.array([[0,1,1],[1,0,1],[1,1,0]]),'I->P':np.array([[-.5,.5,.5],[.5,-.5,.5],[.5,.5,-.5]]),  |
---|
169 |   'A->P':np.array([[-1,0,0],[0,-.5,.5],[0,.5,.5]]),'O->R':np.array([[-1,0,0],[0,-1,0],[0,0,1]]), |
---|
170 |   'abc*':np.eye(3), } |
---|
171 | commonNames =Â ['abc','bca','cab','a-cb','ba-c','-cba','P->A','A->P','P->B','B->P','P->C','C->P', |
---|
172 | Â Â 'P->I','I->P','P->F','F->P','P->R','R->P','R->O','O->R','abc*',] |
---|
173 | |
---|
174 | # Should SGMessageBox, SymOpDialog, DisAglDialog be moved? |
---|
175 | |
---|
176 | ################################################################################ |
---|
177 | #### GSAS-II class definitions |
---|
178 | ################################################################################ |
---|
179 | |
---|
180 | class SGMessageBox(wx.Dialog): |
---|
181 | Â Â ''' Special version of MessageBox that displays space group & super space group text |
---|
182 | Â Â in two blocks |
---|
183 | Â Â ''' |
---|
184 |   def __init__(self,parent,title,text,table,): |
---|
185 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, |
---|
186 | Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
187 | Â Â Â Â self.text =Â text |
---|
188 | Â Â Â Â self.table =Â table |
---|
189 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
190 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
191 | Â Â Â Â mainSizer.Add((0,10)) |
---|
192 |     for line in text: |
---|
193 |       mainSizer.Add(wx.StaticText(self.panel,label='   %s   '%(line)),0,WACV) |
---|
194 | Â Â Â Â ncol =Â self.table[0].count(',')+1 |
---|
195 | Â Â Â Â tableSizer =Â wx.FlexGridSizer(0,2*ncol+3,0,0) |
---|
196 |     for j,item in enumerate(self.table): |
---|
197 | Â Â Â Â Â Â num,flds =Â item.split(')') |
---|
198 |       tableSizer.Add(wx.StaticText(self.panel,label='   %s '%(num+')')),0,WACV|wx.ALIGN_LEFT)      |
---|
199 | Â Â Â Â Â Â flds =Â flds.replace(' ','').split(',') |
---|
200 |       for i,fld in enumerate(flds): |
---|
201 |         if i < ncol-1: |
---|
202 | Â Â Â Â Â Â Â Â Â Â tableSizer.Add(wx.StaticText(self.panel,label='%s, '%(fld)),0,WACV|wx.ALIGN_RIGHT) |
---|
203 | Â Â Â Â Â Â Â Â else: |
---|
204 | Â Â Â Â Â Â Â Â Â Â tableSizer.Add(wx.StaticText(self.panel,label='%s'%(fld)),0,WACV|wx.ALIGN_RIGHT) |
---|
205 |       if not j%2: |
---|
206 | Â Â Â Â Â Â Â Â tableSizer.Add((20,0)) |
---|
207 | Â Â Â Â mainSizer.Add(tableSizer,0,wx.ALIGN_LEFT) |
---|
208 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
209 |     OKbtn = wx.Button(self.panel, wx.ID_OK) |
---|
210 |     OKbtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
211 | Â Â Â Â OKbtn.SetDefault() |
---|
212 | Â Â Â Â btnsizer.AddButton(OKbtn) |
---|
213 | Â Â Â Â btnsizer.Realize() |
---|
214 | Â Â Â Â mainSizer.Add((0,10)) |
---|
215 | Â Â Â Â mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) |
---|
216 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
217 | Â Â Â Â self.panel.Fit() |
---|
218 | Â Â Â Â self.Fit() |
---|
219 | Â Â Â Â size =Â self.GetSize() |
---|
220 | Â Â Â Â self.SetSize([size[0]+20,size[1]]) |
---|
221 | |
---|
222 |   def Show(self): |
---|
223 | Â Â Â Â '''Use this method after creating the dialog to post it |
---|
224 | Â Â Â Â ''' |
---|
225 | Â Â Â Â self.ShowModal() |
---|
226 | Â Â Â Â return |
---|
227 | |
---|
228 |   def OnOk(self,event): |
---|
229 | Â Â Â Â parent =Â self.GetParent() |
---|
230 | Â Â Â Â parent.Raise() |
---|
231 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
232 | |
---|
233 | class SGMagSpinBox(wx.Dialog): |
---|
234 | Â Â ''' Special version of MessageBox that displays magnetic spin text |
---|
235 | Â Â ''' |
---|
236 |   def __init__(self,parent,title,text,table,names,spins,): |
---|
237 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, |
---|
238 | Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,size=wx.Size(420,350)) |
---|
239 | Â Â Â Â self.text =Â text |
---|
240 | Â Â Â Â self.table =Â table |
---|
241 | Â Â Â Â self.names =Â names |
---|
242 | Â Â Â Â self.spins =Â spins |
---|
243 | Â Â Â Â self.panel =Â wxscroll.ScrolledPanel(self) |
---|
244 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
245 | Â Â Â Â mainSizer.Add((0,10)) |
---|
246 | Â Â Â Â first =Â text[0].split(':')[-1].strip() |
---|
247 | Â Â Â Â cents =Â [0,] |
---|
248 |     if 'P' != first[0]: |
---|
249 | Â Â Â Â Â Â cents =Â text[-1].split(';') |
---|
250 |     for line in text: |
---|
251 |       mainSizer.Add(wx.StaticText(self.panel,label='   %s   '%(line)),0,WACV) |
---|
252 | Â Â Â Â ncol =Â self.table[0].count(',')+2 |
---|
253 |     for ic,cent in enumerate(cents): |
---|
254 |       if cent: |
---|
255 | Â Â Â Â Â Â Â Â cent =Â cent.strip(' (').strip(')+\n')Â |
---|
256 | Â Â Â Â Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' for (%s)+'%(cent)),0,WACV) |
---|
257 | Â Â Â Â Â Â tableSizer =Â wx.FlexGridSizer(0,2*ncol+3,0,0) |
---|
258 |       for j,item in enumerate(self.table): |
---|
259 | Â Â Â Â Â Â Â Â flds =Â item.split(')')[1] |
---|
260 | Â Â Â Â Â Â Â Â tableSizer.Add(wx.StaticText(self.panel,label='Â (%2d)Â '%(j+1)),0,WACV|wx.ALIGN_LEFT)Â Â Â Â Â Â |
---|
261 | Â Â Â Â Â Â Â Â flds =Â flds.replace(' ','').split(',') |
---|
262 |         for i,fld in enumerate(flds): |
---|
263 |           if i < ncol-1: |
---|
264 | Â Â Â Â Â Â Â Â Â Â Â Â text =Â wx.StaticText(self.panel,label='%s, '%(fld)) |
---|
265 | Â Â Â Â Â Â Â Â Â Â Â Â tableSizer.Add(text,0,WACV|wx.ALIGN_RIGHT) |
---|
266 | Â Â Â Â Â Â Â Â Â Â else: |
---|
267 |             text = wx.StaticText(self.panel,label='%s '%(fld)) |
---|
268 | Â Â Â Â Â Â Â Â Â Â Â Â tableSizer.Add(text,0,WACV|wx.ALIGN_RIGHT) |
---|
269 | Â Â Â Â Â Â Â Â text =Â wx.StaticText(self.panel,label=' (%s) '%(self.names[j])) |
---|
270 |         if self.spins[j+ic*len(self.table)] < 0: |
---|
271 | Â Â Â Â Â Â Â Â Â Â text.SetForegroundColour('Red') |
---|
272 | Â Â Â Â Â Â Â Â tableSizer.Add(text,0,WACV|wx.ALIGN_RIGHT) |
---|
273 |         if not j%2: |
---|
274 | Â Â Â Â Â Â Â Â Â Â tableSizer.Add((20,0)) |
---|
275 | Â Â Â Â Â Â mainSizer.Add(tableSizer,0,wx.ALIGN_CENTER) |
---|
276 | Â Â Â Â Â Â |
---|
277 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
278 |     OKbtn = wx.Button(self.panel, wx.ID_OK) |
---|
279 | Â Â Â Â OKbtn.SetDefault() |
---|
280 | Â Â Â Â btnsizer.AddButton(OKbtn) |
---|
281 | Â Â Â Â btnsizer.Realize() |
---|
282 | Â Â Â Â mainSizer.Add((0,10)) |
---|
283 | Â Â Â Â mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) |
---|
284 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
285 | Â Â Â Â size =Â np.array(self.GetSize()) |
---|
286 | Â Â Â Â self.panel.SetupScrolling() |
---|
287 | Â Â Â Â size =Â [size[0]-5,size[1]-20]Â Â Â Â #this fiddling is needed for older wx! |
---|
288 | Â Â Â Â self.panel.SetSize(size) |
---|
289 | Â Â Â Â self.panel.SetAutoLayout(1) |
---|
290 | |
---|
291 |   def Show(self): |
---|
292 | Â Â Â Â '''Use this method after creating the dialog to post it |
---|
293 | Â Â Â Â ''' |
---|
294 | Â Â Â Â self.ShowModal() |
---|
295 |     return  |
---|
296 | |
---|
297 | ################################################################################ |
---|
298 | class SymOpDialog(wx.Dialog): |
---|
299 | Â Â '''Class to select a symmetry operator |
---|
300 | Â Â ''' |
---|
301 |   def __init__(self,parent,SGData,New=True,ForceUnit=False): |
---|
302 | Â Â Â Â wx.Dialog.__init__(self,parent,-1,'Select symmetry operator', |
---|
303 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
304 | Â Â Â Â panel =Â wx.Panel(self) |
---|
305 | Â Â Â Â self.SGData =Â SGData |
---|
306 | Â Â Â Â self.New =Â New |
---|
307 | Â Â Â Â self.Force =Â ForceUnit |
---|
308 | Â Â Â Â self.OpSelected =Â [0,0,0,[0,0,0],False,False] |
---|
309 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
310 |     if ForceUnit: |
---|
311 | Â Â Â Â Â Â choice =Â ['No','Yes'] |
---|
312 | Â Â Â Â Â Â self.force =Â wx.RadioBox(panel,-1,'Force to unit cell?',choices=choice) |
---|
313 |       self.force.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
314 | Â Â Â Â Â Â mainSizer.Add(self.force,0,WACV|wx.TOP,5) |
---|
315 | #Â Â Â Â if SGData['SGInv']: |
---|
316 | Â Â Â Â choice =Â ['No','Yes'] |
---|
317 | Â Â Â Â self.inv =Â wx.RadioBox(panel,-1,'Choose inversion?',choices=choice) |
---|
318 |     self.inv.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
319 | Â Â Â Â mainSizer.Add(self.inv,0,WACV) |
---|
320 |     if SGData['SGLatt'] != 'P': |
---|
321 | Â Â Â Â Â Â LattOp =Â G2spc.Latt2text(SGData['SGLatt']).split(';') |
---|
322 | Â Â Â Â Â Â self.latt =Â wx.RadioBox(panel,-1,'Choose cell centering?',choices=LattOp) |
---|
323 |       self.latt.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
324 | Â Â Â Â Â Â mainSizer.Add(self.latt,0,WACV) |
---|
325 |     if SGData['SGLaue'] in ['-1','2/m','mmm','4/m','4/mmm']: |
---|
326 | Â Â Â Â Â Â Ncol =Â 2 |
---|
327 | Â Â Â Â else: |
---|
328 | Â Â Â Â Â Â Ncol =Â 3 |
---|
329 | Â Â Â Â OpList =Â [] |
---|
330 |     for Opr in SGData['SGOps']: |
---|
331 | Â Â Â Â Â Â OpList.append(G2spc.MT2text(Opr)) |
---|
332 | Â Â Â Â self.oprs =Â wx.RadioBox(panel,-1,'Choose space group operator?',choices=OpList, |
---|
333 | Â Â Â Â Â Â majorDimension=Ncol) |
---|
334 |     self.oprs.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
335 | Â Â Â Â mainSizer.Add(self.oprs,0,WACV|wx.BOTTOM,5) |
---|
336 | Â Â Â Â mainSizer.Add(wx.StaticText(panel,-1,"Â Â Choose unit cell?"),0,WACV) |
---|
337 | Â Â Â Â cellSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
338 | Â Â Â Â cellName =Â ['X','Y','Z'] |
---|
339 | Â Â Â Â self.cell =Â [] |
---|
340 |     for i in range(3): |
---|
341 | Â Â Â Â Â Â self.cell.append(wx.SpinCtrl(panel,-1,cellName[i],size=wx.Size(50,20))) |
---|
342 | Â Â Â Â Â Â self.cell[-1].SetRange(-3,3) |
---|
343 | Â Â Â Â Â Â self.cell[-1].SetValue(0) |
---|
344 |       self.cell[-1].Bind(wx.EVT_SPINCTRL, self.OnOpSelect) |
---|
345 | Â Â Â Â Â Â cellSizer.Add(self.cell[-1],0,WACV) |
---|
346 | Â Â Â Â mainSizer.Add(cellSizer,0,WACV|wx.BOTTOM,5) |
---|
347 |     if self.New: |
---|
348 | Â Â Â Â Â Â choice =Â ['No','Yes'] |
---|
349 | Â Â Â Â Â Â self.new =Â wx.RadioBox(panel,-1,'Generate new positions?',choices=choice) |
---|
350 |       self.new.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
351 | Â Â Â Â Â Â mainSizer.Add(self.new,0,WACV) |
---|
352 | |
---|
353 | Â Â Â Â OkBtn =Â wx.Button(panel,-1,"Ok") |
---|
354 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
355 | Â Â Â Â cancelBtn =Â wx.Button(panel,-1,"Cancel") |
---|
356 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
357 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
358 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
359 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
360 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
361 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
362 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
363 | |
---|
364 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
365 | Â Â Â Â panel.SetSizer(mainSizer) |
---|
366 | Â Â Â Â panel.Fit() |
---|
367 | Â Â Â Â self.Fit() |
---|
368 | |
---|
369 |   def OnOpSelect(self,event): |
---|
370 | #Â Â Â Â if self.SGData['SGInv']: |
---|
371 | Â Â Â Â self.OpSelected[0]Â =Â self.inv.GetSelection() |
---|
372 |     if self.SGData['SGLatt'] != 'P': |
---|
373 | Â Â Â Â Â Â self.OpSelected[1]Â =Â self.latt.GetSelection() |
---|
374 | Â Â Â Â self.OpSelected[2]Â =Â self.oprs.GetSelection() |
---|
375 |     for i in range(3): |
---|
376 | Â Â Â Â Â Â self.OpSelected[3][i]Â =Â float(self.cell[i].GetValue()) |
---|
377 |     if self.New: |
---|
378 | Â Â Â Â Â Â self.OpSelected[4]Â =Â self.new.GetSelection() |
---|
379 |     if self.Force: |
---|
380 | Â Â Â Â Â Â self.OpSelected[5]Â =Â self.force.GetSelection() |
---|
381 | |
---|
382 |   def GetSelection(self): |
---|
383 |     return self.OpSelected |
---|
384 | |
---|
385 |   def OnOk(self,event): |
---|
386 | Â Â Â Â parent =Â self.GetParent() |
---|
387 | Â Â Â Â parent.Raise() |
---|
388 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
389 | |
---|
390 |   def OnCancel(self,event): |
---|
391 | Â Â Â Â parent =Â self.GetParent() |
---|
392 | Â Â Â Â parent.Raise() |
---|
393 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
394 | Â Â Â Â |
---|
395 | ################################################################################ |
---|
396 | class SphereEnclosure(wx.Dialog): |
---|
397 | Â Â ''' Add atoms within sphere of enclosure to drawing |
---|
398 | Â Â |
---|
399 | Â Â :param wx.Frame parent: reference to parent frame (or None) |
---|
400 | Â Â :param general: general data (includes drawing data) |
---|
401 | Â Â :param atoms: drawing atoms data |
---|
402 | Â Â :param indx: list of selected atoms (may be empty) |
---|
403 | Â Â |
---|
404 | Â Â ''' |
---|
405 |   def __init__(self,parent,general,drawing,indx): |
---|
406 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup phase transformation', |
---|
407 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
408 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
409 | Â Â Â Â self.General =Â general |
---|
410 | Â Â Â Â self.Drawing =Â drawing |
---|
411 | Â Â Â Â self.indx =Â indx |
---|
412 | Â Â Â Â self.Sphere =Â 1.0 |
---|
413 | Â Â Â Â self.centers =Â [] |
---|
414 |     self.atomTypes = [[item,True] for item in self.General['AtomTypes']] |
---|
415 | Â Â Â Â |
---|
416 | Â Â Â Â self.Draw() |
---|
417 | Â Â Â Â |
---|
418 |   def Draw(self): |
---|
419 | Â Â Â Â |
---|
420 |     def OnRadius(event): |
---|
421 | Â Â Â Â Â Â event.Skip() |
---|
422 | Â Â Â Â Â Â try: |
---|
423 | Â Â Â Â Â Â Â Â val =Â float(radius.GetValue()) |
---|
424 |         if val < 0.5: |
---|
425 |           raise ValueError |
---|
426 | Â Â Â Â Â Â Â Â self.Sphere =Â val |
---|
427 |       except ValueError: |
---|
428 | Â Â Â Â Â Â Â Â pass |
---|
429 | Â Â Â Â Â Â radius.SetValue('%.3f'%(self.Sphere)) |
---|
430 | Â Â Â Â Â Â |
---|
431 |     def OnAtomType(event): |
---|
432 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
433 |       id = Ind[Obj.GetId()] |
---|
434 | Â Â Â Â Â Â self.atomTypes[id][1]Â =Â Obj.GetValue() |
---|
435 | Â Â Â Â |
---|
436 | Â Â Â Â self.panel.Destroy() |
---|
437 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
438 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
439 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Sphere of enclosure controls:'),0,WACV) |
---|
440 | Â Â Â Â topSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
441 | Â Â Â Â atoms =Â [] |
---|
442 |     if len(self.indx): |
---|
443 | Â Â Â Â Â Â topSizer.Add(wx.StaticText(self.panel,label=' Sphere centered at atoms: '),0,WACV) |
---|
444 | Â Â Â Â Â Â cx,ct,cs =Â self.Drawing['atomPtrs'][:3] |
---|
445 | #Â Â Â Â Â Â print self.Drawing.keys() |
---|
446 |       for id in self.indx: |
---|
447 | Â Â Â Â Â Â Â Â atom =Â self.Drawing['Atoms'][id] |
---|
448 | Â Â Â Â Â Â Â Â self.centers.append(atom[cx:cx+3]) |
---|
449 | Â Â Â Â Â Â Â Â atoms.append('%s(%s)'%(atom[ct-1],atom[cs-1])) |
---|
450 | Â Â Â Â Â Â topSizer.Add(wx.ComboBox(self.panel,choices=atoms,value=atoms[0], |
---|
451 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN),0,WACV) |
---|
452 | Â Â Â Â else: |
---|
453 | Â Â Â Â Â Â topSizer.Add(wx.StaticText(self.panel,label=' Sphere centered at drawing view point'),0,WACV) |
---|
454 | Â Â Â Â Â Â self.centers.append(self.Drawing['viewPoint'][0]) |
---|
455 | Â Â Â Â mainSizer.Add(topSizer,0,WACV) |
---|
456 | Â Â Â Â sphereSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
457 | Â Â Â Â sphereSizer.Add(wx.StaticText(self.panel,label=' Sphere radius: '),0,WACV) |
---|
458 | Â Â Â Â radius =Â wx.TextCtrl(self.panel,value='%.3f'%(self.Sphere),style=wx.TE_PROCESS_ENTER) |
---|
459 | Â Â Â Â radius.Bind(wx.EVT_TEXT_ENTER,OnRadius) |
---|
460 | Â Â Â Â radius.Bind(wx.EVT_KILL_FOCUS,OnRadius) |
---|
461 | Â Â Â Â sphereSizer.Add(radius,0,WACV) |
---|
462 | Â Â Â Â mainSizer.Add(sphereSizer,0,WACV) |
---|
463 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Target selected atoms:'),0,WACV) |
---|
464 | Â Â Â Â atSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
465 | Â Â Â Â Ind =Â {} |
---|
466 |     for i,item in enumerate(self.atomTypes): |
---|
467 | Â Â Â Â Â Â atm =Â wx.CheckBox(self.panel,label=item[0]) |
---|
468 | Â Â Â Â Â Â atm.SetValue(item[1]) |
---|
469 |       atm.Bind(wx.EVT_CHECKBOX, OnAtomType) |
---|
470 | Â Â Â Â Â Â Ind[atm.GetId()]Â =Â i |
---|
471 | Â Â Â Â Â Â atSizer.Add(atm,0,WACV) |
---|
472 | Â Â Â Â mainSizer.Add(atSizer,0,WACV) |
---|
473 | Â Â Â Â |
---|
474 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
475 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
476 | Â Â Â Â cancelBtn =Â wx.Button(self.panel,-1,"Cancel") |
---|
477 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
478 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
479 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
480 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
481 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
482 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
483 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
484 | Â Â Â Â |
---|
485 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
486 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
487 | Â Â Â Â self.panel.Fit() |
---|
488 | Â Â Â Â self.Fit() |
---|
489 | Â Â Â Â |
---|
490 |   def GetSelection(self): |
---|
491 | Â Â Â Â used =Â [] |
---|
492 |     for atm in self.atomTypes: |
---|
493 |       if atm[1]: |
---|
494 | Â Â Â Â Â Â Â Â used.append(str(atm[0])) |
---|
495 |     return self.centers,self.Sphere,used |
---|
496 | |
---|
497 |   def OnOk(self,event): |
---|
498 | Â Â Â Â parent =Â self.GetParent() |
---|
499 | Â Â Â Â parent.Raise() |
---|
500 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
501 | |
---|
502 |   def OnCancel(self,event): |
---|
503 | Â Â Â Â parent =Â self.GetParent() |
---|
504 | Â Â Â Â parent.Raise() |
---|
505 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
506 | Â Â Â Â |
---|
507 | ################################################################################ |
---|
508 | class TransformDialog(wx.Dialog): |
---|
509 | Â Â ''' Phase transformation |
---|
510 | Â Â |
---|
511 | Â Â :param wx.Frame parent: reference to parent frame (or None) |
---|
512 | Â Â :param phase: phase data |
---|
513 | Â Â |
---|
514 | Â Â #NB: commonNames & commonTrans defined at top of this file |
---|
515 | Â Â ''' |
---|
516 |   def __init__(self,parent,phase): |
---|
517 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup phase transformation', |
---|
518 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
519 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
520 | Â Â Â Â self.Phase =Â copy.deepcopy(phase)Â Â #will be a new phase! |
---|
521 | #Â Â Â Â self.Super = phase['General']['Super'] |
---|
522 | #Â Â Â Â if self.Super: |
---|
523 | #Â Â Â Â Â Â self.Trans = np.eye(4) |
---|
524 | #Â Â Â Â Â Â self.Vec = np.zeros(4) |
---|
525 | #Â Â Â Â else: |
---|
526 | Â Â Â Â self.Trans =Â np.eye(3) |
---|
527 | Â Â Â Â self.Vec =Â np.zeros(3) |
---|
528 | Â Â Â Â self.oldSpGrp =Â phase['General']['SGData']['SpGrp'] |
---|
529 | Â Â Â Â self.oldSGdata =Â phase['General']['SGData'] |
---|
530 | Â Â Â Â self.newSpGrp =Â self.Phase['General']['SGData']['SpGrp'] |
---|
531 | Â Â Â Â self.oldCell =Â phase['General']['Cell'][1:8] |
---|
532 | Â Â Â Â self.newCell =Â self.Phase['General']['Cell'][1:8] |
---|
533 | Â Â Â Â self.Common =Â 'abc' |
---|
534 | Â Â Â Â self.ifMag =Â False |
---|
535 | Â Â Â Â self.ifConstr =Â True |
---|
536 | Â Â Â Â self.Draw() |
---|
537 | |
---|
538 |   def Draw(self): |
---|
539 | Â Â Â Â Â Â Â Â |
---|
540 |     def OnMatValue(event): |
---|
541 | Â Â Â Â Â Â event.Skip() |
---|
542 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
543 | Â Â Â Â Â Â ix,iy =Â Ind[Obj.GetId()] |
---|
544 | Â Â Â Â Â Â val =Â Obj.GetValue() |
---|
545 | Â Â Â Â Â Â try: |
---|
546 |         if '/' in val: |
---|
547 | Â Â Â Â Â Â Â Â Â Â vals =Â val.split('/') |
---|
548 | Â Â Â Â Â Â Â Â Â Â self.Trans[iy,ix]Â =Â float(vals[0])/float(vals[1]) |
---|
549 | Â Â Â Â Â Â Â Â else:Â Â |
---|
550 | Â Â Â Â Â Â Â Â Â Â self.Trans[iy,ix]Â =Â float(Obj.GetValue()) |
---|
551 |       except ValueError: |
---|
552 | Â Â Â Â Â Â Â Â pass |
---|
553 | Â Â Â Â Â Â Obj.SetValue('%5.3f'%(self.Trans[iy,ix])) |
---|
554 | Â Â Â Â Â Â |
---|
555 |     def OnVecValue(event): |
---|
556 | Â Â Â Â Â Â event.Skip() |
---|
557 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
558 | Â Â Â Â Â Â iy =Â Ind[Obj.GetId()] |
---|
559 | Â Â Â Â Â Â val =Â Obj.GetValue() |
---|
560 | Â Â Â Â Â Â try: |
---|
561 |         if '/' in val: |
---|
562 | Â Â Â Â Â Â Â Â Â Â vals =Â val.split('/') |
---|
563 | Â Â Â Â Â Â Â Â Â Â self.Vec[iy]Â =Â float(vals[0])/float(vals[1]) |
---|
564 | Â Â Â Â Â Â Â Â else:Â Â |
---|
565 | Â Â Â Â Â Â Â Â Â Â self.Vec[iy]Â =Â float(Obj.GetValue()) |
---|
566 |       except ValueError: |
---|
567 | Â Â Â Â Â Â Â Â pass |
---|
568 | Â Â Â Â Â Â Obj.SetValue('%5.3f'%(self.Vec[iy])) |
---|
569 | Â Â Â Â Â Â Â Â |
---|
570 |     def OnCommon(event): |
---|
571 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
572 | Â Â Â Â Â Â self.Common =Â Obj.GetValue() |
---|
573 |       if '*' in self.Common: |
---|
574 | Â Â Â Â Â Â Â Â A,B =Â G2lat.cell2AB(self.oldCell[:6]) |
---|
575 | Â Â Â Â Â Â Â Â self.newCell[2:5]Â =Â [A[2,2],90.,90.] |
---|
576 | Â Â Â Â Â Â Â Â a,b =Â G2lat.cell2AB(self.newCell[:6]) |
---|
577 | Â Â Â Â Â Â Â Â self.Trans =Â np.inner(a.T,B)Â Â #correct! |
---|
578 | Â Â Â Â Â Â Â Â self.newSpGrp =Â 'P 1' |
---|
579 | Â Â Â Â Â Â Â Â SGErr,SGData =Â G2spc.SpcGroup(self.newSpGrp) |
---|
580 | Â Â Â Â Â Â Â Â self.Phase['General']['SGData']Â =Â SGData |
---|
581 | Â Â Â Â Â Â else: |
---|
582 | Â Â Â Â Â Â Â Â self.Trans =Â commonTrans[self.Common] |
---|
583 | Â Â Â Â Â Â OnTest(event) |
---|
584 | Â Â Â Â |
---|
585 |     def OnSpaceGroup(event): |
---|
586 | Â Â Â Â Â Â event.Skip() |
---|
587 | Â Â Â Â Â Â Flds =Â SGTxt.GetValue().split() |
---|
588 | Â Â Â Â Â Â Flds[0]Â =Â Flds[0].upper() |
---|
589 | Â Â Â Â Â Â #get rid of extra spaces between fields first |
---|
590 |       for fld in Flds: fld = fld.strip() |
---|
591 | Â Â Â Â Â Â SpcGp =Â ' '.join(Flds) |
---|
592 |       if SpcGp == self.newSpGrp: #didn't change it! |
---|
593 | Â Â Â Â Â Â Â Â return |
---|
594 | Â Â Â Â Â Â # try a lookup on the user-supplied name |
---|
595 | Â Â Â Â Â Â SpGrpNorm =Â G2spc.StandardizeSpcName(SpcGp) |
---|
596 |       if SpGrpNorm: |
---|
597 | Â Â Â Â Â Â Â Â SGErr,SGData =Â G2spc.SpcGroup(SpGrpNorm) |
---|
598 | Â Â Â Â Â Â else: |
---|
599 | Â Â Â Â Â Â Â Â SGErr,SGData =Â G2spc.SpcGroup(SpcGp) |
---|
600 |       if SGErr: |
---|
601 | Â Â Â Â Â Â Â Â text =Â [G2spc.SGErrors(SGErr)+'\nSpace Group set to previous'] |
---|
602 | Â Â Â Â Â Â Â Â SGTxt.SetValue(self.newSpGrp) |
---|
603 | Â Â Â Â Â Â Â Â msg =Â 'Space Group Error' |
---|
604 | Â Â Â Â Â Â Â Â Style =Â wx.ICON_EXCLAMATION |
---|
605 | Â Â Â Â Â Â Â Â Text =Â '\n'.join(text) |
---|
606 | Â Â Â Â Â Â Â Â wx.MessageBox(Text,caption=msg,style=Style) |
---|
607 | Â Â Â Â Â Â else: |
---|
608 | Â Â Â Â Â Â Â Â text,table =Â G2spc.SGPrint(SGData) |
---|
609 | Â Â Â Â Â Â Â Â self.Phase['General']['SGData']Â =Â SGData |
---|
610 | Â Â Â Â Â Â Â Â self.newSpGrp =Â SpcGp |
---|
611 | Â Â Â Â Â Â Â Â SGTxt.SetValue(self.Phase['General']['SGData']['SpGrp']) |
---|
612 | Â Â Â Â Â Â Â Â msg =Â 'Space Group Information' |
---|
613 | Â Â Â Â Â Â Â Â SGMessageBox(self.panel,msg,text,table).Show() |
---|
614 |       if self.Phase['General']['Type'] == 'magnetic': |
---|
615 | Â Â Â Â Â Â Â Â Nops =Â len(SGData['SGOps'])*len(SGData['SGCen']) |
---|
616 |         if SGData['SGInv']: |
---|
617 | Â Â Â Â Â Â Â Â Â Â Nops *=Â 2 |
---|
618 | Â Â Â Â Â Â Â Â SGData['SpnFlp']Â =Â Nops*[1,] |
---|
619 | #Â Â Â Â Â Â if self.Phase['General']['Type'] in ['modulated',]: |
---|
620 | #Â Â Â Â Â Â Â Â self.Phase['General']['SuperSg'] = SetDefaultSSsymbol() |
---|
621 | #Â Â Â Â Â Â Â Â self.Phase['General']['SSGData'] = G2spc.SSpcGroup(generalData['SGData'],generalData['SuperSg'])[1] |
---|
622 | |
---|
623 |     def OnTest(event): |
---|
624 | Â Â Â Â Â Â self.newCell =Â G2lat.TransformCell(self.oldCell[:6],self.Trans) |
---|
625 | Â Â Â Â Â Â wx.CallAfter(self.Draw) |
---|
626 | Â Â Â Â Â Â |
---|
627 |     def OnMag(event): |
---|
628 | Â Â Â Â Â Â self.ifMag =Â mag.GetValue() |
---|
629 | Â Â Â Â Â Â |
---|
630 |     def OnConstr(event): |
---|
631 | Â Â Â Â Â Â self.ifConstr =Â constr.GetValue() |
---|
632 | |
---|
633 | Â Â Â Â self.panel.Destroy() |
---|
634 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
635 | Â Â Â Â Ind =Â {} |
---|
636 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
637 | Â Â Â Â MatSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
638 | Â Â Â Â transSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
639 | Â Â Â Â transSizer.Add(wx.StaticText(self.panel,label=" XYZ Transformation matrix & vector: M*X+V = X'")) |
---|
640 | #Â Â Â Â if self.Super: |
---|
641 | #Â Â Â Â Â Â Trmat = wx.FlexGridSizer(4,4,0,0) |
---|
642 | #Â Â Â Â else: |
---|
643 | Â Â Â Â commonSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
644 | Â Â Â Â commonSizer.Add(wx.StaticText(self.panel,label=' Common transformations: '),0,WACV) |
---|
645 | Â Â Â Â common =Â wx.ComboBox(self.panel,value=self.Common,choices=commonNames, |
---|
646 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
647 | Â Â Â Â common.Bind(wx.EVT_COMBOBOX,OnCommon) |
---|
648 | Â Â Â Â commonSizer.Add(common,0,WACV) |
---|
649 | Â Â Â Â transSizer.Add(commonSizer) |
---|
650 | Â Â Â Â Trmat =Â wx.FlexGridSizer(3,5,0,0) |
---|
651 |     for iy,line in enumerate(self.Trans): |
---|
652 |       for ix,val in enumerate(line): |
---|
653 | Â Â Â Â Â Â Â Â item =Â wx.TextCtrl(self.panel,value='%5.3f'%(val), |
---|
654 | Â Â Â Â Â Â Â Â Â Â size=(50,25),style=wx.TE_PROCESS_ENTER) |
---|
655 | Â Â Â Â Â Â Â Â Ind[item.GetId()]Â =Â [ix,iy] |
---|
656 | Â Â Â Â Â Â Â Â item.Bind(wx.EVT_TEXT_ENTER,OnMatValue) |
---|
657 | Â Â Â Â Â Â Â Â item.Bind(wx.EVT_KILL_FOCUS,OnMatValue) |
---|
658 | Â Â Â Â Â Â Â Â Trmat.Add(item) |
---|
659 | Â Â Â Â Â Â Trmat.Add((25,0),0) |
---|
660 | Â Â Â Â Â Â vec =Â wx.TextCtrl(self.panel,value='%5.3f'%(self.Vec[iy]), |
---|
661 | Â Â Â Â Â Â Â Â Â Â size=(50,25),style=wx.TE_PROCESS_ENTER) |
---|
662 | Â Â Â Â Â Â Ind[vec.GetId()]Â =Â [iy]Â Â Â Â |
---|
663 | Â Â Â Â Â Â vec.Bind(wx.EVT_TEXT_ENTER,OnVecValue) |
---|
664 | Â Â Â Â Â Â vec.Bind(wx.EVT_KILL_FOCUS,OnVecValue) |
---|
665 | Â Â Â Â Â Â Trmat.Add(vec) |
---|
666 | Â Â Â Â transSizer.Add(Trmat) |
---|
667 | Â Â Â Â MatSizer.Add((10,0),0) |
---|
668 | Â Â Â Â MatSizer.Add(transSizer) |
---|
669 | Â Â Â Â mainSizer.Add(MatSizer) |
---|
670 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Old lattice parameters:'),0,WACV) |
---|
671 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label= |
---|
672 |       ' a = %.5f    b = %.5f   c = %.5f'%(self.oldCell[0],self.oldCell[1],self.oldCell[2])),0,WACV) |
---|
673 |     mainSizer.Add(wx.StaticText(self.panel,label=' alpha = %.3f beta = %.3f gamma = %.3f'% |
---|
674 | Â Â Â Â Â Â (self.oldCell[3],self.oldCell[4],self.oldCell[5])),0,WACV) |
---|
675 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' volume = %.3f'%(self.oldCell[6])),0,WACV) |
---|
676 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' New lattice parameters:'),0,WACV) |
---|
677 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label= |
---|
678 |       ' a = %.5f    b = %.5f   c = %.5f'%(self.newCell[0],self.newCell[1],self.newCell[2])),0,WACV) |
---|
679 |     mainSizer.Add(wx.StaticText(self.panel,label=' alpha = %.3f beta = %.3f gamma = %.3f'% |
---|
680 | Â Â Â Â Â Â (self.newCell[3],self.newCell[4],self.newCell[5])),0,WACV) |
---|
681 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' volume = %.3f'%(self.newCell[6])),0,WACV) |
---|
682 | Â Â Â Â sgSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
683 | Â Â Â Â sgSizer.Add(wx.StaticText(self.panel,label='Â Space group: '),0,WACV) |
---|
684 | Â Â Â Â SGTxt =Â wx.TextCtrl(self.panel,value=self.newSpGrp,style=wx.TE_PROCESS_ENTER) |
---|
685 | Â Â Â Â SGTxt.Bind(wx.EVT_TEXT_ENTER,OnSpaceGroup) |
---|
686 | Â Â Â Â SGTxt.Bind(wx.EVT_KILL_FOCUS,OnSpaceGroup) |
---|
687 | Â Â Â Â sgSizer.Add(SGTxt,0,WACV) |
---|
688 | Â Â Â Â mainSizer.Add(sgSizer,0,WACV) |
---|
689 |     if 'magnetic' not in self.Phase['General']['Type']: |
---|
690 | Â Â Â Â Â Â mag =Â wx.CheckBox(self.panel,label=' Make new phase magnetic?') |
---|
691 | Â Â Â Â Â Â mag.Bind(wx.EVT_CHECKBOX,OnMag) |
---|
692 | Â Â Â Â Â Â mainSizer.Add(mag,0,WACV) |
---|
693 |       mainSizer.Add(wx.StaticText(self.panel, \ |
---|
694 | Â Â Â Â Â Â Â Â label=' NB: Nonmagnetic atoms will be deleted from new phase'),0,WACV) |
---|
695 | Â Â Â Â Â Â constr =Â wx.CheckBox(self.panel,label=' Make constraints between phases?') |
---|
696 |       mainSizer.Add(wx.StaticText(self.panel, \ |
---|
697 | Â Â Â Â Â Â Â Â label=' Constraints not correct for non-diagonal transforms'),0,WACV) |
---|
698 | Â Â Â Â Â Â constr.SetValue(self.ifConstr) |
---|
699 | Â Â Â Â Â Â constr.Bind(wx.EVT_CHECKBOX,OnConstr) |
---|
700 | Â Â Â Â Â Â mainSizer.Add(constr,0,WACV) |
---|
701 | |
---|
702 | Â Â Â Â TestBtn =Â wx.Button(self.panel,-1,"Test") |
---|
703 |     TestBtn.Bind(wx.EVT_BUTTON, OnTest) |
---|
704 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
705 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
706 | Â Â Â Â cancelBtn =Â wx.Button(self.panel,-1,"Cancel") |
---|
707 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
708 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
709 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
710 | Â Â Â Â btnSizer.Add(TestBtn) |
---|
711 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
712 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
713 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
714 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
715 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
716 | Â Â Â Â |
---|
717 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
718 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
719 | Â Â Â Â self.panel.Fit() |
---|
720 | Â Â Â Â self.Fit() |
---|
721 | Â Â Â Â |
---|
722 |   def GetSelection(self): |
---|
723 |     if self.ifMag: |
---|
724 | Â Â Â Â Â Â self.Phase['General']['Name']Â +=Â ' mag' |
---|
725 | Â Â Â Â else: |
---|
726 | Â Â Â Â Â Â self.Phase['General']['Name']Â +=Â ' %s'%(self.Common) |
---|
727 | Â Â Â Â self.Phase['General']['Cell'][1:]Â =Â G2lat.TransformCell(self.oldCell[:6],self.Trans)Â Â Â Â Â Â |
---|
728 |     return self.Phase,self.Trans,self.Vec,self.ifMag,self.ifConstr |
---|
729 | |
---|
730 |   def OnOk(self,event): |
---|
731 | Â Â Â Â parent =Â self.GetParent() |
---|
732 | Â Â Â Â parent.Raise() |
---|
733 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
734 | |
---|
735 |   def OnCancel(self,event): |
---|
736 | Â Â Â Â parent =Â self.GetParent() |
---|
737 | Â Â Â Â parent.Raise() |
---|
738 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
739 | ################################################################################ |
---|
740 | class UseMagAtomDialog(wx.Dialog): |
---|
741 | Â Â '''Get user selected magnetic atoms after cell transformation |
---|
742 | Â Â ''' |
---|
743 |   def __init__(self,parent,Atoms,atCodes): |
---|
744 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'Magnetic atom selection', |
---|
745 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
746 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
747 | Â Â Â Â self.Atoms =Â Atoms |
---|
748 | Â Â Â Â self.atCodes =Â atCodes |
---|
749 | Â Â Â Â self.Use =Â len(self.Atoms)*[True,] |
---|
750 | Â Â Â Â self.Draw() |
---|
751 | Â Â Â Â |
---|
752 |   def Draw(self): |
---|
753 | Â Â Â Â |
---|
754 |     def OnUseChk(event): |
---|
755 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
756 | Â Â Â Â Â Â iuse =Â Indx[Obj.GetId()] |
---|
757 |       self.Use[iuse] = not self.Use[iuse] |
---|
758 | Â Â Â Â Â Â Obj.SetValue(self.Use[iuse]) |
---|
759 | Â Â Â Â |
---|
760 | Â Â Â Â self.panel.Destroy() |
---|
761 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
762 | Â Â Â Â Indx =Â {} |
---|
763 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
764 | Â Â Â Â |
---|
765 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z:'),0,WACV) |
---|
766 | Â Â Â Â atmSizer =Â wx.FlexGridSizer(0,2,5,5) |
---|
767 |     for iuse,[use,atom] in enumerate(zip(self.Use,self.Atoms)): |
---|
768 | Â Â Â Â Â Â useChk =Â wx.CheckBox(self.panel,label='Use?') |
---|
769 | Â Â Â Â Â Â Indx[useChk.GetId()]Â =Â iuse |
---|
770 | Â Â Â Â Â Â useChk.SetValue(use) |
---|
771 |       useChk.Bind(wx.EVT_CHECKBOX, OnUseChk) |
---|
772 | Â Â Â Â Â Â atmSizer.Add(useChk,0,WACV) |
---|
773 |       text = ' %s %10.5f %10.5f %10.5f'%(atom[0],atom[3],atom[4],atom[5]) |
---|
774 | Â Â Â Â Â Â atmSizer.Add(wx.StaticText(self.panel,label=text),0,WACV) |
---|
775 | Â Â Â Â mainSizer.Add(atmSizer) |
---|
776 | Â Â Â Â |
---|
777 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
778 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
779 | Â Â Â Â cancelBtn =Â wx.Button(self.panel,-1,"Use All") |
---|
780 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
781 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
782 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
783 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
784 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
785 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
786 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
787 | Â Â Â Â |
---|
788 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
789 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
790 | Â Â Â Â self.panel.Fit() |
---|
791 | Â Â Â Â self.Fit() |
---|
792 | Â Â Â Â |
---|
793 |   def GetSelection(self): |
---|
794 | Â Â Â Â useAtoms =Â [] |
---|
795 | Â Â Â Â useatCodes =Â [] |
---|
796 |     for use,atom,code in zip(self.Use,self.Atoms,self.atCodes): |
---|
797 |       if use: |
---|
798 | Â Â Â Â Â Â Â Â useAtoms.append(atom) |
---|
799 | Â Â Â Â Â Â Â Â useatCodes.append(code) |
---|
800 |     return useAtoms,useatCodes |
---|
801 | |
---|
802 |   def OnOk(self,event): |
---|
803 | Â Â Â Â parent =Â self.GetParent() |
---|
804 | Â Â Â Â parent.Raise() |
---|
805 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
806 | |
---|
807 |   def OnCancel(self,event): |
---|
808 | Â Â Â Â parent =Â self.GetParent() |
---|
809 | Â Â Â Â parent.Raise() |
---|
810 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
811 | Â Â Â Â Â Â |
---|
812 | Â Â Â Â Â Â Â Â |
---|
813 | ################################################################################ |
---|
814 | class RotationDialog(wx.Dialog): |
---|
815 | Â Â ''' Get Rotate & translate matrix & vector - currently not used |
---|
816 | Â Â needs rethinking - possible use to rotate a group of atoms about some |
---|
817 | Â Â vector/origin + translation |
---|
818 | Â Â |
---|
819 | Â Â ''' |
---|
820 |   def __init__(self,parent): |
---|
821 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'Atom group rotation/translation', |
---|
822 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
823 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
824 | Â Â Â Â self.Trans =Â np.eye(3) |
---|
825 | Â Â Â Â self.Vec =Â np.zeros(3) |
---|
826 | Â Â Â Â self.rotAngle =Â 0. |
---|
827 | Â Â Â Â self.rotVec =Â np.array([0.,0.,1.]) |
---|
828 | Â Â Â Â self.Expand =Â '' |
---|
829 | Â Â Â Â self.Draw() |
---|
830 | |
---|
831 |   def Draw(self): |
---|
832 | |
---|
833 |     def OnMatValue(event): |
---|
834 | Â Â Â Â Â Â event.Skip() |
---|
835 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
836 | Â Â Â Â Â Â ix,iy =Â Ind[Obj.GetId()] |
---|
837 | Â Â Â Â Â Â val =Â Obj.GetValue() |
---|
838 |       if '/' in val: |
---|
839 | Â Â Â Â Â Â Â Â vals =Â val.split('/') |
---|
840 | Â Â Â Â Â Â Â Â self.Trans[iy,ix]Â =Â float(vals[0])/float(vals[1]) |
---|
841 | Â Â Â Â Â Â else:Â Â |
---|
842 | Â Â Â Â Â Â Â Â self.Trans[iy,ix]Â =Â float(Obj.GetValue()) |
---|
843 | Â Â Â Â Â Â Obj.SetValue('%5.3f'%(self.Trans[iy,ix])) |
---|
844 | Â Â Â Â Â Â |
---|
845 | Â Â Â Â Â Â |
---|
846 |     def OnVecValue(event): |
---|
847 | Â Â Â Â Â Â event.Skip() |
---|
848 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
849 | Â Â Â Â Â Â iy =Â Ind[Obj.GetId()] |
---|
850 | Â Â Â Â Â Â val =Â Obj.GetValue() |
---|
851 |       if '/' in val: |
---|
852 | Â Â Â Â Â Â Â Â vals =Â val.split('/') |
---|
853 | Â Â Â Â Â Â Â Â self.Vec[iy]Â =Â float(vals[0])/float(vals[1]) |
---|
854 | Â Â Â Â Â Â else:Â Â |
---|
855 | Â Â Â Â Â Â Â Â self.Vec[iy]Â =Â float(Obj.GetValue()) |
---|
856 | Â Â Â Â Â Â Obj.SetValue('%5.3f'%(self.Vec[iy])) |
---|
857 | Â Â Â Â Â Â |
---|
858 |     def OnExpand(event): |
---|
859 | Â Â Â Â Â Â self.Expand =Â expand.GetValue() |
---|
860 | Â Â Â Â Â Â |
---|
861 |     def OnRotAngle(event): |
---|
862 | Â Â Â Â Â Â event.Skip() |
---|
863 | Â Â Â Â Â Â self.rotAngle =Â float(rotangle.GetValue()) |
---|
864 | Â Â Â Â Â Â rotangle.SetValue('%5.3f'%(self.rotAngle)) |
---|
865 | Â Â Â Â Â Â Q =Â G2mth.AVdeg2Q(self.rotAngle,self.rotVec) |
---|
866 | Â Â Â Â Â Â self.Trans =Â G2mth.Q2Mat(Q) |
---|
867 | Â Â Â Â Â Â self.Draw() |
---|
868 | Â Â Â Â Â Â |
---|
869 |     def OnRotVec(event): |
---|
870 | Â Â Â Â Â Â event.Skip() |
---|
871 | Â Â Â Â Â Â vals =Â rotvec.GetValue() |
---|
872 | Â Â Â Â Â Â vals =Â vals.split() |
---|
873 |       self.rotVec = np.array([float(val) for val in vals]) |
---|
874 |       rotvec.SetValue('%5.3f %5.3f %5.3f'%(self.rotVec[0],self.rotVec[1],self.rotVec[2])) |
---|
875 | Â Â Â Â Â Â Q =Â G2mth.AVdeg2Q(self.rotAngle,self.rotVec) |
---|
876 | Â Â Â Â Â Â self.Trans =Â G2mth.Q2Mat(Q) |
---|
877 | Â Â Â Â Â Â self.Draw() |
---|
878 | Â Â Â Â Â Â |
---|
879 | Â Â Â Â self.panel.Destroy() |
---|
880 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
881 | Â Â Â Â Ind =Â {} |
---|
882 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
883 | Â Â Â Â MatSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
884 | Â Â Â Â transSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
885 | Â Â Â Â transSizer.Add(wx.StaticText(self.panel,label=" XYZ Transformation matrix && vector: "+Â \ |
---|
886 |       "\n B*M*A*(X-V)+V = X'\n A,B: Cartesian transformation matrices")) |
---|
887 | Â Â Â Â Trmat =Â wx.FlexGridSizer(3,5,0,0) |
---|
888 |     for iy,line in enumerate(self.Trans): |
---|
889 |       for ix,val in enumerate(line): |
---|
890 | Â Â Â Â Â Â Â Â item =Â wx.TextCtrl(self.panel,value='%5.3f'%(val), |
---|
891 | Â Â Â Â Â Â Â Â Â Â size=(50,25),style=wx.TE_PROCESS_ENTER) |
---|
892 | Â Â Â Â Â Â Â Â Ind[item.GetId()]Â =Â [ix,iy] |
---|
893 | Â Â Â Â Â Â Â Â item.Bind(wx.EVT_TEXT_ENTER,OnMatValue) |
---|
894 | Â Â Â Â Â Â Â Â item.Bind(wx.EVT_KILL_FOCUS,OnMatValue) |
---|
895 | Â Â Â Â Â Â Â Â Trmat.Add(item) |
---|
896 | Â Â Â Â Â Â Trmat.Add((25,0),0) |
---|
897 | Â Â Â Â Â Â vec =Â wx.TextCtrl(self.panel,value='%5.3f'%(self.Vec[iy]), |
---|
898 | Â Â Â Â Â Â Â Â Â Â size=(50,25),style=wx.TE_PROCESS_ENTER) |
---|
899 | Â Â Â Â Â Â Ind[vec.GetId()]Â =Â [iy]Â Â Â Â |
---|
900 | Â Â Â Â Â Â vec.Bind(wx.EVT_TEXT_ENTER,OnVecValue) |
---|
901 | Â Â Â Â Â Â vec.Bind(wx.EVT_KILL_FOCUS,OnVecValue) |
---|
902 | Â Â Â Â Â Â Trmat.Add(vec) |
---|
903 | Â Â Â Â transSizer.Add(Trmat) |
---|
904 | Â Â Â Â MatSizer.Add((10,0),0) |
---|
905 | Â Â Â Â MatSizer.Add(transSizer) |
---|
906 | Â Â Â Â mainSizer.Add(MatSizer) |
---|
907 | Â Â Â Â rotationBox =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
908 | Â Â Â Â rotationBox.Add(wx.StaticText(self.panel,label=' Rotation angle: '),0,WACV) |
---|
909 | Â Â Â Â rotangle =Â wx.TextCtrl(self.panel,value='%5.3f'%(self.rotAngle), |
---|
910 | Â Â Â Â Â Â size=(50,25),style=wx.TE_PROCESS_ENTER) |
---|
911 | Â Â Â Â rotangle.Bind(wx.EVT_TEXT_ENTER,OnRotAngle) |
---|
912 | Â Â Â Â rotangle.Bind(wx.EVT_KILL_FOCUS,OnRotAngle) |
---|
913 | Â Â Â Â rotationBox.Add(rotangle,0,WACV) |
---|
914 | Â Â Â Â rotationBox.Add(wx.StaticText(self.panel,label=' about vector: '),0,WACV) |
---|
915 |     rotvec = wx.TextCtrl(self.panel,value='%5.3f %5.3f %5.3f'%(self.rotVec[0],self.rotVec[1],self.rotVec[2]), |
---|
916 | Â Â Â Â Â Â size=(100,25),style=wx.TE_PROCESS_ENTER) |
---|
917 | Â Â Â Â rotvec.Bind(wx.EVT_TEXT_ENTER,OnRotVec) |
---|
918 | Â Â Â Â rotvec.Bind(wx.EVT_KILL_FOCUS,OnRotVec) |
---|
919 | Â Â Â Â rotationBox.Add(rotvec,0,WACV) |
---|
920 | Â Â Â Â mainSizer.Add(rotationBox,0,WACV) |
---|
921 | Â Â Â Â expandChoice =Â ['','xy','xz','yz','xyz'] |
---|
922 | Â Â Â Â expandBox =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
923 | Â Â Â Â expandBox.Add(wx.StaticText(self.panel,label=' Expand -1 to +1 on: '),0,WACV) |
---|
924 | Â Â Â Â expand =Â wx.ComboBox(self.panel,value=self.Expand,choices=expandChoice, |
---|
925 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
926 | Â Â Â Â expand.Bind(wx.EVT_COMBOBOX,OnExpand) |
---|
927 | Â Â Â Â expandBox.Add(expand,0,WACV) |
---|
928 | Â Â Â Â expandBox.Add(wx.StaticText(self.panel,label=' and find unique atoms '),0,WACV)Â Â Â Â |
---|
929 | Â Â Â Â mainSizer.Add(expandBox) |
---|
930 | Â Â Â Â Â Â Â Â |
---|
931 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
932 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
933 | Â Â Â Â cancelBtn =Â wx.Button(self.panel,-1,"Cancel") |
---|
934 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
935 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
936 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
937 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
938 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
939 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
940 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
941 | Â Â Â Â |
---|
942 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
943 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
944 | Â Â Â Â self.panel.Fit() |
---|
945 | Â Â Â Â self.Fit() |
---|
946 | |
---|
947 |   def GetSelection(self): |
---|
948 |     return self.Trans,self.Vec,self.Expand |
---|
949 | |
---|
950 |   def OnOk(self,event): |
---|
951 | Â Â Â Â parent =Â self.GetParent() |
---|
952 | Â Â Â Â parent.Raise() |
---|
953 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
954 | |
---|
955 |   def OnCancel(self,event): |
---|
956 | Â Â Â Â parent =Â self.GetParent() |
---|
957 | Â Â Â Â parent.Raise() |
---|
958 | Â Â Â Â self.EndModal(wx.ID_CANCEL)Â Â |
---|
959 | Â Â Â Â |
---|
960 | ################################################################################ |
---|
961 | class DIFFaXcontrols(wx.Dialog): |
---|
962 | Â Â ''' Solicit items needed to prepare DIFFaX control.dif file |
---|
963 | Â Â ''' |
---|
964 |   def __init__(self,parent,ctrls,parms=None): |
---|
965 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'DIFFaX controls', |
---|
966 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
967 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
968 | Â Â Â Â self.ctrls =Â ctrls |
---|
969 | Â Â Â Â self.calcType =Â 'powder pattern' |
---|
970 | Â Â Â Â self.plane =Â 'h0l' |
---|
971 | Â Â Â Â self.planeChoice =Â ['h0l','0kl','hhl','h-hl',] |
---|
972 | Â Â Â Â self.lmax =Â '2' |
---|
973 |     self.lmaxChoice = [str(i+1) for i in range(6)] |
---|
974 | Â Â Â Â self.Parms =Â parms |
---|
975 | Â Â Â Â self.Parm =Â None |
---|
976 |     if self.Parms != None: |
---|
977 | Â Â Â Â Â Â self.Parm =Â self.Parms[0] |
---|
978 | Â Â Â Â self.parmRange =Â [0.,1.] |
---|
979 | Â Â Â Â self.parmStep =Â 2 |
---|
980 | Â Â Â Â self.Inst =Â 'Gaussian' |
---|
981 | Â Â Â Â self.Draw() |
---|
982 | Â Â Â Â |
---|
983 |   def Draw(self): |
---|
984 | Â Â Â Â |
---|
985 |     def OnCalcType(event): |
---|
986 | Â Â Â Â Â Â self.calcType =Â calcType.GetValue() |
---|
987 | Â Â Â Â Â Â wx.CallAfter(self.Draw) |
---|
988 | Â Â Â Â Â Â |
---|
989 |     def OnPlane(event): |
---|
990 | Â Â Â Â Â Â self.plane =Â plane.GetValue() |
---|
991 | Â Â Â Â Â Â |
---|
992 |     def OnMaxL(event): |
---|
993 | Â Â Â Â Â Â self.lmax =Â lmax.GetValue() |
---|
994 | Â Â Â Â Â Â |
---|
995 |     def OnParmSel(event): |
---|
996 | Â Â Â Â Â Â self.Parm =Â parmsel.GetValue() |
---|
997 | Â Â Â Â Â Â |
---|
998 |     def OnNumStep(event): |
---|
999 | Â Â Â Â Â Â self.parmStep =Â int(numStep.GetValue()) |
---|
1000 | Â Â Â Â Â Â |
---|
1001 |     def OnParmRange(event): |
---|
1002 | Â Â Â Â Â Â event.Skip() |
---|
1003 | Â Â Â Â Â Â vals =Â parmrange.GetValue().split() |
---|
1004 | Â Â Â Â Â Â try: |
---|
1005 | Â Â Â Â Â Â Â Â vals =Â [float(vals[0]),float(vals[1])] |
---|
1006 |       except ValueError: |
---|
1007 | Â Â Â Â Â Â Â Â vals =Â self.parmRange |
---|
1008 |       parmrange.SetValue('%.3f %.3f'%(vals[0],vals[1])) |
---|
1009 | Â Â Â Â Â Â self.parmRange =Â vals |
---|
1010 | Â Â Â Â Â Â |
---|
1011 |     def OnInstSel(event): |
---|
1012 | Â Â Â Â Â Â self.Inst =Â instsel.GetValue() |
---|
1013 | Â Â Â Â |
---|
1014 | Â Â Â Â self.panel.Destroy() |
---|
1015 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
1016 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1017 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Controls for DIFFaX'),0,WACV) |
---|
1018 |     if self.Parms: |
---|
1019 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Sequential powder pattern simulation'),0,WACV) |
---|
1020 | Â Â Â Â else: |
---|
1021 | Â Â Â Â Â Â calcChoice =Â ['powder pattern','selected area'] |
---|
1022 | Â Â Â Â Â Â calcSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1023 | Â Â Â Â Â Â calcSizer.Add(wx.StaticText(self.panel,label=' Select calculation type: '),0,WACV) |
---|
1024 | Â Â Â Â Â Â calcType =Â wx.ComboBox(self.panel,value=self.calcType,choices=calcChoice, |
---|
1025 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1026 | Â Â Â Â Â Â calcType.Bind(wx.EVT_COMBOBOX,OnCalcType) |
---|
1027 | Â Â Â Â Â Â calcSizer.Add(calcType,0,WACV) |
---|
1028 | Â Â Â Â Â Â mainSizer.Add(calcSizer) |
---|
1029 |     if self.Parms: |
---|
1030 | Â Â Â Â Â Â parmSel =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1031 | Â Â Â Â Â Â parmSel.Add(wx.StaticText(self.panel,label=' Select parameter to vary: '),0,WACV) |
---|
1032 | Â Â Â Â Â Â parmsel =Â wx.ComboBox(self.panel,value=self.Parm,choices=self.Parms, |
---|
1033 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1034 | Â Â Â Â Â Â parmsel.Bind(wx.EVT_COMBOBOX,OnParmSel) |
---|
1035 | Â Â Â Â Â Â parmSel.Add(parmsel,0,WACV) |
---|
1036 | Â Â Â Â Â Â mainSizer.Add(parmSel) |
---|
1037 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Enter parameter range & no. steps: '),0,WACV) |
---|
1038 | Â Â Â Â Â Â parmRange =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1039 |       numChoice = [str(i+1) for i in range(10)] |
---|
1040 |       parmrange = wx.TextCtrl(self.panel,value='%.3f %.3f'%(self.parmRange[0],self.parmRange[1]), |
---|
1041 | Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER) |
---|
1042 | Â Â Â Â Â Â parmrange.Bind(wx.EVT_TEXT_ENTER,OnParmRange) |
---|
1043 | Â Â Â Â Â Â parmrange.Bind(wx.EVT_KILL_FOCUS,OnParmRange) |
---|
1044 | Â Â Â Â Â Â parmRange.Add(parmrange,0,WACV) |
---|
1045 | Â Â Â Â Â Â numStep =Â wx.ComboBox(self.panel,value=str(self.parmStep),choices=numChoice, |
---|
1046 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1047 | Â Â Â Â Â Â numStep.Bind(wx.EVT_COMBOBOX,OnNumStep) |
---|
1048 | Â Â Â Â Â Â parmRange.Add(numStep,0,WACV) |
---|
1049 | Â Â Â Â Â Â mainSizer.Add(parmRange)Â Â Â Â Â Â |
---|
1050 |     if 'selected' in self.calcType: |
---|
1051 | Â Â Â Â Â Â planeSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1052 | Â Â Â Â Â Â planeSizer.Add(wx.StaticText(self.panel,label=' Select plane: '),0,WACV) |
---|
1053 | Â Â Â Â Â Â plane =Â wx.ComboBox(self.panel,value=self.plane,choices=self.planeChoice, |
---|
1054 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1055 | Â Â Â Â Â Â plane.Bind(wx.EVT_COMBOBOX,OnPlane) |
---|
1056 | Â Â Â Â Â Â planeSizer.Add(plane,0,WACV) |
---|
1057 | Â Â Â Â Â Â planeSizer.Add(wx.StaticText(self.panel,label=' Max. l index: '),0,WACV) |
---|
1058 | Â Â Â Â Â Â lmax =Â wx.ComboBox(self.panel,value=self.lmax,choices=self.lmaxChoice, |
---|
1059 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1060 | Â Â Â Â Â Â lmax.Bind(wx.EVT_COMBOBOX,OnMaxL) |
---|
1061 | Â Â Â Â Â Â planeSizer.Add(lmax,0,WACV)Â Â Â Â Â Â |
---|
1062 | Â Â Â Â Â Â mainSizer.Add(planeSizer) |
---|
1063 | Â Â Â Â else: |
---|
1064 | Â Â Â Â Â Â instChoice =Â ['None','Mean Gaussian','Gaussian',] |
---|
1065 | Â Â Â Â Â Â instSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1066 | Â Â Â Â Â Â instSizer.Add(wx.StaticText(self.panel,label=' Select instrument broadening: '),0,WACV) |
---|
1067 | Â Â Â Â Â Â instsel =Â wx.ComboBox(self.panel,value=self.Inst,choices=instChoice, |
---|
1068 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1069 | Â Â Â Â Â Â instsel.Bind(wx.EVT_COMBOBOX,OnInstSel) |
---|
1070 | Â Â Â Â Â Â instSizer.Add(instsel,0,WACV) |
---|
1071 | Â Â Â Â Â Â mainSizer.Add(instSizer) |
---|
1072 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
1073 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
1074 | Â Â Â Â cancelBtn =Â wx.Button(self.panel,-1,"Cancel") |
---|
1075 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
1076 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1077 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1078 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
1079 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1080 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
1081 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1082 | Â Â Â Â |
---|
1083 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
1084 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
1085 | Â Â Â Â self.panel.Fit() |
---|
1086 | Â Â Â Â self.Fit() |
---|
1087 | Â Â Â Â |
---|
1088 |   def GetSelection(self): |
---|
1089 |     if 'powder' in self.calcType: |
---|
1090 |       return 'PWDR',self.Inst,self.Parm,self.parmRange,self.parmStep |
---|
1091 |     elif 'selected' in self.calcType: |
---|
1092 |       return 'SADP',self.plane,self.lmax |
---|
1093 | |
---|
1094 |   def OnOk(self,event): |
---|
1095 | Â Â Â Â parent =Â self.GetParent() |
---|
1096 | Â Â Â Â parent.Raise() |
---|
1097 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
1098 | |
---|
1099 |   def OnCancel(self,event): |
---|
1100 | Â Â Â Â parent =Â self.GetParent() |
---|
1101 | Â Â Â Â parent.Raise() |
---|
1102 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
1103 | Â Â Â Â Â Â |
---|
1104 | Â Â Â Â |
---|
1105 | ################################################################################ |
---|
1106 | class MergeDialog(wx.Dialog): |
---|
1107 | Â Â ''' HKL transformation & merge dialog |
---|
1108 | Â Â |
---|
1109 | Â Â :param wx.Frame parent: reference to parent frame (or None) |
---|
1110 | Â Â :param data: HKLF data |
---|
1111 | Â Â |
---|
1112 |   #NB: commonNames & commonTrans defined at top of this file   |
---|
1113 | Â Â '''Â Â Â Â |
---|
1114 |   def __init__(self,parent,data): |
---|
1115 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup HKLF merge', |
---|
1116 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
1117 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
1118 | Â Â Â Â self.data =Â data |
---|
1119 | Â Â Â Â self.Super =Â data[1]['Super'] |
---|
1120 |     if self.Super: |
---|
1121 | Â Â Â Â Â Â self.Trans =Â np.eye(4) |
---|
1122 | Â Â Â Â else: |
---|
1123 | Â Â Â Â Â Â self.Trans =Â np.eye(3) |
---|
1124 | Â Â Â Â self.Cent =Â 'noncentrosymmetric' |
---|
1125 | Â Â Â Â self.Laue =Â '1' |
---|
1126 | Â Â Â Â self.Class =Â 'triclinic' |
---|
1127 | Â Â Â Â self.Common =Â 'abc' |
---|
1128 | Â Â Â Â self.Draw() |
---|
1129 | Â Â Â Â |
---|
1130 |   def Draw(self): |
---|
1131 | Â Â Â Â Â Â Â Â |
---|
1132 |     def OnMatValue(event): |
---|
1133 | Â Â Â Â Â Â event.Skip() |
---|
1134 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1135 | Â Â Â Â Â Â ix,iy =Â Ind[Obj.GetId()] |
---|
1136 | Â Â Â Â Â Â self.Trans[ix,iy]Â =Â float(Obj.GetValue()) |
---|
1137 | Â Â Â Â Â Â Â Â |
---|
1138 |     def OnCent(event): |
---|
1139 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1140 | Â Â Â Â Â Â self.Cent =Â Obj.GetValue() |
---|
1141 | Â Â Â Â Â Â self.Laue =Â '' |
---|
1142 | Â Â Â Â Â Â wx.CallAfter(self.Draw) |
---|
1143 | Â Â Â Â Â Â |
---|
1144 |     def OnLaue(event): |
---|
1145 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1146 | Â Â Â Â Â Â self.Laue =Â Obj.GetValue() |
---|
1147 | Â Â Â Â Â Â wx.CallAfter(self.Draw) |
---|
1148 | Â Â Â Â Â Â |
---|
1149 |     def OnClass(event): |
---|
1150 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1151 | Â Â Â Â Â Â self.Class =Â Obj.GetValue() |
---|
1152 | Â Â Â Â Â Â self.Laue =Â '' |
---|
1153 | Â Â Â Â Â Â wx.CallAfter(self.Draw) |
---|
1154 | Â Â Â Â Â Â |
---|
1155 |     def OnCommon(event): |
---|
1156 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1157 | Â Â Â Â Â Â self.Common =Â Obj.GetValue() |
---|
1158 | Â Â Â Â Â Â self.Trans =Â commonTrans[self.Common] |
---|
1159 | Â Â Â Â Â Â wx.CallAfter(self.Draw) |
---|
1160 | Â Â Â Â |
---|
1161 | Â Â Â Â self.panel.Destroy() |
---|
1162 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
1163 | Â Â Â Â Ind =Â {} |
---|
1164 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1165 | Â Â Â Â MatSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1166 | Â Â Â Â transSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1167 | Â Â Â Â transSizer.Add(wx.StaticText(self.panel,label=" HKL Transformation matrix: M*H = H'")) |
---|
1168 |     if self.Super: |
---|
1169 | Â Â Â Â Â Â Trmat =Â wx.FlexGridSizer(4,4,0,0) |
---|
1170 | Â Â Â Â else: |
---|
1171 | Â Â Â Â Â Â commonSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1172 | Â Â Â Â Â Â commonSizer.Add(wx.StaticText(self.panel,label=' Common transformations: '),0,WACV) |
---|
1173 |       common = wx.ComboBox(self.panel,value=self.Common,choices=commonNames[:-1], #not the last one! |
---|
1174 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1175 | Â Â Â Â Â Â common.Bind(wx.EVT_COMBOBOX,OnCommon) |
---|
1176 | Â Â Â Â Â Â commonSizer.Add(common,0,WACV) |
---|
1177 | Â Â Â Â Â Â transSizer.Add(commonSizer) |
---|
1178 | Â Â Â Â Â Â Trmat =Â wx.FlexGridSizer(3,3,0,0) |
---|
1179 |     for iy,line in enumerate(self.Trans): |
---|
1180 |       for ix,val in enumerate(line): |
---|
1181 | Â Â Â Â Â Â Â Â item =Â wx.TextCtrl(self.panel,value='%5.3f'%(val), |
---|
1182 | Â Â Â Â Â Â Â Â Â Â size=(50,25),style=wx.TE_PROCESS_ENTER) |
---|
1183 | Â Â Â Â Â Â Â Â Ind[item.GetId()]Â =Â [ix,iy] |
---|
1184 | Â Â Â Â Â Â Â Â item.Bind(wx.EVT_TEXT_ENTER,OnMatValue) |
---|
1185 | Â Â Â Â Â Â Â Â item.Bind(wx.EVT_KILL_FOCUS,OnMatValue) |
---|
1186 | Â Â Â Â Â Â Â Â Trmat.Add(item) |
---|
1187 | Â Â Â Â transSizer.Add(Trmat) |
---|
1188 | Â Â Â Â MatSizer.Add((10,0),0) |
---|
1189 | Â Â Â Â MatSizer.Add(transSizer) |
---|
1190 | Â Â Â Â mainSizer.Add(MatSizer) |
---|
1191 | Â Â Â Â laueClass =Â ['triclinic','monoclinic','orthorhombic','trigonal(H)','tetragonal','hexagonal','cubic'] |
---|
1192 | Â Â Â Â centroLaue =Â {'triclinic':['-1',],'monoclinic':['2/m','1 1 2/m','2/m 1 1',], |
---|
1193 |       'orthorhombic':['m m m',],'trigonal(H)':['-3','-3 m 1','-3 1 m',],  \ |
---|
1194 | Â Â Â Â Â Â 'tetragonal':['4/m','4/m m m',],'hexagonal':['6/m','6/m m m',],'cubic':['m 3','m 3 m']} |
---|
1195 | Â Â Â Â noncentroLaue =Â {'triclinic':['1',],'monoclinic':['2','2 1 1','1 1 2','m','m 1 1','1 1 m',], |
---|
1196 | Â Â Â Â Â Â 'orthorhombic':['2 2 2','m m 2','m 2 m','2 m m',], |
---|
1197 | Â Â Â Â Â Â 'trigonal(H)':['3','3 1 2','3 2 1','3 m 1','3 1 m',], |
---|
1198 |       'tetragonal':['4','-4','4 2 2','4 m m','-4 2 m','-4 m 2',], \ |
---|
1199 | Â Â Â Â Â Â 'hexagonal':['6','-6','6 2 2','6 m m','-6 m 2','-6 2 m',],'cubic':['2 3','4 3 2','-4 3 m']} |
---|
1200 | Â Â Â Â centChoice =Â ['noncentrosymmetric','centrosymmetric'] |
---|
1201 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Select Laue class for new lattice:'),0,WACV) |
---|
1202 | Â Â Â Â Class =Â wx.ComboBox(self.panel,value=self.Class,choices=laueClass, |
---|
1203 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1204 | Â Â Â Â Class.Bind(wx.EVT_COMBOBOX,OnClass) |
---|
1205 | Â Â Â Â mainSizer.Add(Class,0,WACV) |
---|
1206 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,label=' Target Laue symmetry:'),0,WACV) |
---|
1207 | Â Â Â Â Cent =Â wx.ComboBox(self.panel,value=self.Cent,choices=centChoice, |
---|
1208 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1209 | Â Â Â Â Cent.Bind(wx.EVT_COMBOBOX,OnCent) |
---|
1210 | Â Â Â Â mergeSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1211 | Â Â Â Â mergeSizer.Add(Cent,0,WACV) |
---|
1212 | Â Â Â Â mergeSizer.Add((10,0),0) |
---|
1213 | Â Â Â Â Choice =Â centroLaue[self.Class] |
---|
1214 |     if 'non' in self.Cent: |
---|
1215 | Â Â Â Â Â Â Choice =Â noncentroLaue[self.Class] |
---|
1216 | Â Â Â Â Laue =Â wx.ComboBox(self.panel,value=self.Laue,choices=Choice, |
---|
1217 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
1218 | Â Â Â Â Laue.Bind(wx.EVT_COMBOBOX,OnLaue) |
---|
1219 | Â Â Â Â mergeSizer.Add(Laue,0,WACV) |
---|
1220 | Â Â Â Â mainSizer.Add(mergeSizer) |
---|
1221 | |
---|
1222 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
1223 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
1224 | Â Â Â Â cancelBtn =Â wx.Button(self.panel,-1,"Cancel") |
---|
1225 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
1226 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1227 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1228 |     if self.Laue: |
---|
1229 | Â Â Â Â Â Â btnSizer.Add(OkBtn) |
---|
1230 | Â Â Â Â Â Â btnSizer.Add((20,20),1) |
---|
1231 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
1232 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1233 | Â Â Â Â |
---|
1234 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
1235 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
1236 | Â Â Â Â self.panel.Fit() |
---|
1237 | Â Â Â Â self.Fit() |
---|
1238 | Â Â Â Â |
---|
1239 |   def GetSelection(self): |
---|
1240 |     return self.Trans,self.Cent,self.Laue |
---|
1241 | |
---|
1242 |   def OnOk(self,event): |
---|
1243 | Â Â Â Â parent =Â self.GetParent() |
---|
1244 | Â Â Â Â parent.Raise() |
---|
1245 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
1246 | |
---|
1247 |   def OnCancel(self,event): |
---|
1248 | Â Â Â Â parent =Â self.GetParent() |
---|
1249 | Â Â Â Â parent.Raise() |
---|
1250 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
1251 | |
---|
1252 | Â Â Â Â |
---|
1253 | ################################################################################ |
---|
1254 | class AddHatomDialog(wx.Dialog): |
---|
1255 | Â Â '''H atom addition dialog. After :meth:`ShowModal` returns, the results |
---|
1256 | Â Â are found in dict :attr:`self.data`, which is accessed using :meth:`GetData`. |
---|
1257 | Â Â |
---|
1258 | Â Â :param wx.Frame parent: reference to parent frame (or None) |
---|
1259 | Â Â :param dict Neigh: a dict of atom names with list of atom name, dist pairs for neighboring atoms |
---|
1260 | Â Â :param dict phase: a dict containing the phase as defined by |
---|
1261 | Â Â Â :ref:`Phase Tree Item <Phase_table>`Â Â |
---|
1262 | Â Â ''' |
---|
1263 |   def __init__(self,parent,Neigh,phase): |
---|
1264 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,'H atom add', |
---|
1265 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
1266 | Â Â Â Â self.panel =Â wxscroll.ScrolledPanel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
1267 | Â Â Â Â self.Neigh =Â Neigh |
---|
1268 | Â Â Â Â self.phase =Â phase |
---|
1269 | Â Â Â Â self.Hatoms =Â [] |
---|
1270 | Â Â Â Â self.Draw(self.Neigh,self.phase) |
---|
1271 | Â Â Â Â Â Â |
---|
1272 |   def Draw(self,Neigh,phase): |
---|
1273 | Â Â Â Â '''Creates the contents of the dialog. Normally called |
---|
1274 | Â Â Â Â by :meth:`__init__`. |
---|
1275 | Â Â Â Â ''' |
---|
1276 |     def OnHSelect(event): |
---|
1277 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1278 | Â Â Â Â Â Â item,i =Â Indx[Obj.GetId()] |
---|
1279 |       for obj in Indx[item]: |
---|
1280 | Â Â Â Â Â Â Â Â obj.SetValue(False) |
---|
1281 | Â Â Â Â Â Â Obj.SetValue(True) |
---|
1282 | Â Â Â Â Â Â self.Neigh[item][2]Â =Â i |
---|
1283 | Â Â Â Â Â Â |
---|
1284 |     def OnBond(event): |
---|
1285 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1286 | Â Â Â Â Â Â inei,ibond =Â Indx[Obj.GetId()] |
---|
1287 | Â Â Â Â Â Â self.Neigh[inei][1][0][ibond][2]Â =Â Obj.GetValue() |
---|
1288 | Â Â Â Â Â Â |
---|
1289 | Â Â Â Â self.panel.Destroy() |
---|
1290 | Â Â Â Â self.panel =Â wxscroll.ScrolledPanel(self,style =Â wx.DEFAULT_DIALOG_STYLE) |
---|
1291 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1292 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,-1,'H atom add controls for phase %s:'%(phase['General']['Name'])), |
---|
1293 | Â Â Â Â Â Â 0,wx.LEFT|wx.TOP,10) |
---|
1294 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,-1,'NB: Check selections as they may not be correct'),0,WACV|wx.LEFT,10) |
---|
1295 |     mainSizer.Add(wx.StaticText(self.panel,-1," Atom: Add # H's     Use: Neighbors, dist"),0,wx.TOP|wx.LEFT,5) |
---|
1296 | Â Â Â Â nHatms =Â ['0','1','2','3'] |
---|
1297 | Â Â Â Â dataSizer =Â wx.FlexGridSizer(0,3,0,0) |
---|
1298 | Â Â Â Â Indx =Â {} |
---|
1299 |     for inei,neigh in enumerate(Neigh): |
---|
1300 | Â Â Â Â Â Â dataSizer.Add(wx.StaticText(self.panel,-1,' %s:Â '%(neigh[0])),0,WACV) |
---|
1301 | Â Â Â Â Â Â nH =Â 1Â Â Â #for O atom |
---|
1302 |       if 'C' in neigh[0] or 'N' in neigh[0]: |
---|
1303 | Â Â Â Â Â Â Â Â nH =Â 4-len(neigh[1][0]) |
---|
1304 | Â Â Â Â Â Â checks =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1305 | Â Â Â Â Â Â Ids =Â [] |
---|
1306 |       for i in range(nH+1): |
---|
1307 | Â Â Â Â Â Â Â Â nHs =Â wx.CheckBox(self.panel,-1,label=nHatms[i]) |
---|
1308 |         if i == neigh[2]: |
---|
1309 | Â Â Â Â Â Â Â Â Â Â nHs.SetValue(True) |
---|
1310 | Â Â Â Â Â Â Â Â Indx[nHs.GetId()]Â =Â [inei,i] |
---|
1311 | Â Â Â Â Â Â Â Â Ids.append(nHs) |
---|
1312 |         nHs.Bind(wx.EVT_CHECKBOX, OnHSelect) |
---|
1313 | Â Â Â Â Â Â Â Â checks.Add(nHs,0,WACV) |
---|
1314 | Â Â Â Â Â Â Indx[inei]Â =Â Ids |
---|
1315 | Â Â Â Â Â Â dataSizer.Add(checks,0,WACV) |
---|
1316 | Â Â Â Â Â Â lineSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1317 |       for ib,bond in enumerate(neigh[1][0]): |
---|
1318 | Â Â Â Â Â Â Â Â Bond =Â wx.CheckBox(self.panel,-1,label=': %s, %.3f'%(bond[0],bond[1])) |
---|
1319 | Â Â Â Â Â Â Â Â Bond.SetValue(bond[2]) |
---|
1320 | Â Â Â Â Â Â Â Â Indx[Bond.GetId()]Â =Â [inei,ib] |
---|
1321 | Â Â Â Â Â Â Â Â Bond.Bind(wx.EVT_CHECKBOX,OnBond)Â Â Â Â Â Â Â Â |
---|
1322 | Â Â Â Â Â Â Â Â lineSizer.Add(Bond,0,WACV)Â Â Â Â Â Â Â Â |
---|
1323 | Â Â Â Â Â Â dataSizer.Add(lineSizer,0,WACV|wx.RIGHT,10) |
---|
1324 | Â Â Â Â mainSizer.Add(dataSizer,0,wx.LEFT,5) |
---|
1325 | |
---|
1326 | Â Â Â Â CancelBtn =Â wx.Button(self.panel,-1,'Cancel') |
---|
1327 |     CancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
1328 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,'Ok') |
---|
1329 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
1330 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1331 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1332 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
1333 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1334 | Â Â Â Â btnSizer.Add(CancelBtn) |
---|
1335 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1336 |     mainSizer.Add(btnSizer,0,wx.BOTTOM|wx.TOP, 10) |
---|
1337 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
1338 | Â Â Â Â size =Â np.array(self.GetSize()) |
---|
1339 | Â Â Â Â self.panel.SetupScrolling() |
---|
1340 | Â Â Â Â self.panel.SetAutoLayout(1) |
---|
1341 | Â Â Â Â size =Â [size[0]-5,size[1]-20]Â Â Â Â #this fiddling is needed for older wx! |
---|
1342 | Â Â Â Â self.panel.SetSize(size) |
---|
1343 | Â Â Â Â |
---|
1344 |   def GetData(self): |
---|
1345 | Â Â Â Â 'Returns the values from the dialog' |
---|
1346 |     for neigh in self.Neigh: |
---|
1347 |       for ibond,bond in enumerate(neigh[1][0]): |
---|
1348 |         if not bond[2]: |
---|
1349 | Â Â Â Â Â Â Â Â Â Â neigh[1][1][1][ibond]Â =Â 0Â Â #deselected bond |
---|
1350 |       neigh[1][1][1] = [a for a in neigh[1][1][1] if a] |
---|
1351 |     return self.Neigh    #has #Hs to add for each entry |
---|
1352 | Â Â Â Â |
---|
1353 |   def OnOk(self,event): |
---|
1354 | Â Â Â Â 'Called when the OK button is pressed' |
---|
1355 | Â Â Â Â parent =Â self.GetParent() |
---|
1356 | Â Â Â Â parent.Raise() |
---|
1357 | Â Â Â Â self.EndModal(wx.ID_OK)Â Â Â Â Â Â Â |
---|
1358 | |
---|
1359 |   def OnCancel(self,event): |
---|
1360 | Â Â Â Â parent =Â self.GetParent() |
---|
1361 | Â Â Â Â parent.Raise() |
---|
1362 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
1363 | |
---|
1364 | ################################################################################ |
---|
1365 | class DisAglDialog(wx.Dialog): |
---|
1366 | Â Â '''Distance/Angle Controls input dialog. After |
---|
1367 | Â Â :meth:`ShowModal` returns, the results are found in |
---|
1368 | Â Â dict :attr:`self.data`, which is accessed using :meth:`GetData`. |
---|
1369 | |
---|
1370 | Â Â :param wx.Frame parent: reference to parent frame (or None) |
---|
1371 | Â Â :param dict data: a dict containing the current |
---|
1372 | Â Â Â search ranges or an empty dict, which causes default values |
---|
1373 | Â Â Â to be used. |
---|
1374 | Â Â Â Will be used to set element `DisAglCtls` in |
---|
1375 | Â Â Â :ref:`Phase Tree Item <Phase_table>` |
---|
1376 | Â Â :param dict default:Â A dict containing the default |
---|
1377 | Â Â Â search ranges for each element. |
---|
1378 | Â Â :param bool Reset: if True (default), show Reset button |
---|
1379 | Â Â :param bool Angle: if True (default), show angle radii |
---|
1380 | Â Â ''' |
---|
1381 |   def __init__(self,parent,data,default,Reset=True,Angle=True): |
---|
1382 | Â Â Â Â text =Â 'Distance Angle Controls' |
---|
1383 |     if not Angle: |
---|
1384 | Â Â Â Â Â Â text =Â 'Distance Controls' |
---|
1385 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,text, |
---|
1386 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
1387 | Â Â Â Â self.default =Â default |
---|
1388 | Â Â Â Â self.Reset =Â Reset |
---|
1389 | Â Â Â Â self.Angle =Â Angle |
---|
1390 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
1391 | Â Â Â Â self._default(data,self.default) |
---|
1392 | Â Â Â Â self.Draw(self.data) |
---|
1393 | Â Â Â Â Â Â Â Â |
---|
1394 |   def _default(self,data,default): |
---|
1395 | Â Â Â Â '''Set starting values for the search values, either from |
---|
1396 | Â Â Â Â the input array or from defaults, if input is null |
---|
1397 | Â Â Â Â ''' |
---|
1398 |     if data: |
---|
1399 | Â Â Â Â Â Â self.data =Â copy.deepcopy(data)Â # don't mess with originals |
---|
1400 | Â Â Â Â else: |
---|
1401 | Â Â Â Â Â Â self.data =Â {} |
---|
1402 | Â Â Â Â Â Â self.data['Name']Â =Â default['Name'] |
---|
1403 | Â Â Â Â Â Â self.data['Factors']Â =Â [0.85,0.85] |
---|
1404 | Â Â Â Â Â Â self.data['AtomTypes']Â =Â default['AtomTypes'] |
---|
1405 | Â Â Â Â Â Â self.data['BondRadii']Â =Â default['BondRadii'][:] |
---|
1406 | Â Â Â Â Â Â self.data['AngleRadii']Â =Â default['AngleRadii'][:] |
---|
1407 | |
---|
1408 |   def Draw(self,data): |
---|
1409 | Â Â Â Â '''Creates the contents of the dialog. Normally called |
---|
1410 | Â Â Â Â by :meth:`__init__`. |
---|
1411 | Â Â Â Â ''' |
---|
1412 | Â Â Â Â self.panel.Destroy() |
---|
1413 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
1414 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1415 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,-1,'Controls for phase '+data['Name']), |
---|
1416 | Â Â Â Â Â Â 0,WACV|wx.LEFT,10) |
---|
1417 | Â Â Â Â mainSizer.Add((10,10),1) |
---|
1418 | Â Â Â Â |
---|
1419 | Â Â Â Â ncol =Â 3 |
---|
1420 |     if not self.Angle: |
---|
1421 | Â Â Â Â Â Â ncol=2 |
---|
1422 | Â Â Â Â radiiSizer =Â wx.FlexGridSizer(0,ncol,5,5) |
---|
1423 | Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,' Type'),0,WACV) |
---|
1424 | Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,'Bond radii'),0,WACV) |
---|
1425 |     if self.Angle: |
---|
1426 | Â Â Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,'Angle radii'),0,WACV) |
---|
1427 | Â Â Â Â self.objList =Â {} |
---|
1428 |     for id,item in enumerate(self.data['AtomTypes']): |
---|
1429 | Â Â Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,' '+item),0,WACV) |
---|
1430 | Â Â Â Â Â Â bRadii =Â G2G.ValidatedTxtCtrl(self.panel,data['BondRadii'],id,nDig=(10,3),typeHint=float) |
---|
1431 | Â Â Â Â Â Â radiiSizer.Add(bRadii,0,WACV) |
---|
1432 |       if self.Angle: |
---|
1433 | Â Â Â Â Â Â Â Â aRadii =Â G2G.ValidatedTxtCtrl(self.panel,data['AngleRadii'],id,nDig=(10,3),typeHint=float) |
---|
1434 | Â Â Â Â Â Â Â Â radiiSizer.Add(aRadii,0,WACV) |
---|
1435 | Â Â Â Â mainSizer.Add(radiiSizer,0,wx.EXPAND) |
---|
1436 |     if self.Angle: |
---|
1437 | Â Â Â Â Â Â factorSizer =Â wx.FlexGridSizer(0,2,5,5) |
---|
1438 | Â Â Â Â Â Â Names =Â ['Bond','Angle'] |
---|
1439 |       for i,name in enumerate(Names): |
---|
1440 | Â Â Â Â Â Â Â Â factorSizer.Add(wx.StaticText(self.panel,-1,name+' search factor'),0,WACV) |
---|
1441 | Â Â Â Â Â Â Â Â bondFact =Â G2G.ValidatedTxtCtrl(self.panel,data['Factors'],i,nDig=(10,3),typeHint=float) |
---|
1442 | Â Â Â Â Â Â Â Â factorSizer.Add(bondFact) |
---|
1443 | Â Â Â Â Â Â mainSizer.Add(factorSizer,0,wx.EXPAND) |
---|
1444 | Â Â Â Â |
---|
1445 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
1446 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
1447 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1448 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1449 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
1450 |     if self.Reset: |
---|
1451 | Â Â Â Â Â Â ResetBtn =Â wx.Button(self.panel,-1,'Reset') |
---|
1452 |       ResetBtn.Bind(wx.EVT_BUTTON, self.OnReset) |
---|
1453 | Â Â Â Â Â Â btnSizer.Add(ResetBtn) |
---|
1454 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
1455 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
1456 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
1457 | Â Â Â Â self.panel.Fit() |
---|
1458 | Â Â Â Â self.Fit() |
---|
1459 | Â Â |
---|
1460 |   def GetData(self): |
---|
1461 | Â Â Â Â 'Returns the values from the dialog' |
---|
1462 |     return self.data |
---|
1463 | Â Â Â Â |
---|
1464 |   def OnOk(self,event): |
---|
1465 | Â Â Â Â 'Called when the OK button is pressed' |
---|
1466 | Â Â Â Â parent =Â self.GetParent() |
---|
1467 | Â Â Â Â parent.Raise() |
---|
1468 | Â Â Â Â self.EndModal(wx.ID_OK)Â Â Â Â Â Â Â |
---|
1469 | Â Â Â Â |
---|
1470 |   def OnReset(self,event): |
---|
1471 | Â Â Â Â 'Called when the Reset button is pressed' |
---|
1472 | Â Â Â Â data =Â {} |
---|
1473 | Â Â Â Â self._default(data,self.default) |
---|
1474 | Â Â Â Â self.Draw(self.data) |
---|
1475 | Â Â Â Â Â Â Â Â |
---|
1476 | ################################################################################ |
---|
1477 | class ShowLSParms(wx.Dialog): |
---|
1478 | Â Â '''Create frame to show least-squares parameters |
---|
1479 | Â Â ''' |
---|
1480 |   def __init__(self,parent,title,parmDict,varyList,fullVaryList, |
---|
1481 | Â Â Â Â Â Â Â Â Â size=(300,430)): |
---|
1482 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=size, |
---|
1483 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
1484 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1485 | |
---|
1486 | Â Â Â Â panel =Â wxscroll.ScrolledPanel( |
---|
1487 |       self, wx.ID_ANY, |
---|
1488 | Â Â Â Â Â Â #size=size, |
---|
1489 | Â Â Â Â Â Â style =Â wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) |
---|
1490 | Â Â Â Â num =Â len(varyList) |
---|
1491 | Â Â Â Â mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number of refined variables: '+str(num))) |
---|
1492 |     if len(varyList) != len(fullVaryList): |
---|
1493 | Â Â Â Â Â Â num =Â len(fullVaryList)Â -Â len(varyList) |
---|
1494 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(self,wx.ID_ANY,' + '+str(num)+' parameters are varied via constraints')) |
---|
1495 | Â Â Â Â subSizer =Â wx.FlexGridSizer(cols=4,hgap=2,vgap=2) |
---|
1496 | Â Â Â Â parmNames =Â parmDict.keys() |
---|
1497 | Â Â Â Â parmNames.sort() |
---|
1498 | Â Â Â Â subSizer.Add((-1,-1)) |
---|
1499 |     subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'Parameter name ')) |
---|
1500 | Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'refine?')) |
---|
1501 | Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'value'),0,wx.ALIGN_RIGHT) |
---|
1502 | Â Â Â Â explainRefine =Â False |
---|
1503 |     for name in parmNames: |
---|
1504 | Â Â Â Â Â Â # skip entries without numerical values |
---|
1505 |       if isinstance(parmDict[name],basestring): continue |
---|
1506 | Â Â Â Â Â Â try: |
---|
1507 | Â Â Â Â Â Â Â Â value =Â G2py3.FormatSigFigs(parmDict[name]) |
---|
1508 |       except TypeError: |
---|
1509 | Â Â Â Â Â Â Â Â value =Â str(parmDict[name])+' -?'Â # unexpected |
---|
1510 | Â Â Â Â Â Â Â Â #continue |
---|
1511 | Â Â Â Â Â Â v =Â G2obj.getVarDescr(name) |
---|
1512 |       if v is None or v[-1] is None: |
---|
1513 | Â Â Â Â Â Â Â Â subSizer.Add((-1,-1)) |
---|
1514 | Â Â Â Â Â Â else:Â Â Â Â Â Â Â Â |
---|
1515 | Â Â Â Â Â Â Â Â ch =Â G2G.HelpButton(panel,G2obj.fmtVarDescr(name)) |
---|
1516 | Â Â Â Â Â Â Â Â subSizer.Add(ch,0,wx.LEFT|wx.RIGHT|WACV|wx.ALIGN_CENTER,1) |
---|
1517 | Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(name))) |
---|
1518 |       if name in varyList: |
---|
1519 | Â Â Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'R')) |
---|
1520 |       elif name in fullVaryList: |
---|
1521 | Â Â Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'C')) |
---|
1522 | Â Â Â Â Â Â Â Â explainRefine =Â True |
---|
1523 | Â Â Â Â Â Â else: |
---|
1524 | Â Â Â Â Â Â Â Â subSizer.Add((-1,-1)) |
---|
1525 | Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,value),0,wx.ALIGN_RIGHT) |
---|
1526 | |
---|
1527 | Â Â Â Â # finish up ScrolledPanel |
---|
1528 | Â Â Â Â panel.SetSizer(subSizer) |
---|
1529 | Â Â Â Â panel.SetAutoLayout(1) |
---|
1530 | Â Â Â Â panel.SetupScrolling() |
---|
1531 |     mainSizer.Add(panel,1, wx.ALL|wx.EXPAND,1) |
---|
1532 | |
---|
1533 |     if explainRefine: |
---|
1534 | Â Â Â Â Â Â mainSizer.Add( |
---|
1535 | Â Â Â Â Â Â Â Â wx.StaticText(self,wx.ID_ANY, |
---|
1536 | Â Â Â Â Â Â Â Â Â Â Â Â Â '"R" indicates a refined variable\n'+ |
---|
1537 | Â Â Â Â Â Â Â Â Â Â Â Â Â '"C" indicates generated from a constraint' |
---|
1538 | Â Â Â Â Â Â Â Â Â Â Â Â Â ), |
---|
1539 |         0, wx.ALL,0) |
---|
1540 | Â Â Â Â # make OK button |
---|
1541 | Â Â Â Â btnsizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1542 |     btn = wx.Button(self, wx.ID_CLOSE,"Close") |
---|
1543 | Â Â Â Â btn.Bind(wx.EVT_BUTTON,self._onClose) |
---|
1544 | Â Â Â Â btnsizer.Add(btn) |
---|
1545 |     mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) |
---|
1546 | Â Â Â Â # Allow window to be enlarged but not made smaller |
---|
1547 | Â Â Â Â self.SetSizer(mainSizer) |
---|
1548 | Â Â Â Â self.SetMinSize(self.GetSize()) |
---|
1549 | |
---|
1550 |   def _onClose(self,event): |
---|
1551 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
1552 | Â |
---|
1553 | ################################################################################ |
---|
1554 | class DataFrame(wx.Frame): |
---|
1555 | Â Â '''Create the data item window and all the entries in menus used in |
---|
1556 | Â Â that window. For Linux and windows, the menu entries are created for the |
---|
1557 | Â Â current data item window, but in the Mac the menu is accessed from all |
---|
1558 | Â Â windows. This means that a different menu is posted depending on which |
---|
1559 | Â Â data item is posted. On the Mac, all the menus contain the data tree menu |
---|
1560 | Â Â items, but additional menus are added specific to the data item. |
---|
1561 | |
---|
1562 | Â Â Note that while the menus are created here, |
---|
1563 | Â Â the binding for the menus is done later in various GSASII*GUI modules, |
---|
1564 | Â Â where the functions to be called are defined. |
---|
1565 | Â Â ''' |
---|
1566 |   def Bind(self,eventtype,handler,*args,**kwargs): |
---|
1567 | Â Â Â Â '''Override the Bind() function: on the Mac the binding is to |
---|
1568 | Â Â Â Â the main window, so that menus operate with any window on top. |
---|
1569 | Â Â Â Â For other platforms, either wrap calls that will be logged |
---|
1570 | Â Â Â Â or call the default wx.Frame Bind() to bind to the menu item directly. |
---|
1571 | |
---|
1572 | Â Â Â Â Note that bindings can be made to objects by Id or by direct reference to the |
---|
1573 | Â Â Â Â object. As a convention, when bindings are to objects, they are not logged |
---|
1574 | Â Â Â Â but when bindings are by Id, they are logged. |
---|
1575 | Â Â Â Â ''' |
---|
1576 |     if sys.platform == "darwin": # mac |
---|
1577 | Â Â Â Â Â Â self.G2frame.Bind(eventtype,handler,*args,**kwargs) |
---|
1578 | Â Â Â Â Â Â return |
---|
1579 |     if eventtype == wx.EVT_MENU and 'id' in kwargs: |
---|
1580 | Â Â Â Â Â Â menulabels =Â log.SaveMenuCommand(kwargs['id'],self.G2frame,handler) |
---|
1581 |       if menulabels: |
---|
1582 | Â Â Â Â Â Â Â Â #print 'intercepting bind for',handler,menulabels,kwargs['id'] |
---|
1583 | Â Â Â Â Â Â Â Â wx.Frame.Bind(self,eventtype,self.G2frame.MenuBinding,*args,**kwargs) |
---|
1584 | Â Â Â Â Â Â Â Â return |
---|
1585 | Â Â Â Â Â Â wx.Frame.Bind(self,eventtype,handler,*args,**kwargs)Â Â Â |
---|
1586 | Â Â Â Â |
---|
1587 |   def PrefillDataMenu(self,menu,empty=False): |
---|
1588 | Â Â Â Â '''Create the "standard" part of data frame menus. Note that on Linux and |
---|
1589 | Â Â Â Â Windows nothing happens here. On Mac, this menu duplicates the |
---|
1590 | Â Â Â Â tree menu, but adds an extra help command for the data item and a separator. |
---|
1591 | Â Â Â Â ''' |
---|
1592 | Â Â Â Â self.datamenu =Â menu |
---|
1593 | Â Â Â Â self.G2frame.dataMenuBars.append(menu) |
---|
1594 |     if sys.platform == "darwin": # mac             |
---|
1595 | Â Â Â Â Â Â self.G2frame.FillMainMenu(menu,addhelp=False)Â # add the data tree menu items |
---|
1596 |       if not empty: |
---|
1597 | Â Â Â Â Â Â Â Â menu.Append(wx.Menu(title=''),title='|')Â # add a separator |
---|
1598 | Â Â Â Â |
---|
1599 |   def PostfillDataMenu(self,empty=False): |
---|
1600 | Â Â Â Â '''Add the help menu to the data frame menus. Note that on Linux and |
---|
1601 | Â Â Â Â Windows, this is the standard help Menu but without the update commands but adds an extra help |
---|
1602 | Â Â Â Â command for the data item. |
---|
1603 | Â Â Â Â On Mac, this is the entire help menu including the update commands, a separator and the |
---|
1604 | Â Â Â Â extra help command for the data item. |
---|
1605 | Â Â Â Â ''' |
---|
1606 | Â Â Â Â menu =Â self.datamenu |
---|
1607 |     if sys.platform == "darwin": # mac |
---|
1608 |       if not empty: |
---|
1609 | Â Â Â Â Â Â Â Â menu.Append(wx.Menu(title=''),title='|')Â # add another separator |
---|
1610 | Â Â Â Â Â Â HelpMenu=G2G.MyHelp(self,includeTree=True, |
---|
1611 | Â Â Â Â Â Â Â Â morehelpitems=[('&Tutorials','Tutorials'),]) |
---|
1612 | Â Â Â Â Â Â menu.Append(menu=HelpMenu,title='&Help') |
---|
1613 | Â Â Â Â else:Â # other |
---|
1614 | Â Â Â Â Â Â menu.Append(menu=G2G.MyHelp(self),title='&Help') |
---|
1615 | |
---|
1616 |   def _init_menus(self): |
---|
1617 | Â Â Â Â 'define all GSAS-II data frame menus' |
---|
1618 | |
---|
1619 | Â Â Â Â # for use where no menu or data frame help is provided |
---|
1620 | Â Â Â Â self.BlankMenu =Â wx.MenuBar() |
---|
1621 | Â Â Â Â |
---|
1622 | Â Â Â Â # Controls |
---|
1623 | Â Â Â Â self.ControlsMenu =Â wx.MenuBar() |
---|
1624 | Â Â Â Â self.PrefillDataMenu(self.ControlsMenu,empty=True) |
---|
1625 | Â Â Â Â self.PostfillDataMenu(empty=True) |
---|
1626 | Â Â Â Â |
---|
1627 | Â Â Â Â # Notebook |
---|
1628 | Â Â Â Â self.DataNotebookMenu =Â wx.MenuBar()Â |
---|
1629 | Â Â Â Â self.PrefillDataMenu(self.DataNotebookMenu,empty=True) |
---|
1630 | Â Â Â Â self.PostfillDataMenu(empty=True) |
---|
1631 | Â Â Â Â |
---|
1632 | Â Â Â Â # Comments |
---|
1633 | Â Â Â Â self.DataCommentsMenu =Â wx.MenuBar() |
---|
1634 | Â Â Â Â self.PrefillDataMenu(self.DataCommentsMenu,empty=True) |
---|
1635 | Â Â Â Â self.PostfillDataMenu(empty=True) |
---|
1636 | Â Â Â Â |
---|
1637 | Â Â Â Â # Constraints |
---|
1638 | Â Â Â Â self.ConstraintMenu =Â wx.MenuBar() |
---|
1639 | Â Â Â Â self.PrefillDataMenu(self.ConstraintMenu) |
---|
1640 | Â Â Â Â self.ConstraintTab =Â wx.Menu(title='') |
---|
1641 |     self.ConstraintMenu.Append(menu=self.ConstraintTab, title='Select tab') |
---|
1642 |     for id,txt in ( |
---|
1643 | Â Â Â Â Â Â (wxID_CONSPHASE,'Phase'), |
---|
1644 | Â Â Â Â Â Â (wxID_CONSHAP,'Histogram/Phase'), |
---|
1645 | Â Â Â Â Â Â (wxID_CONSHIST,'Histogram'), |
---|
1646 | Â Â Â Â Â Â (wxID_CONSGLOBAL,'Global')): |
---|
1647 | Â Â Â Â Â Â self.ConstraintTab.Append( |
---|
1648 |         id=id, kind=wx.ITEM_NORMAL,text=txt, |
---|
1649 | Â Â Â Â Â Â Â Â help='Select '+txt+' constraint editing tab') |
---|
1650 | Â Â Â Â self.ConstraintEdit =Â wx.Menu(title='') |
---|
1651 |     self.ConstraintMenu.Append(menu=self.ConstraintEdit, title='Edit Constr.') # renamed from Edit due to Mac adding extra items to menu |
---|
1652 |     self.ConstraintEdit.Append(id=wxID_HOLDADD, kind=wx.ITEM_NORMAL,text='Add hold', |
---|
1653 | Â Â Â Â Â Â help='Prevent refinement of parameter values') |
---|
1654 |     self.ConstraintEdit.Append(id=wxID_EQUIVADD, kind=wx.ITEM_NORMAL,text='Add equivalence', |
---|
1655 | Â Â Â Â Â Â help='Force parameter values to be equivalent') |
---|
1656 |     self.ConstraintEdit.Append(id=wxID_CONSTRAINTADD, kind=wx.ITEM_NORMAL,text='Add constraint equation', |
---|
1657 | Â Â Â Â Â Â help='Add a constraint equation to apply to parameter values') |
---|
1658 |     self.ConstraintEdit.Append(id=wxID_FUNCTADD, kind=wx.ITEM_NORMAL,text='Add New Var', |
---|
1659 | Â Â Â Â Â Â help='Create a variable composed of existing parameters') |
---|
1660 |     self.ConstraintEdit.Append(id=wxID_EQUIVALANCEATOMS, kind=wx.ITEM_NORMAL,text='Make atoms equivalent', |
---|
1661 | Â Â Â Â Â Â help='Force atom parameter values to be equivalent') |
---|
1662 | Â Â Â Â self.ConstraintEdit.Enable(wxID_EQUIVALANCEATOMS,False) |
---|
1663 | #Â Â Â Â self.ConstraintEdit.Append(id=wxID_ADDRIDING, kind=wx.ITEM_NORMAL,text='Add H riding constraints', |
---|
1664 | #Â Â Â Â Â Â help='Add H atom riding constraints between atom parameter values') |
---|
1665 | #Â Â Â Â self.ConstraintEdit.Enable(wxID_ADDRIDING,False) |
---|
1666 | Â Â Â Â self.PostfillDataMenu() |
---|
1667 | |
---|
1668 | Â Â Â Â # item = self.ConstraintEdit.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Update GUI') |
---|
1669 | Â Â Â Â # def UpdateGSASIIconstrGUI(event): |
---|
1670 | Â Â Â Â #Â Â Â import GSASIIconstrGUI |
---|
1671 | Â Â Â Â #Â Â Â reload(GSASIIconstrGUI) |
---|
1672 | Â Â Â Â #Â Â Â import GSASIIobj |
---|
1673 | Â Â Â Â #Â Â Â reload(GSASIIobj) |
---|
1674 | Â Â Â Â # self.Bind(wx.EVT_MENU,UpdateGSASIIconstrGUI,id=item.GetId()) |
---|
1675 | |
---|
1676 | Â Â Â Â # Rigid bodies |
---|
1677 | Â Â Â Â self.RigidBodyMenu =Â wx.MenuBar() |
---|
1678 | Â Â Â Â self.PrefillDataMenu(self.RigidBodyMenu) |
---|
1679 | Â Â Â Â self.ResidueRBMenu =Â wx.Menu(title='') |
---|
1680 |     self.ResidueRBMenu.Append(id=wxID_RIGIDBODYIMPORT, kind=wx.ITEM_NORMAL,text='Import XYZ', |
---|
1681 | Â Â Â Â Â Â help='Import rigid body XYZ from file') |
---|
1682 |     self.ResidueRBMenu.Append(id=wxID_RESIDUETORSSEQ, kind=wx.ITEM_NORMAL,text='Define sequence', |
---|
1683 | Â Â Â Â Â Â help='Define torsion sequence') |
---|
1684 |     self.ResidueRBMenu.Append(id=wxID_RIGIDBODYADD, kind=wx.ITEM_NORMAL,text='Import residues', |
---|
1685 | Â Â Â Â Â Â help='Import residue rigid bodies from macro file') |
---|
1686 |     self.RigidBodyMenu.Append(menu=self.ResidueRBMenu, title='Edit Body') |
---|
1687 | Â Â Â Â self.PostfillDataMenu() |
---|
1688 | |
---|
1689 | Â Â Â Â self.VectorBodyMenu =Â wx.MenuBar() |
---|
1690 | Â Â Â Â self.PrefillDataMenu(self.VectorBodyMenu) |
---|
1691 | Â Â Â Â self.VectorRBEdit =Â wx.Menu(title='') |
---|
1692 |     self.VectorRBEdit.Append(id=wxID_VECTORBODYADD, kind=wx.ITEM_NORMAL,text='Add rigid body', |
---|
1693 | Â Â Â Â Â Â help='Add vector rigid body') |
---|
1694 |     self.VectorBodyMenu.Append(menu=self.VectorRBEdit, title='Edit Vector Body') |
---|
1695 | Â Â Â Â self.PostfillDataMenu() |
---|
1696 | |
---|
1697 | Â Â Â Â Â Â Â Â Â Â |
---|
1698 | Â Â Â Â # Restraints |
---|
1699 | Â Â Â Â self.RestraintTab =Â wx.Menu(title='') |
---|
1700 | Â Â Â Â self.RestraintEdit =Â wx.Menu(title='') |
---|
1701 |     self.RestraintEdit.Append(id=wxID_RESTSELPHASE, kind=wx.ITEM_NORMAL,text='Select phase', |
---|
1702 | Â Â Â Â Â Â help='Select phase') |
---|
1703 |     self.RestraintEdit.Append(id=wxID_RESTRAINTADD, kind=wx.ITEM_NORMAL,text='Add restraints', |
---|
1704 | Â Â Â Â Â Â help='Add restraints') |
---|
1705 | Â Â Â Â self.RestraintEdit.Enable(wxID_RESTRAINTADD,True)Â Â #gets disabled if macromolecule phase |
---|
1706 |     self.RestraintEdit.Append(id=wxID_AARESTRAINTADD, kind=wx.ITEM_NORMAL,text='Add residue restraints', |
---|
1707 | Â Â Â Â Â Â help='Add residue based restraints for macromolecules from macro file') |
---|
1708 | Â Â Â Â self.RestraintEdit.Enable(wxID_AARESTRAINTADD,False)Â Â #gets enabled if macromolecule phase |
---|
1709 |     self.RestraintEdit.Append(id=wxID_AARESTRAINTPLOT, kind=wx.ITEM_NORMAL,text='Plot residue restraints', |
---|
1710 | Â Â Â Â Â Â help='Plot selected residue based restraints for macromolecules from macro file') |
---|
1711 | Â Â Â Â self.RestraintEdit.Enable(wxID_AARESTRAINTPLOT,False)Â Â #gets enabled if macromolecule phase |
---|
1712 |     self.RestraintEdit.Append(id=wxID_RESRCHANGEVAL, kind=wx.ITEM_NORMAL,text='Change value', |
---|
1713 | Â Â Â Â Â Â help='Change observed value') |
---|
1714 |     self.RestraintEdit.Append(id=wxID_RESTCHANGEESD, kind=wx.ITEM_NORMAL,text='Change esd', |
---|
1715 | Â Â Â Â Â Â help='Change esd in observed value') |
---|
1716 |     self.RestraintEdit.Append(id=wxID_RESTDELETE, kind=wx.ITEM_NORMAL,text='Delete restraints', |
---|
1717 | Â Â Â Â Â Â help='Delete selected restraints') |
---|
1718 | |
---|
1719 | Â Â Â Â self.RestraintMenu =Â wx.MenuBar() |
---|
1720 | Â Â Â Â self.PrefillDataMenu(self.RestraintMenu) |
---|
1721 |     self.RestraintMenu.Append(menu=self.RestraintTab, title='Select tab') |
---|
1722 |     self.RestraintMenu.Append(menu=self.RestraintEdit, title='Edit Restr.') |
---|
1723 | Â Â Â Â self.PostfillDataMenu() |
---|
1724 | Â Â Â Â Â Â |
---|
1725 | Â Â Â Â # Sequential results |
---|
1726 | Â Â Â Â self.SequentialMenu =Â wx.MenuBar() |
---|
1727 | Â Â Â Â self.PrefillDataMenu(self.SequentialMenu) |
---|
1728 | Â Â Â Â self.SequentialFile =Â wx.Menu(title='') |
---|
1729 |     self.SequentialMenu.Append(menu=self.SequentialFile, title='Columns') |
---|
1730 |     self.SequentialFile.Append(id=wxID_RENAMESEQSEL, kind=wx.ITEM_NORMAL,text='Rename selected', |
---|
1731 | Â Â Â Â Â Â help='Rename selected sequential refinement columns') |
---|
1732 |     self.SequentialFile.Append(id=wxID_SAVESEQSEL, kind=wx.ITEM_NORMAL,text='Save selected as text', |
---|
1733 | Â Â Â Â Â Â help='Save selected sequential refinement results as a text file') |
---|
1734 |     self.SequentialFile.Append(id=wxID_SAVESEQCSV, kind=wx.ITEM_NORMAL,text='Save all as CSV', |
---|
1735 | Â Â Â Â Â Â help='Save all sequential refinement results as a CSV spreadsheet file') |
---|
1736 |     self.SequentialFile.Append(id=wxID_SAVESEQSELCSV, kind=wx.ITEM_NORMAL,text='Save selected as CSV', |
---|
1737 | Â Â Â Â Â Â help='Save selected sequential refinement results as a CSV spreadsheet file') |
---|
1738 |     self.SequentialFile.Append(id=wxID_PLOTSEQSEL, kind=wx.ITEM_NORMAL,text='Plot selected', |
---|
1739 | Â Â Â Â Â Â help='Plot selected sequential refinement results') |
---|
1740 |     self.SequentialFile.Append(id=wxID_AVESEQSEL, kind=wx.ITEM_NORMAL,text='Compute average', |
---|
1741 | Â Â Â Â Â Â help='Compute average for selected parameter')Â Â Â Â Â Â |
---|
1742 |     self.SequentialFile.Append(id=wxID_ORGSEQSEL, kind=wx.ITEM_NORMAL,text='Reorganize', |
---|
1743 | Â Â Â Â Â Â help='Reorganize variables where variables change') |
---|
1744 | Â Â Â Â self.SequentialPvars =Â wx.Menu(title='') |
---|
1745 |     self.SequentialMenu.Append(menu=self.SequentialPvars, title='Pseudo Vars') |
---|
1746 | Â Â Â Â self.SequentialPvars.Append( |
---|
1747 |       id=wxADDSEQVAR, kind=wx.ITEM_NORMAL,text='Add Formula', |
---|
1748 | Â Â Â Â Â Â help='Add a new custom pseudo-variable') |
---|
1749 | Â Â Â Â self.SequentialPvars.Append( |
---|
1750 |       id=wxADDSEQDIST, kind=wx.ITEM_NORMAL,text='Add Distance', |
---|
1751 | Â Â Â Â Â Â help='Add a new bond distance pseudo-variable') |
---|
1752 | Â Â Â Â self.SequentialPvars.Append( |
---|
1753 |       id=wxADDSEQANGLE, kind=wx.ITEM_NORMAL,text='Add Angle', |
---|
1754 | Â Â Â Â Â Â help='Add a new bond angle pseudo-variable') |
---|
1755 | Â Â Â Â self.SequentialPvars.Append( |
---|
1756 |       id=wxDELSEQVAR, kind=wx.ITEM_NORMAL,text='Delete', |
---|
1757 | Â Â Â Â Â Â help='Delete an existing pseudo-variable') |
---|
1758 | Â Â Â Â self.SequentialPvars.Append( |
---|
1759 |       id=wxEDITSEQVAR, kind=wx.ITEM_NORMAL,text='Edit', |
---|
1760 | Â Â Â Â Â Â help='Edit an existing pseudo-variable') |
---|
1761 | |
---|
1762 | Â Â Â Â self.SequentialPfit =Â wx.Menu(title='') |
---|
1763 |     self.SequentialMenu.Append(menu=self.SequentialPfit, title='Parametric Fit') |
---|
1764 | Â Â Â Â self.SequentialPfit.Append( |
---|
1765 |       id=wxADDPARFIT, kind=wx.ITEM_NORMAL,text='Add equation', |
---|
1766 | Â Â Â Â Â Â help='Add a new equation to minimize') |
---|
1767 | Â Â Â Â self.SequentialPfit.Append( |
---|
1768 |       id=wxCOPYPARFIT, kind=wx.ITEM_NORMAL,text='Copy equation', |
---|
1769 | Â Â Â Â Â Â help='Copy an equation to minimize - edit it next') |
---|
1770 | Â Â Â Â self.SequentialPfit.Append( |
---|
1771 |       id=wxDELPARFIT, kind=wx.ITEM_NORMAL,text='Delete equation', |
---|
1772 | Â Â Â Â Â Â help='Delete an equation for parametric minimization') |
---|
1773 | Â Â Â Â self.SequentialPfit.Append( |
---|
1774 |       id=wxEDITPARFIT, kind=wx.ITEM_NORMAL,text='Edit equation', |
---|
1775 | Â Â Â Â Â Â help='Edit an existing parametric minimization equation') |
---|
1776 | Â Â Â Â self.SequentialPfit.Append( |
---|
1777 |       id=wxDOPARFIT, kind=wx.ITEM_NORMAL,text='Fit to equation(s)', |
---|
1778 | Â Â Â Â Â Â help='Perform a parametric minimization') |
---|
1779 | Â Â Â Â # fill sequential Export menu |
---|
1780 | Â Â Â Â self.SeqExportLookup =Â {} |
---|
1781 | Â Â Â Â self.SequentialEx =Â wx.Menu(title='') |
---|
1782 |     self.SequentialMenu.Append(menu=self.SequentialEx, title='Seq Export') |
---|
1783 |     for lbl,txt in (('Phase','Export selected phase(s)'), |
---|
1784 | Â Â Â Â Â Â Â Â Â Â Â Â ('Project','Export entire sequential fit')): |
---|
1785 | Â Â Â Â Â Â objlist =Â [] |
---|
1786 |       for obj in self.G2frame.exporterlist: |
---|
1787 |         if lbl.lower() in obj.exporttype: |
---|
1788 | Â Â Â Â Â Â Â Â Â Â try: |
---|
1789 | Â Â Â Â Â Â Â Â Â Â Â Â obj.Writer |
---|
1790 |           except AttributeError: |
---|
1791 | Â Â Â Â Â Â Â Â Â Â Â Â continue |
---|
1792 | Â Â Â Â Â Â Â Â Â Â objlist.append(obj) |
---|
1793 |       if objlist: |
---|
1794 | Â Â Â Â Â Â Â Â submenu =Â wx.Menu() |
---|
1795 | Â Â Â Â Â Â Â Â item =Â self.SequentialEx.AppendMenu( |
---|
1796 |           wx.ID_ANY, lbl+' as', |
---|
1797 |           submenu, help=txt) |
---|
1798 |         for obj in objlist: |
---|
1799 | Â Â Â Â Â Â Â Â Â Â item =Â submenu.Append( |
---|
1800 | Â Â Â Â Â Â Â Â Â Â Â Â wx.ID_ANY, |
---|
1801 | Â Â Â Â Â Â Â Â Â Â Â Â help=obj.longFormatName, |
---|
1802 | Â Â Â Â Â Â Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
1803 | Â Â Â Â Â Â Â Â Â Â Â Â text=obj.formatName) |
---|
1804 | Â Â Â Â Â Â Â Â Â Â self.SeqExportLookup[item.GetId()]Â =Â (obj,lbl)Â # lookup table for submenu item |
---|
1805 | Â Â Â Â |
---|
1806 | Â Â Â Â self.PostfillDataMenu() |
---|
1807 | Â Â Â Â Â Â |
---|
1808 | Â Â Â Â # PWDR & SASD |
---|
1809 | Â Â Â Â self.PWDRMenu =Â wx.MenuBar() |
---|
1810 | Â Â Â Â self.PrefillDataMenu(self.PWDRMenu) |
---|
1811 | Â Â Â Â self.ErrorAnal =Â wx.Menu(title='') |
---|
1812 | Â Â Â Â self.PWDRMenu.Append(menu=self.ErrorAnal,title='Commands') |
---|
1813 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDANALYSIS,kind=wx.ITEM_NORMAL,text='Error Analysis', |
---|
1814 | Â Â Â Â Â Â help='Error analysis on powder pattern') |
---|
1815 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDCOPY,kind=wx.ITEM_NORMAL,text='Copy params', |
---|
1816 | Â Â Â Â Â Â help='Copy of PWDR parameters') |
---|
1817 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PLOTCTRLCOPY,kind=wx.ITEM_NORMAL,text='Copy plot controls', |
---|
1818 | Â Â Â Â Â Â help='Copy of PWDR plot controls') |
---|
1819 | Â Â Â Â self.moveDiffCurve =Â self.ErrorAnal.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Move diff. curve', |
---|
1820 | Â Â Â Â Â Â help='Click on position where difference curve is placed') |
---|
1821 | Â Â Â Â self.moveTickLoc =Â self.ErrorAnal.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Move ticks', |
---|
1822 | Â Â Â Â Â Â help='Move mouse to where tick marks should be positioned') |
---|
1823 | Â Â Â Â self.moveTickSpc =Â self.ErrorAnal.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Set tick space', |
---|
1824 | Â Â Â Â Â Â help='Click to set spacing between phase tick marks') |
---|
1825 | Â Â Â Â self.PostfillDataMenu() |
---|
1826 | Â Â Â Â Â Â |
---|
1827 | Â Â Â Â # HKLF |
---|
1828 | Â Â Â Â self.HKLFMenu =Â wx.MenuBar() |
---|
1829 | Â Â Â Â self.PrefillDataMenu(self.HKLFMenu) |
---|
1830 | Â Â Â Â self.ErrorAnal =Â wx.Menu(title='') |
---|
1831 | Â Â Â Â self.HKLFMenu.Append(menu=self.ErrorAnal,title='Commands') |
---|
1832 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDANALYSIS,kind=wx.ITEM_NORMAL,text='Error Analysis', |
---|
1833 | Â Â Â Â Â Â help='Error analysis on single crystal data') |
---|
1834 | Â Â Â Â self.ErrorAnal.Append(id=wxID_MERGEHKL,kind=wx.ITEM_NORMAL,text='Merge HKLs', |
---|
1835 | Â Â Â Â Â Â help='Transform & merge HKLF data to new histogram') |
---|
1836 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWD3DHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot 3D HKLs', |
---|
1837 | Â Â Â Â Â Â help='Plot HKLs from single crystal data in 3D') |
---|
1838 | Â Â Â Â self.ErrorAnal.Append(id=wxID_3DALLHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot all 3D HKLs', |
---|
1839 | Â Â Â Â Â Â help='Plot HKLs from all single crystal data in 3D') |
---|
1840 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDCOPY,kind=wx.ITEM_NORMAL,text='Copy params', |
---|
1841 | Â Â Â Â Â Â help='Copy of HKLF parameters') |
---|
1842 | Â Â Â Â self.PostfillDataMenu() |
---|
1843 | Â Â Â Â Â Â |
---|
1844 | Â Â Â Â # PWDR / Limits |
---|
1845 | Â Â Â Â self.LimitMenu =Â wx.MenuBar() |
---|
1846 | Â Â Â Â self.PrefillDataMenu(self.LimitMenu) |
---|
1847 | Â Â Â Â self.LimitEdit =Â wx.Menu(title='') |
---|
1848 |     self.LimitMenu.Append(menu=self.LimitEdit, title='Edit Limits') |
---|
1849 |     self.LimitEdit.Append(id=wxID_LIMITCOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
1850 | Â Â Â Â Â Â help='Copy limits to other histograms') |
---|
1851 |     self.LimitEdit.Append(id=wxID_ADDEXCLREGION, kind=wx.ITEM_NORMAL,text='Add exclude', |
---|
1852 | Â Â Â Â Â Â help='Add excluded region - select a point on plot; drag to adjust')Â Â Â Â Â Â |
---|
1853 | Â Â Â Â self.PostfillDataMenu() |
---|
1854 | Â Â Â Â Â Â |
---|
1855 | Â Â Â Â # PDR / Background |
---|
1856 | Â Â Â Â self.BackMenu =Â wx.MenuBar() |
---|
1857 | Â Â Â Â self.PrefillDataMenu(self.BackMenu) |
---|
1858 | Â Â Â Â self.BackEdit =Â wx.Menu(title='') |
---|
1859 |     self.BackMenu.Append(menu=self.BackEdit, title='File') |
---|
1860 |     self.BackEdit.Append(id=wxID_BACKCOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
1861 | Â Â Â Â Â Â help='Copy background parameters to other histograms') |
---|
1862 |     self.BackEdit.Append(id=wxID_BACKFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
1863 | Â Â Â Â Â Â help='Copy background refinement flags to other histograms') |
---|
1864 |     self.BackEdit.Append(id=wxID_PEAKSMOVE, kind=wx.ITEM_NORMAL,text='Move peaks', |
---|
1865 | Â Â Â Â Â Â help='Move background peaks to Peak List') |
---|
1866 |     self.BackEdit.Append(id=wxID_MAKEBACKRDF, kind=wx.ITEM_NORMAL,text='Plot RDF', |
---|
1867 | Â Â Â Â Â Â help='Plot radial distribution from differences') |
---|
1868 | Â Â Â Â self.BackFixed =Â wx.Menu(title='')Â # fixed background point menu |
---|
1869 |     self.BackMenu.Append(menu=self.BackFixed, title='Fixed Points') |
---|
1870 | Â Â Â Â self.wxID_BackPts =Â {} |
---|
1871 | Â Â Â Â self.wxID_BackPts['Add']Â =Â wx.NewId()Â # N.B. not using wxID_ global as for other menu items |
---|
1872 |     self.BackFixed.Append(id=self.wxID_BackPts['Add'], kind=wx.ITEM_RADIO,text='Add', |
---|
1873 | Â Â Â Â Â Â help='Add fixed background points with mouse clicks') |
---|
1874 | Â Â Â Â self.wxID_BackPts['Move']Â =Â wx.NewId()Â |
---|
1875 |     item = self.BackFixed.Append(id=self.wxID_BackPts['Move'], kind=wx.ITEM_RADIO,text='Move', |
---|
1876 | Â Â Â Â Â Â help='Move selected fixed background points with mouse drags') |
---|
1877 | Â Â Â Â item.Check(True) |
---|
1878 | Â Â Â Â self.wxID_BackPts['Del']Â =Â wx.NewId() |
---|
1879 |     self.BackFixed.Append(id=self.wxID_BackPts['Del'], kind=wx.ITEM_RADIO,text='Delete', |
---|
1880 | Â Â Â Â Â Â help='Delete fixed background points with mouse clicks') |
---|
1881 | Â Â Â Â self.wxID_BackPts['Clear']Â =Â wx.NewId()Â |
---|
1882 |     self.BackFixed.Append(id=self.wxID_BackPts['Clear'], kind=wx.ITEM_NORMAL,text='Clear', |
---|
1883 | Â Â Â Â Â Â help='Clear fixed background points') |
---|
1884 | Â Â Â Â self.wxID_BackPts['Fit']Â =Â wx.NewId()Â |
---|
1885 |     self.BackFixed.Append(id=self.wxID_BackPts['Fit'], kind=wx.ITEM_NORMAL,text='Fit background', |
---|
1886 | Â Â Â Â Â Â help='Fit background function to fixed background points') |
---|
1887 | Â Â Â Â self.PostfillDataMenu() |
---|
1888 | Â Â Â Â Â Â |
---|
1889 | Â Â Â Â # PDR / Instrument Parameters |
---|
1890 | Â Â Â Â self.InstMenu =Â wx.MenuBar() |
---|
1891 | Â Â Â Â self.PrefillDataMenu(self.InstMenu) |
---|
1892 | Â Â Â Â self.InstEdit =Â wx.Menu(title='') |
---|
1893 |     self.InstMenu.Append(menu=self.InstEdit, title='Operations') |
---|
1894 |     self.InstEdit.Append(help='Calibrate from indexed peaks', |
---|
1895 |       id=wxID_INSTCALIB, kind=wx.ITEM_NORMAL,text='Calibrate')      |
---|
1896 |     self.InstEdit.Append(help='Reset instrument profile parameters to default', |
---|
1897 |       id=wxID_INSTPRMRESET, kind=wx.ITEM_NORMAL,text='Reset profile')      |
---|
1898 |     self.InstEdit.Append(help='Load instrument profile parameters from file', |
---|
1899 |       id=wxID_INSTLOAD, kind=wx.ITEM_NORMAL,text='Load profile...')      |
---|
1900 |     self.InstEdit.Append(help='Save instrument profile parameters to file', |
---|
1901 |       id=wxID_INSTSAVE, kind=wx.ITEM_NORMAL,text='Save profile...') |
---|
1902 |     self.InstEdit.Append(help='Save all instrument profile parameters to one file', |
---|
1903 |       id=wxID_INSTSAVEALL, kind=wx.ITEM_NORMAL,text='Save all profile...')      |
---|
1904 |     self.InstEdit.Append(help='Copy instrument profile parameters to other histograms', |
---|
1905 |       id=wxID_INSTCOPY, kind=wx.ITEM_NORMAL,text='Copy') |
---|
1906 |     self.InstEdit.Append(id=wxID_INSTFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
1907 | Â Â Â Â Â Â help='Copy instrument parameter refinement flags to other histograms') |
---|
1908 | #Â Â Â Â self.InstEdit.Append(help='Change radiation type (Ka12 - synch)', |
---|
1909 | #Â Â Â Â Â Â id=wxID_CHANGEWAVETYPE, kind=wx.ITEM_NORMAL,text='Change radiation') |
---|
1910 |     self.InstEdit.Append(id=wxID_INST1VAL, kind=wx.ITEM_NORMAL,text='Set one value', |
---|
1911 | Â Â Â Â Â Â help='Set one instrument parameter value across multiple histograms') |
---|
1912 | |
---|
1913 | Â Â Â Â self.PostfillDataMenu() |
---|
1914 | Â Â Â Â |
---|
1915 | Â Â Â Â # PDR / Sample Parameters |
---|
1916 | Â Â Â Â self.SampleMenu =Â wx.MenuBar() |
---|
1917 | Â Â Â Â self.PrefillDataMenu(self.SampleMenu) |
---|
1918 | Â Â Â Â self.SampleEdit =Â wx.Menu(title='') |
---|
1919 |     self.SampleMenu.Append(menu=self.SampleEdit, title='Command') |
---|
1920 |     self.SetScale = self.SampleEdit.Append(id=wxID_SETSCALE, kind=wx.ITEM_NORMAL,text='Set scale', |
---|
1921 | Â Â Â Â Â Â help='Set scale by matching to another histogram') |
---|
1922 |     self.SampleEdit.Append(id=wxID_SAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load', |
---|
1923 | Â Â Â Â Â Â help='Load sample parameters from file') |
---|
1924 |     self.SampleEdit.Append(id=wxID_SAMPLESAVE, kind=wx.ITEM_NORMAL,text='Save', |
---|
1925 | Â Â Â Â Â Â help='Save sample parameters to file') |
---|
1926 |     self.SampleEdit.Append(id=wxID_SAMPLECOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
1927 | Â Â Â Â Â Â help='Copy refinable and most other sample parameters to other histograms') |
---|
1928 |     self.SampleEdit.Append(id=wxID_SAMPLECOPYSOME, kind=wx.ITEM_NORMAL,text='Copy selected...', |
---|
1929 | Â Â Â Â Â Â help='Copy selected sample parameters to other histograms') |
---|
1930 |     self.SampleEdit.Append(id=wxID_SAMPLEFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
1931 | Â Â Â Â Â Â help='Copy sample parameter refinement flags to other histograms') |
---|
1932 |     self.SampleEdit.Append(id=wxID_SAMPLE1VAL, kind=wx.ITEM_NORMAL,text='Set one value', |
---|
1933 | Â Â Â Â Â Â help='Set one sample parameter value across multiple histograms') |
---|
1934 |     self.SampleEdit.Append(id=wxID_ALLSAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load all', |
---|
1935 | Â Â Â Â Â Â help='Load sample parmameters over multiple histograms') |
---|
1936 | |
---|
1937 | Â Â Â Â self.PostfillDataMenu() |
---|
1938 | Â Â Â Â self.SetScale.Enable(False) |
---|
1939 | |
---|
1940 | Â Â Â Â # PDR / Peak List |
---|
1941 | Â Â Â Â self.PeakMenu =Â wx.MenuBar() |
---|
1942 | Â Â Â Â self.PrefillDataMenu(self.PeakMenu) |
---|
1943 | Â Â Â Â self.PeakEdit =Â wx.Menu(title='') |
---|
1944 |     self.PeakMenu.Append(menu=self.PeakEdit, title='Peak Fitting') |
---|
1945 | Â Â Â Â self.peaksSel =Â self.PeakEdit.Append(wx.ID_ANY, |
---|
1946 | Â Â Â Â Â Â help='Set refinement flags for selected peaks', |
---|
1947 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
1948 | Â Â Â Â Â Â text='Set sel. ref flags...') |
---|
1949 | Â Â Â Â self.peaksAll =Â self.PeakEdit.Append(wx.ID_ANY, |
---|
1950 | Â Â Â Â Â Â help='Set refinement flags for all peaks', |
---|
1951 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
1952 | Â Â Â Â Â Â text='Set all ref flags...') |
---|
1953 |     self.AutoSearch = self.PeakEdit.Append(help='Automatic peak search', |
---|
1954 |       id=wxID_AUTOSEARCH, kind=wx.ITEM_NORMAL,text='Auto search') |
---|
1955 |     self.UnDo = self.PeakEdit.Append(help='Undo last least squares refinement', |
---|
1956 |       id=wxID_UNDO, kind=wx.ITEM_NORMAL,text='UnDo') |
---|
1957 |     self.PeakFit = self.PeakEdit.Append(id=wxID_LSQPEAKFIT, kind=wx.ITEM_NORMAL,text='Peakfit', |
---|
1958 | Â Â Â Â Â Â help='Peak fitting'Â ) |
---|
1959 |     self.PFOneCycle = self.PeakEdit.Append(id=wxID_LSQONECYCLE, kind=wx.ITEM_NORMAL,text='Peakfit one cycle', |
---|
1960 | Â Â Â Â Â Â help='One cycle of Peak fitting'Â ) |
---|
1961 |     self.PeakEdit.Append(id=wxID_RESETSIGGAM, kind=wx.ITEM_NORMAL, |
---|
1962 | Â Â Â Â Â Â text='Reset sig and gam',help='Reset sigma and gamma to global fit'Â ) |
---|
1963 |     self.PeakCopy = self.PeakEdit.Append(help='Copy peaks to other histograms', |
---|
1964 |       id=wxID_PEAKSCOPY, kind=wx.ITEM_NORMAL,text='Peak copy') |
---|
1965 |     self.SeqPeakFit = self.PeakEdit.Append(id=wxID_SEQPEAKFIT, kind=wx.ITEM_NORMAL,text='Seq PeakFit', |
---|
1966 | Â Â Â Â Â Â help='Sequential Peak fitting for all histograms'Â ) |
---|
1967 |     self.PeakEdit.Append(id=wxID_CLEARPEAKS, kind=wx.ITEM_NORMAL,text='Clear peaks', |
---|
1968 | Â Â Â Â Â Â help='Clear the peak list'Â ) |
---|
1969 | Â Â Â Â self.movePeak =Â self.PeakEdit.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Move selected peak', |
---|
1970 | Â Â Â Â Â Â help='Select a peak in the table, then use this to move it with the mouse.') |
---|
1971 | Â Â Â Â self.PostfillDataMenu() |
---|
1972 | Â Â Â Â self.UnDo.Enable(False) |
---|
1973 | Â Â Â Â self.PeakFit.Enable(False) |
---|
1974 | Â Â Â Â self.PFOneCycle.Enable(False) |
---|
1975 | Â Â Â Â self.AutoSearch.Enable(True) |
---|
1976 | Â Â Â Â |
---|
1977 | Â Â Â Â # PDR / Index Peak List |
---|
1978 | Â Â Â Â self.IndPeaksMenu =Â wx.MenuBar() |
---|
1979 | Â Â Â Â self.PrefillDataMenu(self.IndPeaksMenu) |
---|
1980 | Â Â Â Â self.IndPeaksEdit =Â wx.Menu(title='') |
---|
1981 | Â Â Â Â self.IndPeaksMenu.Append(menu=self.IndPeaksEdit,title='Operations') |
---|
1982 |     self.IndPeaksEdit.Append(help='Load/Reload index peaks from peak list',id=wxID_INDXRELOAD, |
---|
1983 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Load/Reload') |
---|
1984 | Â Â Â Â self.PostfillDataMenu() |
---|
1985 | Â Â Â Â |
---|
1986 | Â Â Â Â # PDR / Unit Cells List |
---|
1987 | Â Â Â Â self.IndexMenu =Â wx.MenuBar() |
---|
1988 | Â Â Â Â self.PrefillDataMenu(self.IndexMenu) |
---|
1989 | Â Â Â Â self.IndexEdit =Â wx.Menu(title='') |
---|
1990 |     self.IndexMenu.Append(menu=self.IndexEdit, title='Cell Index/Refine') |
---|
1991 |     self.IndexPeaks = self.IndexEdit.Append(help='', id=wxID_INDEXPEAKS, kind=wx.ITEM_NORMAL, |
---|
1992 | Â Â Â Â Â Â text='Index Cell') |
---|
1993 |     self.CopyCell = self.IndexEdit.Append( id=wxID_COPYCELL, kind=wx.ITEM_NORMAL,text='Copy Cell', |
---|
1994 | Â Â Â Â Â Â help='Copy selected unit cell from indexing to cell refinement fields') |
---|
1995 |     self.RefineCell = self.IndexEdit.Append( id=wxID_REFINECELL, kind=wx.ITEM_NORMAL, |
---|
1996 | Â Â Â Â Â Â text='Refine Cell',help='Refine unit cell parameters from indexed peaks') |
---|
1997 |     self.MakeNewPhase = self.IndexEdit.Append( id=wxID_MAKENEWPHASE, kind=wx.ITEM_NORMAL, |
---|
1998 | Â Â Â Â Â Â text='Make new phase',help='Make new phase from selected unit cell') |
---|
1999 |     self.ExportCells = self.IndexEdit.Append( id=wxID_EXPORTCELLS, kind=wx.ITEM_NORMAL, |
---|
2000 | Â Â Â Â Â Â text='Export cell list',help='Export cell list to csv file') |
---|
2001 | Â Â Â Â self.PostfillDataMenu() |
---|
2002 | Â Â Â Â self.IndexPeaks.Enable(False) |
---|
2003 | Â Â Â Â self.CopyCell.Enable(False) |
---|
2004 | Â Â Â Â self.RefineCell.Enable(False) |
---|
2005 | Â Â Â Â self.MakeNewPhase.Enable(False) |
---|
2006 | Â Â Â Â |
---|
2007 | Â Â Â Â # PDR / Reflection Lists |
---|
2008 | Â Â Â Â self.ReflMenu =Â wx.MenuBar() |
---|
2009 | Â Â Â Â self.PrefillDataMenu(self.ReflMenu) |
---|
2010 | Â Â Â Â self.ReflEdit =Â wx.Menu(title='') |
---|
2011 |     self.ReflMenu.Append(menu=self.ReflEdit, title='Reflection List') |
---|
2012 |     self.SelectPhase = self.ReflEdit.Append(help='Select phase for reflection list',id=wxID_SELECTPHASE, |
---|
2013 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Select phase') |
---|
2014 | Â Â Â Â self.ReflEdit.Append(id=wxID_PWDHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot HKLs', |
---|
2015 | Â Â Â Â Â Â help='Plot HKLs from powder pattern') |
---|
2016 | Â Â Â Â self.ReflEdit.Append(id=wxID_PWD3DHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot 3D HKLs', |
---|
2017 | Â Â Â Â Â Â help='Plot HKLs from powder pattern in 3D') |
---|
2018 | Â Â Â Â self.PostfillDataMenu() |
---|
2019 | Â Â Â Â |
---|
2020 | Â Â Â Â # SASD / Instrument Parameters |
---|
2021 | Â Â Â Â self.SASDInstMenu =Â wx.MenuBar() |
---|
2022 | Â Â Â Â self.PrefillDataMenu(self.SASDInstMenu) |
---|
2023 | Â Â Â Â self.SASDInstEdit =Â wx.Menu(title='') |
---|
2024 |     self.SASDInstMenu.Append(menu=self.SASDInstEdit, title='Operations') |
---|
2025 |     self.InstEdit.Append(help='Reset instrument profile parameters to default', |
---|
2026 |       id=wxID_INSTPRMRESET, kind=wx.ITEM_NORMAL,text='Reset profile') |
---|
2027 |     self.SASDInstEdit.Append(help='Copy instrument profile parameters to other histograms', |
---|
2028 |       id=wxID_INSTCOPY, kind=wx.ITEM_NORMAL,text='Copy') |
---|
2029 | Â Â Â Â self.PostfillDataMenu() |
---|
2030 | Â Â Â Â |
---|
2031 | Â Â Â Â #SASD & REFL/ Substance editor |
---|
2032 | Â Â Â Â self.SubstanceMenu =Â wx.MenuBar() |
---|
2033 | Â Â Â Â self.PrefillDataMenu(self.SubstanceMenu) |
---|
2034 | Â Â Â Â self.SubstanceEdit =Â wx.Menu(title='') |
---|
2035 |     self.SubstanceMenu.Append(menu=self.SubstanceEdit, title='Edit substance') |
---|
2036 |     self.SubstanceEdit.Append(id=wxID_LOADSUBSTANCE, kind=wx.ITEM_NORMAL,text='Load substance', |
---|
2037 | Â Â Â Â Â Â help='Load substance from file') |
---|
2038 |     self.SubstanceEdit.Append(id=wxID_ADDSUBSTANCE, kind=wx.ITEM_NORMAL,text='Add substance', |
---|
2039 | Â Â Â Â Â Â help='Add new substance to list') |
---|
2040 |     self.SubstanceEdit.Append(id=wxID_COPYSUBSTANCE, kind=wx.ITEM_NORMAL,text='Copy substances', |
---|
2041 | Â Â Â Â Â Â help='Copy substances') |
---|
2042 |     self.SubstanceEdit.Append(id=wxID_DELETESUBSTANCE, kind=wx.ITEM_NORMAL,text='Delete substance', |
---|
2043 | Â Â Â Â Â Â help='Delete substance from list')Â Â Â Â Â Â |
---|
2044 |     self.SubstanceEdit.Append(id=wxID_ELEMENTADD, kind=wx.ITEM_NORMAL,text='Add elements', |
---|
2045 | Â Â Â Â Â Â help='Add elements to substance') |
---|
2046 |     self.SubstanceEdit.Append(id=wxID_ELEMENTDELETE, kind=wx.ITEM_NORMAL,text='Delete elements', |
---|
2047 | Â Â Â Â Â Â help='Delete elements from substance') |
---|
2048 | Â Â Â Â self.PostfillDataMenu() |
---|
2049 | Â Â Â Â |
---|
2050 | Â Â Â Â # SASD/ Models |
---|
2051 | Â Â Â Â self.ModelMenu =Â wx.MenuBar() |
---|
2052 | Â Â Â Â self.PrefillDataMenu(self.ModelMenu) |
---|
2053 | Â Â Â Â self.ModelEdit =Â wx.Menu(title='') |
---|
2054 |     self.ModelMenu.Append(menu=self.ModelEdit, title='Models') |
---|
2055 | Â Â Â Â self.ModelEdit.Append(id=wxID_MODELADD,kind=wx.ITEM_NORMAL,text='Add', |
---|
2056 | Â Â Â Â Â Â help='Add new term to model') |
---|
2057 |     self.ModelEdit.Append(id=wxID_MODELFIT, kind=wx.ITEM_NORMAL,text='Fit', |
---|
2058 | Â Â Â Â Â Â help='Fit model parameters to data') |
---|
2059 |     self.SasdUndo = self.ModelEdit.Append(id=wxID_MODELUNDO, kind=wx.ITEM_NORMAL,text='Undo', |
---|
2060 | Â Â Â Â Â Â help='Undo model fit') |
---|
2061 | Â Â Â Â self.SasdUndo.Enable(False)Â Â Â Â Â Â |
---|
2062 |     self.ModelEdit.Append(id=wxID_MODELFITALL, kind=wx.ITEM_NORMAL,text='Sequential fit', |
---|
2063 | Â Â Â Â Â Â help='Sequential fit of model parameters to all SASD data') |
---|
2064 |     self.ModelEdit.Append(id=wxID_MODELCOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
2065 | Â Â Â Â Â Â help='Copy model parameters to other histograms') |
---|
2066 |     self.ModelEdit.Append(id=wxID_MODELCOPYFLAGS, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
2067 | Â Â Â Â Â Â help='Copy model refinement flags to other histograms') |
---|
2068 | Â Â Â Â self.PostfillDataMenu() |
---|
2069 | Â Â Â Â |
---|
2070 | Â Â Â Â # IMG / Image Controls |
---|
2071 | Â Â Â Â self.ImageMenu =Â wx.MenuBar() |
---|
2072 | Â Â Â Â self.PrefillDataMenu(self.ImageMenu) |
---|
2073 | Â Â Â Â self.ImageEdit =Â wx.Menu(title='') |
---|
2074 |     self.ImageMenu.Append(menu=self.ImageEdit, title='Operations') |
---|
2075 |     self.ImageEdit.Append(help='Calibrate detector by fitting to calibrant lines', |
---|
2076 |       id=wxID_IMCALIBRATE, kind=wx.ITEM_NORMAL,text='Calibrate') |
---|
2077 |     self.ImageEdit.Append(help='Recalibrate detector by fitting to calibrant lines', |
---|
2078 |       id=wxID_IMRECALIBRATE, kind=wx.ITEM_NORMAL,text='Recalibrate') |
---|
2079 |     self.ImageEdit.Append(help='Recalibrate all images by fitting to calibrant lines', |
---|
2080 |       id=wxID_IMRECALIBALL, kind=wx.ITEM_NORMAL,text='Recalibrate all')      |
---|
2081 |     self.ImageEdit.Append(help='Clear calibration data points and rings',id=wxID_IMCLEARCALIB, |
---|
2082 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Clear calibration') |
---|
2083 |     self.ImageEdit.Append(help='Integrate selected image',id=wxID_IMINTEGRATE, |
---|
2084 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Integrate') |
---|
2085 | Â Â Â Â self.ImageEdit.Append(help='Integrate all images selected from list',id=wxID_INTEGRATEALL, |
---|
2086 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Integrate all') |
---|
2087 |     self.ImageEdit.Append(help='Copy image controls to other images', |
---|
2088 |       id=wxID_IMCOPYCONTROLS, kind=wx.ITEM_NORMAL,text='Copy Controls') |
---|
2089 |     self.ImageEdit.Append(help='Copy selected image controls to other images', |
---|
2090 |       id=wxID_IMCOPYSELECTED, kind=wx.ITEM_NORMAL,text='Copy Selected') |
---|
2091 |     self.ImageEdit.Append(help='Save image controls to file', |
---|
2092 |       id=wxID_IMSAVECONTROLS, kind=wx.ITEM_NORMAL,text='Save Controls') |
---|
2093 |     self.ImageEdit.Append(help='Save controls from selected images to file', |
---|
2094 |       id=wxID_SAVESELECTEDCONTROLS, kind=wx.ITEM_NORMAL,text='Save Multiple Controls') |
---|
2095 | Â Â Â Â self.ImageEdit.Append(help='Load image controls from file', |
---|
2096 |       id=wxID_IMLOADCONTROLS, kind=wx.ITEM_NORMAL,text='Load Controls') |
---|
2097 |     self.ImageEdit.Append(help='Transfer integration range for other detector distances', |
---|
2098 |       id=wxID_IMXFERCONTROLS, kind=wx.ITEM_NORMAL,text='Xfer angles') |
---|
2099 |     self.ImageEdit.Append(help='Open Auto-integration window to integrate a series of images', |
---|
2100 |       id=wxID_IMAUTOINTEG, kind=wx.ITEM_NORMAL,text='Auto Integrate') |
---|
2101 | Â Â Â Â self.PostfillDataMenu() |
---|
2102 | Â Â Â Â Â Â |
---|
2103 | Â Â Â Â # IMG / Masks |
---|
2104 | Â Â Â Â self.MaskMenu =Â wx.MenuBar() |
---|
2105 | Â Â Â Â self.PrefillDataMenu(self.MaskMenu) |
---|
2106 | Â Â Â Â self.MaskEdit =Â wx.Menu(title='') |
---|
2107 |     self.MaskMenu.Append(menu=self.MaskEdit, title='Operations') |
---|
2108 | Â Â Â Â submenu =Â wx.Menu() |
---|
2109 | Â Â Â Â self.MaskEdit.AppendMenu( |
---|
2110 |       wx.ID_ANY,'Create new', submenu, |
---|
2111 | Â Â Â Â Â Â help='' |
---|
2112 | Â Â Â Â Â Â ) |
---|
2113 |     self.MaskEdit.Append(help='Copy mask to other images', |
---|
2114 |       id=wxID_MASKCOPY, kind=wx.ITEM_NORMAL,text='Copy mask') |
---|
2115 |     self.MaskEdit.Append(help='Save mask to file', |
---|
2116 |       id=wxID_MASKSAVE, kind=wx.ITEM_NORMAL,text='Save mask') |
---|
2117 |     self.MaskEdit.Append(help='Load mask from file', |
---|
2118 |       id=wxID_MASKLOAD, kind=wx.ITEM_NORMAL,text='Load mask') |
---|
2119 |     self.MaskEdit.Append(help='Load mask from file; ignore threshold', |
---|
2120 |       id=wxID_MASKLOADNOT, kind=wx.ITEM_NORMAL,text='Load mask w/o threshold') |
---|
2121 |     self.MaskEdit.Append(help='Auto search for spot masks; NB: will clear old spot masks', |
---|
2122 |       id=wxID_FINDSPOTS, kind=wx.ITEM_NORMAL,text='Auto spot masks') |
---|
2123 |     submenu.Append(help='Create an arc mask with mouse input', |
---|
2124 |       id=wxID_NEWMASKARC, kind=wx.ITEM_NORMAL,text='Arc mask') |
---|
2125 |     submenu.Append(help='Create a frame mask with mouse input', |
---|
2126 |       id=wxID_NEWMASKFRAME, kind=wx.ITEM_NORMAL,text='Frame mask') |
---|
2127 |     submenu.Append(help='Create a polygon mask with mouse input', |
---|
2128 |       id=wxID_NEWMASKPOLY, kind=wx.ITEM_NORMAL,text='Polygon mask') |
---|
2129 |     submenu.Append(help='Create a ring mask with mouse input', |
---|
2130 |       id=wxID_NEWMASKRING, kind=wx.ITEM_NORMAL,text='Ring mask') |
---|
2131 |     submenu.Append(help='Create spot masks with mouse input', |
---|
2132 |       id=wxID_NEWMASKSPOT, kind=wx.ITEM_NORMAL,text='Spot mask') |
---|
2133 | Â Â Â Â self.PostfillDataMenu() |
---|
2134 | Â Â Â Â Â Â |
---|
2135 | Â Â Â Â # IMG / Stress/Strain |
---|
2136 | Â Â Â Â self.StrStaMenu =Â wx.MenuBar() |
---|
2137 | Â Â Â Â self.PrefillDataMenu(self.StrStaMenu) |
---|
2138 | Â Â Â Â self.StrStaEdit =Â wx.Menu(title='') |
---|
2139 |     self.StrStaMenu.Append(menu=self.StrStaEdit, title='Operations') |
---|
2140 |     self.StrStaEdit.Append(help='Append d-zero for one ring', |
---|
2141 |       id=wxID_APPENDDZERO, kind=wx.ITEM_NORMAL,text='Append d-zero') |
---|
2142 |     self.StrStaEdit.Append(help='Fit stress/strain data', |
---|
2143 |       id=wxID_STRSTAFIT, kind=wx.ITEM_NORMAL,text='Fit stress/strain') |
---|
2144 |     self.StrStaEdit.Append(help='Plot intensity distribution', |
---|
2145 |       id=wxID_STRSTAPLOT, kind=wx.ITEM_NORMAL,text='Plot intensity distribution') |
---|
2146 | Â Â Â Â self.StrStaEdit.Append(help='Update d-zero from ave d-zero', |
---|
2147 |       id=wxID_UPDATEDZERO, kind=wx.ITEM_NORMAL,text='Update d-zero')    |
---|
2148 |     self.StrStaEdit.Append(help='Fit stress/strain data for all images', |
---|
2149 |       id=wxID_STRSTAALLFIT, kind=wx.ITEM_NORMAL,text='All image fit') |
---|
2150 |     self.StrStaEdit.Append(help='Copy stress/strain data to other images', |
---|
2151 |       id=wxID_STRSTACOPY, kind=wx.ITEM_NORMAL,text='Copy stress/strain') |
---|
2152 |     self.StrStaEdit.Append(help='Save stress/strain data to file', |
---|
2153 |       id=wxID_STRSTASAVE, kind=wx.ITEM_NORMAL,text='Save stress/strain') |
---|
2154 |     self.StrStaEdit.Append(help='Load stress/strain data from file', |
---|
2155 |       id=wxID_STRSTALOAD, kind=wx.ITEM_NORMAL,text='Load stress/strain') |
---|
2156 |     self.StrStaEdit.Append(help='Load sample data from file', |
---|
2157 |       id=wxID_STRSTSAMPLE, kind=wx.ITEM_NORMAL,text='Load sample data') |
---|
2158 | Â Â Â Â self.PostfillDataMenu() |
---|
2159 | Â Â Â Â Â Â |
---|
2160 | Â Â Â Â # PDF / PDF Controls |
---|
2161 | Â Â Â Â self.PDFMenu =Â wx.MenuBar() |
---|
2162 | Â Â Â Â self.PrefillDataMenu(self.PDFMenu) |
---|
2163 | Â Â Â Â self.PDFEdit =Â wx.Menu(title='') |
---|
2164 |     self.PDFMenu.Append(menu=self.PDFEdit, title='PDF Controls') |
---|
2165 |     self.PDFEdit.Append(help='Add one or more elements to sample composition',id=wxID_PDFADDELEMENT, kind=wx.ITEM_NORMAL, |
---|
2166 | Â Â Â Â Â Â text='Add elements') |
---|
2167 |     self.PDFEdit.Append(help='Delete element from sample composition',id=wxID_PDFDELELEMENT, kind=wx.ITEM_NORMAL, |
---|
2168 | Â Â Â Â Â Â text='Delete element') |
---|
2169 |     self.PDFEdit.Append(help='Copy PDF controls', id=wxID_PDFCOPYCONTROLS, kind=wx.ITEM_NORMAL, |
---|
2170 | Â Â Â Â Â Â text='Copy controls') |
---|
2171 |     self.PDFEdit.Append(help='Load PDF controls from file',id=wxID_PDFLOADCONTROLS, kind=wx.ITEM_NORMAL, |
---|
2172 | Â Â Â Â Â Â text='Load Controls') |
---|
2173 |     self.PDFEdit.Append(help='Save PDF controls to file', id=wxID_PDFSAVECONTROLS, kind=wx.ITEM_NORMAL, |
---|
2174 | Â Â Â Â Â Â text='Save controls') |
---|
2175 |     self.PDFEdit.Append(help='Compute PDF', id=wxID_PDFCOMPUTE, kind=wx.ITEM_NORMAL, |
---|
2176 | Â Â Â Â Â Â text='Compute PDF') |
---|
2177 |     self.PDFEdit.Append(help='Compute all PDFs', id=wxID_PDFCOMPUTEALL, kind=wx.ITEM_NORMAL, |
---|
2178 | Â Â Â Â Â Â text='Compute all PDFs') |
---|
2179 | #Â Â Â Â self.PDFEdit.Append(help='Optimize PDF', id=wxID_PDFOPT, kind=wx.ITEM_NORMAL, |
---|
2180 | #Â Â Â Â Â Â text='Optimize corrections for r<Rmin section of current G(r)') |
---|
2181 | Â Â Â Â self.PostfillDataMenu() |
---|
2182 | Â Â Â Â |
---|
2183 | Â Â Â Â # PDF / PDF Peaks |
---|
2184 | Â Â Â Â self.PDFPksMenu =Â wx.MenuBar() |
---|
2185 | Â Â Â Â self.PrefillDataMenu(self.PDFPksMenu) |
---|
2186 | Â Â Â Â self.PDFPksEdit =Â wx.Menu(title='') |
---|
2187 |     self.PDFPksMenu.Append(menu=self.PDFPksEdit, title='PDF Peaks') |
---|
2188 |     self.PDFPksEdit.Append(help='Fit PDF peaks', id=wxID_PDFPKSFIT, kind=wx.ITEM_NORMAL, |
---|
2189 | Â Â Â Â Â Â text='Fit Peaks') |
---|
2190 |     self.PDFPksEdit.Append(help='Fit all PDF peaks', id=wxID_PDFPKSFITALL, kind=wx.ITEM_NORMAL, |
---|
2191 | Â Â Â Â Â Â text='Fit all PDF peakss') |
---|
2192 |     self.PDFPksEdit.Append(help='Copy PDF peaks', id=wxID_PDFCOPYPEAKS, kind=wx.ITEM_NORMAL, |
---|
2193 | Â Â Â Â Â Â text='Copy peaks') |
---|
2194 | Â Â Â Â |
---|
2195 | Â Â Â Â self.PostfillDataMenu() |
---|
2196 | |
---|
2197 | Â Â Â Â |
---|
2198 | Â Â Â Â # Phase / General tab |
---|
2199 | Â Â Â Â self.DataGeneral =Â wx.MenuBar() |
---|
2200 | Â Â Â Â self.PrefillDataMenu(self.DataGeneral) |
---|
2201 | Â Â Â Â self.DataGeneral.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2202 | Â Â Â Â self.GeneralCalc =Â wx.Menu(title='') |
---|
2203 | Â Â Â Â self.DataGeneral.Append(menu=self.GeneralCalc,title='Compute') |
---|
2204 |     self.GeneralCalc.Append(help='Compute Fourier map',id=wxID_FOURCALC, kind=wx.ITEM_NORMAL, |
---|
2205 | Â Â Â Â Â Â text='Fourier map') |
---|
2206 |     self.GeneralCalc.Append(help='Search Fourier map',id=wxID_FOURSEARCH, kind=wx.ITEM_NORMAL, |
---|
2207 | Â Â Â Â Â Â text='Search map') |
---|
2208 |     self.GeneralCalc.Append(help='Run charge flipping',id=wxID_CHARGEFLIP, kind=wx.ITEM_NORMAL, |
---|
2209 | Â Â Â Â Â Â text='Charge flipping') |
---|
2210 |     self.GeneralCalc.Append(help='Run 4D charge flipping',id=wxID_4DCHARGEFLIP, kind=wx.ITEM_NORMAL, |
---|
2211 | Â Â Â Â Â Â text='4D Charge flipping') |
---|
2212 | Â Â Â Â self.GeneralCalc.Enable(wxID_4DCHARGEFLIP,False)Â Â |
---|
2213 |     self.GeneralCalc.Append(help='Clear map',id=wxID_FOURCLEAR, kind=wx.ITEM_NORMAL, |
---|
2214 | Â Â Â Â Â Â text='Clear map') |
---|
2215 |     self.GeneralCalc.Append(help='Run Monte Carlo - Simulated Annealing',id=wxID_SINGLEMCSA, kind=wx.ITEM_NORMAL, |
---|
2216 | Â Â Â Â Â Â text='MC/SA') |
---|
2217 |     self.GeneralCalc.Append(help='Run Monte Carlo - Simulated Annealing on multiprocessors',id=wxID_MULTIMCSA, kind=wx.ITEM_NORMAL, |
---|
2218 | Â Â Â Â Â Â text='Multi MC/SA')Â Â Â Â Â Â #currently not useful |
---|
2219 |     self.GeneralCalc.Append(help='Transform crystal structure',id=wxID_TRANSFORMSTRUCTURE, kind=wx.ITEM_NORMAL, |
---|
2220 | Â Â Â Â Â Â text='Transform') |
---|
2221 | Â Â Â Â self.PostfillDataMenu() |
---|
2222 | Â Â Â Â |
---|
2223 | Â Â Â Â # Phase / Data tab |
---|
2224 | Â Â Â Â self.DataMenu =Â wx.MenuBar() |
---|
2225 | Â Â Â Â self.PrefillDataMenu(self.DataMenu) |
---|
2226 | Â Â Â Â self.DataMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2227 | Â Â Â Â self.DataEdit =Â wx.Menu(title='') |
---|
2228 |     self.DataMenu.Append(menu=self.DataEdit, title='Edit Phase') |
---|
2229 |     self.DataEdit.Append(id=wxID_DATACOPY, kind=wx.ITEM_NORMAL,text='Copy data', |
---|
2230 | Â Â Â Â Â Â help='Copy phase data to other histograms') |
---|
2231 |     self.DataEdit.Append(id=wxID_DATACOPYFLAGS, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
2232 | Â Â Â Â Â Â help='Copy phase data flags to other histograms') |
---|
2233 |     self.DataEdit.Append(id=wxID_DATASELCOPY, kind=wx.ITEM_NORMAL,text='Copy selected data', |
---|
2234 | Â Â Â Â Â Â help='Copy selected phase data to other histograms') |
---|
2235 |     self.DataEdit.Append(id=wxID_DATAUSE, kind=wx.ITEM_NORMAL,text='Select used data', |
---|
2236 | Â Â Â Â Â Â help='Select all histograms to use') |
---|
2237 |     self.DataEdit.Append(id=wxID_PWDRADD, kind=wx.ITEM_NORMAL,text='Add powder histograms', |
---|
2238 | Â Â Â Â Â Â help='Select new powder histograms to be used for this phase') |
---|
2239 |     self.DataEdit.Append(id=wxID_HKLFADD, kind=wx.ITEM_NORMAL,text='Add single crystal histograms', |
---|
2240 | Â Â Â Â Â Â help='Select new single crystal histograms to be used for this phase') |
---|
2241 |     self.DataEdit.Append(id=wxID_DATADELETE, kind=wx.ITEM_NORMAL,text='Remove histograms', |
---|
2242 | Â Â Â Â Â Â help='Remove histograms from use for this phase') |
---|
2243 | Â Â Â Â self.PostfillDataMenu() |
---|
2244 | Â Â Â Â Â Â |
---|
2245 | Â Â Â Â # Phase / Atoms tab |
---|
2246 | Â Â Â Â self.AtomsMenu =Â wx.MenuBar() |
---|
2247 | Â Â Â Â self.PrefillDataMenu(self.AtomsMenu) |
---|
2248 | Â Â Â Â self.AtomsMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2249 | Â Â Â Â self.AtomEdit =Â wx.Menu(title='') |
---|
2250 | Â Â Â Â self.AtomCompute =Â wx.Menu(title='') |
---|
2251 |     self.AtomsMenu.Append(menu=self.AtomEdit, title='Edit Atoms') |
---|
2252 |     self.AtomsMenu.Append(menu=self.AtomCompute, title='Compute') |
---|
2253 | Â Â Â Â submenu =Â wx.Menu() |
---|
2254 |     self.AtomEdit.AppendMenu(wx.ID_ANY, 'On selected atoms...', submenu, |
---|
2255 | Â Â Â Â Â Â help='Set/Act on selected atoms') |
---|
2256 | Â Â Â Â submenu.Append(wxID_ATOMSSETSEL, |
---|
2257 | Â Â Â Â Â Â help='Set refinement flags for selected atoms', |
---|
2258 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
2259 | Â Â Â Â Â Â text='Refine selected') |
---|
2260 |     submenu.Append(id=wxID_ATOMSMODIFY, kind=wx.ITEM_NORMAL,text='Modify parameters', |
---|
2261 | Â Â Â Â Â Â help='Modify parameters values for all selected atoms') |
---|
2262 |     submenu.Append(id=wxID_ATOMSEDITINSERT, kind=wx.ITEM_NORMAL,text='Insert atom', |
---|
2263 | Â Â Â Â Â Â help='Inserts an H atom before all selected atoms') |
---|
2264 |     submenu.Append(id=wxID_ADDHATOM, kind=wx.ITEM_NORMAL,text='Calc H atoms', |
---|
2265 | Â Â Â Â Â Â help='Insert H atoms in expected bonding positions for selected atoms') |
---|
2266 |     submenu.Append(id=wxID_ATOMSEDITDELETE, kind=wx.ITEM_NORMAL,text='Delete atom', |
---|
2267 | Â Â Â Â Â Â help='Delete selected atoms') |
---|
2268 |     submenu.Append(id=wxID_ATOMSTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform atoms', |
---|
2269 | Â Â Â Â Â Â help='Symmetry transform selected atoms') |
---|
2270 | #Â Â Â Â self.AtomEdit.Append(id=wxID_ATOMSROTATE, kind=wx.ITEM_NORMAL,text='Rotate atoms', |
---|
2271 | #Â Â Â Â Â Â help='Select atoms to rotate first') |
---|
2272 | Â Â Â Â submenu.Append(wxID_ATOMSSETALL, |
---|
2273 | Â Â Â Â Â Â help='Set refinement flags for all atoms', |
---|
2274 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
2275 | Â Â Â Â Â Â text='Select All') |
---|
2276 | Â Â Â Â |
---|
2277 |     self.AtomEdit.Append(id=wxID_ATOMSEDITADD, kind=wx.ITEM_NORMAL,text='Append atom', |
---|
2278 | Â Â Â Â Â Â help='Appended as an H atom') |
---|
2279 |     self.AtomEdit.Append(id=wxID_ATOMSVIEWADD, kind=wx.ITEM_NORMAL,text='Append view point', |
---|
2280 | Â Â Â Â Â Â help='Appended as an H atom') |
---|
2281 |     self.AtomEdit.Append(id=wxID_ATOMVIEWINSERT, kind=wx.ITEM_NORMAL,text='Insert view point', |
---|
2282 | Â Â Â Â Â Â help='Select atom row to insert before; inserted as an H atom') |
---|
2283 |     self.AtomEdit.Append(id=wxID_UPDATEHATOM, kind=wx.ITEM_NORMAL,text='Update H atoms', |
---|
2284 | Â Â Â Â Â Â help='Update H atoms in standard positions') |
---|
2285 |     self.AtomEdit.Append(id=wxID_ATOMMOVE, kind=wx.ITEM_NORMAL,text='Move selected atom to view point', |
---|
2286 | Â Â Â Â Â Â help='Select a single atom to be moved to view point in plot') |
---|
2287 |     self.AtomEdit.Append(id=wxID_MAKEMOLECULE, kind=wx.ITEM_NORMAL,text='Assemble molecule', |
---|
2288 | Â Â Â Â Â Â help='Select a single atom to assemble as a molecule from scattered atom positions') |
---|
2289 |     self.AtomEdit.Append(id=wxID_RELOADDRAWATOMS, kind=wx.ITEM_NORMAL,text='Reload draw atoms', |
---|
2290 | Â Â Â Â Â Â help='Reload atom drawing list') |
---|
2291 | Â Â Â Â submenu =Â wx.Menu() |
---|
2292 |     self.AtomEdit.AppendMenu(wx.ID_ANY, 'Reimport atoms', submenu, |
---|
2293 | Â Â Â Â Â Â help='Reimport atoms from file; sequence must match') |
---|
2294 | Â Â Â Â # setup a cascade menu for the formats that have been defined |
---|
2295 | Â Â Â Â self.ReImportMenuId =Â {}Â # points to readers for each menu entry |
---|
2296 |     for reader in self.G2frame.ImportPhaseReaderlist: |
---|
2297 | Â Â Â Â Â Â item =Â submenu.Append( |
---|
2298 | Â Â Â Â Â Â Â Â wx.ID_ANY,help=reader.longFormatName, |
---|
2299 | Â Â Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='reimport coordinates from '+reader.formatName+' file') |
---|
2300 | Â Â Â Â Â Â self.ReImportMenuId[item.GetId()]Â =Â reader |
---|
2301 | Â Â Â Â item =Â submenu.Append( |
---|
2302 | Â Â Â Â Â Â wx.ID_ANY, |
---|
2303 | Â Â Â Â Â Â help='Reimport coordinates, try to determine format from file', |
---|
2304 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
2305 | Â Â Â Â Â Â text='guess format from file') |
---|
2306 |     self.ReImportMenuId[item.GetId()] = None # try all readers |
---|
2307 | |
---|
2308 |     self.AtomCompute.Append(id=wxID_ATOMSDISAGL, kind=wx.ITEM_NORMAL,text='Show Distances && Angles', |
---|
2309 | Â Â Â Â Â Â help='Compute distances & angles for selected atoms') |
---|
2310 |     self.AtomCompute.Append(id=wxID_ATOMSPDISAGL, kind=wx.ITEM_NORMAL,text='Save Distances && Angles', |
---|
2311 | Â Â Â Â Â Â help='Compute distances & angles for selected atoms') |
---|
2312 | Â Â Â Â self.AtomCompute.ISOcalc =Â self.AtomCompute.Append( |
---|
2313 |       id=wxID_ISODISP, kind=wx.ITEM_NORMAL, |
---|
2314 | Â Â Â Â Â Â text='ISODISTORT mode values', |
---|
2315 | Â Â Â Â Â Â help='Compute values of ISODISTORT modes from atom parameters') |
---|
2316 |     self.AtomCompute.Append(id=wxID_ATOMSDENSITY, kind=wx.ITEM_NORMAL, |
---|
2317 | Â Â Â Â Â Â text='Density', |
---|
2318 | Â Â Â Â Â Â help='Compute density for current phase') |
---|
2319 | Â Â Â Â self.PostfillDataMenu() |
---|
2320 | Â Â Â Â |
---|
2321 | Â Â Â Â # Phase / Imcommensurate "waves" tab |
---|
2322 | Â Â Â Â self.WavesData =Â wx.MenuBar() |
---|
2323 | Â Â Â Â self.PrefillDataMenu(self.WavesData) |
---|
2324 | Â Â Â Â self.WavesData.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2325 | Â Â Â Â self.WavesDataEdit =Â wx.Menu(title='') |
---|
2326 |     self.WavesData.Append(menu=self.WavesDataEdit, title='Edit Wave') |
---|
2327 |     self.WavesDataEdit.Append(id=wxID_WAVEVARY, kind=wx.ITEM_NORMAL,text='Global wave vary', |
---|
2328 | Â Â Â Â Â Â help='Global setting of wave vary flags') |
---|
2329 | Â Â Â Â self.PostfillDataMenu() |
---|
2330 | Â Â Â Â |
---|
2331 | Â Â Â Â # Phase / Layer tab |
---|
2332 | Â Â Â Â self.LayerData =Â wx.MenuBar() |
---|
2333 | Â Â Â Â self.PrefillDataMenu(self.LayerData) |
---|
2334 | Â Â Â Â self.LayerData.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2335 | Â Â Â Â self.LayerDataEdit =Â wx.Menu(title='') |
---|
2336 |     self.LayerData.Append(menu=self.LayerDataEdit, title='Operations') |
---|
2337 |     self.LayerDataEdit.Append(id=wxID_LOADDIFFAX, kind=wx.ITEM_NORMAL,text='Load from DIFFaX file', |
---|
2338 | Â Â Â Â Â Â help='Load layer info from DIFFaX file') |
---|
2339 |     self.LayerDataEdit.Append(id=wxID_COPYPHASE, kind=wx.ITEM_NORMAL,text='Copy phase cell', |
---|
2340 | Â Â Â Â Â Â help='Copy phase cell from another project') |
---|
2341 |     self.LayerDataEdit.Append(id=wxID_LAYERSIMULATE, kind=wx.ITEM_NORMAL,text='Simulate pattern', |
---|
2342 | Â Â Â Â Â Â help='Simulate diffraction pattern from layer stacking') |
---|
2343 |     self.LayerDataEdit.Append(id=wxID_LAYERSFIT, kind=wx.ITEM_NORMAL,text='Fit pattern', |
---|
2344 | Â Â Â Â Â Â help='Fit diffraction pattern with layer stacking model') |
---|
2345 |     self.LayerDataEdit.Append(id=wxID_SEQUENCESIMULATE, kind=wx.ITEM_NORMAL,text='Sequence simulations', |
---|
2346 | Â Â Â Â Â Â help='Sequence simulation changing one parameter') |
---|
2347 | Â Â Â Â self.PostfillDataMenu() |
---|
2348 | Â Â Â Â Â Â Â Â Â |
---|
2349 | Â Â Â Â # Phase / Draw Options tab |
---|
2350 | Â Â Â Â self.DataDrawOptions =Â wx.MenuBar() |
---|
2351 | Â Â Â Â self.PrefillDataMenu(self.DataDrawOptions) |
---|
2352 | Â Â Â Â self.DataDrawOptions.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2353 | Â Â Â Â self.PostfillDataMenu() |
---|
2354 | Â Â Â Â |
---|
2355 | Â Â Â Â # Phase / Draw Atoms tab |
---|
2356 | Â Â Â Â self.DrawAtomsMenu =Â wx.MenuBar() |
---|
2357 | Â Â Â Â self.PrefillDataMenu(self.DrawAtomsMenu) |
---|
2358 | Â Â Â Â self.DrawAtomsMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2359 | Â Â Â Â self.DrawAtomEdit =Â wx.Menu(title='') |
---|
2360 | Â Â Â Â self.DrawAtomCompute =Â wx.Menu(title='') |
---|
2361 | Â Â Â Â self.DrawAtomRestraint =Â wx.Menu(title='') |
---|
2362 | Â Â Â Â self.DrawAtomRigidBody =Â wx.Menu(title='') |
---|
2363 |     self.DrawAtomsMenu.Append(menu=self.DrawAtomEdit, title='Edit Figure') |
---|
2364 | Â Â Â Â self.DrawAtomsMenu.Append(menu=self.DrawAtomCompute,title='Compute') |
---|
2365 |     self.DrawAtomsMenu.Append(menu=self.DrawAtomRestraint, title='Restraints') |
---|
2366 |     self.DrawAtomsMenu.Append(menu=self.DrawAtomRigidBody, title='Rigid body') |
---|
2367 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMSTYLE, kind=wx.ITEM_NORMAL,text='Atom style', |
---|
2368 | Â Â Â Â Â Â help='Select atoms first') |
---|
2369 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMLABEL, kind=wx.ITEM_NORMAL,text='Atom label', |
---|
2370 | Â Â Â Â Â Â help='Select atoms first') |
---|
2371 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMCOLOR, kind=wx.ITEM_NORMAL,text='Atom color', |
---|
2372 | Â Â Â Â Â Â help='Select atoms first') |
---|
2373 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMRESETCOLOR, kind=wx.ITEM_NORMAL,text='Reset atom colors', |
---|
2374 | Â Â Â Â Â Â help='Resets all atom colors to defaults') |
---|
2375 |     self.DrawAtomEdit.Append(id=wxID_DRWAEDITRADII, kind=wx.ITEM_NORMAL,text='Edit atom radii', |
---|
2376 | Â Â Â Â Â Â help='Edit drawing atom radii') |
---|
2377 |     self.DrawAtomEdit.Append(id=wxID_DRAWVIEWPOINT, kind=wx.ITEM_NORMAL,text='View point', |
---|
2378 | Â Â Â Â Â Â help='View point is 1st atom selected') |
---|
2379 |     self.DrawAtomEdit.Append(id=wxID_DRAWADDEQUIV, kind=wx.ITEM_NORMAL,text='Add atoms', |
---|
2380 | Â Â Â Â Â Â help='Add symmetry & cell equivalents to drawing set from selected atoms') |
---|
2381 |     self.DrawAtomEdit.Append(id=wxID_DRAWADDSPHERE, kind=wx.ITEM_NORMAL,text='Add sphere of atoms', |
---|
2382 | Â Â Â Â Â Â help='Add atoms within sphere of enclosure') |
---|
2383 |     self.DrawAtomEdit.Append(id=wxID_DRAWTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform draw atoms', |
---|
2384 | Â Â Â Â Â Â help='Transform selected atoms by symmetry & cell translations') |
---|
2385 |     self.DrawAtomEdit.Append(id=wxID_DRAWFILLCOORD, kind=wx.ITEM_NORMAL,text='Fill CN-sphere', |
---|
2386 | Â Â Â Â Â Â help='Fill coordination sphere for selected atoms')Â Â Â Â Â Â |
---|
2387 |     self.DrawAtomEdit.Append(id=wxID_DRAWFILLCELL, kind=wx.ITEM_NORMAL,text='Fill unit cell', |
---|
2388 | Â Â Â Â Â Â help='Fill unit cell with selected atoms') |
---|
2389 |     self.DrawAtomEdit.Append(id=wxID_DRAWDELETE, kind=wx.ITEM_NORMAL,text='Delete atoms', |
---|
2390 | Â Â Â Â Â Â help='Delete atoms from drawing set') |
---|
2391 |     self.DrawAtomCompute.Append(id=wxID_DRAWDISTVP, kind=wx.ITEM_NORMAL,text='View pt. dist.', |
---|
2392 | Â Â Â Â Â Â help='Compute distance of selected atoms from view point')Â Â |
---|
2393 |     self.DrawAtomCompute.Append(id=wxID_DRAWDISAGLTOR, kind=wx.ITEM_NORMAL,text='Dist. Ang. Tors.', |
---|
2394 | Â Â Â Â Â Â help='Compute distance, angle or torsion for 2-4 selected atoms')Â Â |
---|
2395 |     self.DrawAtomCompute.Append(id=wxID_DRAWPLANE, kind=wx.ITEM_NORMAL,text='Best plane', |
---|
2396 | Â Â Â Â Â Â help='Compute best plane for 4+ selected atoms')Â Â |
---|
2397 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRBOND, kind=wx.ITEM_NORMAL,text='Add bond restraint', |
---|
2398 | Â Â Â Â Â Â help='Add bond restraint for selected atoms (2)') |
---|
2399 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRANGLE, kind=wx.ITEM_NORMAL,text='Add angle restraint', |
---|
2400 | Â Â Â Â Â Â help='Add angle restraint for selected atoms (3: one end 1st)') |
---|
2401 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRPLANE, kind=wx.ITEM_NORMAL,text='Add plane restraint', |
---|
2402 | Â Â Â Â Â Â help='Add plane restraint for selected atoms (4+)') |
---|
2403 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRCHIRAL, kind=wx.ITEM_NORMAL,text='Add chiral restraint', |
---|
2404 | Â Â Â Â Â Â help='Add chiral restraint for selected atoms (4: center atom 1st)') |
---|
2405 |     self.DrawAtomRigidBody.Append(id=wxID_DRAWDEFINERB, kind=wx.ITEM_NORMAL,text='Define rigid body', |
---|
2406 | Â Â Â Â Â Â help='Define rigid body with selected atoms') |
---|
2407 | Â Â Â Â self.PostfillDataMenu() |
---|
2408 | |
---|
2409 | Â Â Â Â # Phase / MCSA tab |
---|
2410 | Â Â Â Â self.MCSAMenu =Â wx.MenuBar() |
---|
2411 | Â Â Â Â self.PrefillDataMenu(self.MCSAMenu) |
---|
2412 | Â Â Â Â self.MCSAMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2413 | Â Â Â Â self.MCSAEdit =Â wx.Menu(title='') |
---|
2414 |     self.MCSAMenu.Append(menu=self.MCSAEdit, title='MC/SA') |
---|
2415 |     self.MCSAEdit.Append(id=wxID_ADDMCSAATOM, kind=wx.ITEM_NORMAL,text='Add atom', |
---|
2416 | Â Â Â Â Â Â help='Add single atom to MC/SA model') |
---|
2417 |     self.MCSAEdit.Append(id=wxID_ADDMCSARB, kind=wx.ITEM_NORMAL,text='Add rigid body', |
---|
2418 | Â Â Â Â Â Â help='Add rigid body to MC/SA model'Â ) |
---|
2419 |     self.MCSAEdit.Append(id=wxID_CLEARMCSARB, kind=wx.ITEM_NORMAL,text='Clear rigid bodies', |
---|
2420 | Â Â Â Â Â Â help='Clear all atoms & rigid bodies from MC/SA model'Â ) |
---|
2421 |     self.MCSAEdit.Append(id=wxID_MOVEMCSA, kind=wx.ITEM_NORMAL,text='Move MC/SA solution', |
---|
2422 | Â Â Â Â Â Â help='Move MC/SA solution to atom list'Â ) |
---|
2423 |     self.MCSAEdit.Append(id=wxID_MCSACLEARRESULTS, kind=wx.ITEM_NORMAL,text='Clear results', |
---|
2424 | Â Â Â Â Â Â help='Clear table of MC/SA results'Â ) |
---|
2425 | Â Â Â Â self.PostfillDataMenu() |
---|
2426 | Â Â Â Â Â Â |
---|
2427 | Â Â Â Â # Phase / Texture tab |
---|
2428 | Â Â Â Â self.TextureMenu =Â wx.MenuBar() |
---|
2429 | Â Â Â Â self.PrefillDataMenu(self.TextureMenu) |
---|
2430 | Â Â Â Â self.TextureMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2431 | Â Â Â Â self.TextureEdit =Â wx.Menu(title='') |
---|
2432 |     self.TextureMenu.Append(menu=self.TextureEdit, title='Texture') |
---|
2433 |     self.TextureEdit.Append(id=wxID_REFINETEXTURE, kind=wx.ITEM_NORMAL,text='Refine texture', |
---|
2434 | Â Â Â Â Â Â help='Refine the texture coefficients from sequential results') |
---|
2435 | #Â Â Â Â self.TextureEdit.Append(id=wxID_CLEARTEXTURE, kind=wx.ITEM_NORMAL,text='Clear texture', |
---|
2436 | #Â Â Â Â Â Â help='Clear the texture coefficients' ) |
---|
2437 | Â Â Â Â self.PostfillDataMenu() |
---|
2438 | Â Â Â Â Â Â |
---|
2439 | Â Â Â Â # Phase / Pawley tab |
---|
2440 | Â Â Â Â self.PawleyMenu =Â wx.MenuBar() |
---|
2441 | Â Â Â Â self.PrefillDataMenu(self.PawleyMenu) |
---|
2442 | Â Â Â Â self.PawleyMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2443 | Â Â Â Â self.PawleyEdit =Â wx.Menu(title='') |
---|
2444 | Â Â Â Â self.PawleyMenu.Append(menu=self.PawleyEdit,title='Operations') |
---|
2445 |     self.PawleyEdit.Append(id=wxID_PAWLEYSET, kind=wx.ITEM_NORMAL,text='Pawley settings', |
---|
2446 | Â Â Â Â Â Â help='Change Pawley refinement settings') |
---|
2447 |     self.PawleyEdit.Append(id=wxID_PAWLEYLOAD, kind=wx.ITEM_NORMAL,text='Pawley create', |
---|
2448 | Â Â Â Â Â Â help='Initialize Pawley reflection list') |
---|
2449 |     self.PawleyEdit.Append(id=wxID_PAWLEYESTIMATE, kind=wx.ITEM_NORMAL,text='Pawley estimate', |
---|
2450 | Â Â Â Â Â Â help='Estimate initial Pawley intensities') |
---|
2451 |     self.PawleyEdit.Append(id=wxID_PAWLEYUPDATE, kind=wx.ITEM_NORMAL,text='Pawley update', |
---|
2452 | Â Â Â Â Â Â help='Update negative Pawley intensities with -0.5*Fobs and turn off refinement') |
---|
2453 |     self.PawleyEdit.Append(id=wxID_PAWLEYSELALL, kind=wx.ITEM_NORMAL,text='Select all', |
---|
2454 | Â Â Â Â Â Â help='Select all reflections to be refined') |
---|
2455 |     self.PawleyEdit.Append(id=wxID_PAWLEYSELNONE, kind=wx.ITEM_NORMAL,text='Select none', |
---|
2456 | Â Â Â Â Â Â help='Set flag for all reflections for no refinement') |
---|
2457 |     self.PawleyEdit.Append(id=wxID_PAWLEYSELTOGGLE, kind=wx.ITEM_NORMAL,text='Toggle Selection', |
---|
2458 | Â Â Â Â Â Â help='Toggle Selection flag for all reflections to opposite setting') |
---|
2459 | Â Â Â Â self.PostfillDataMenu() |
---|
2460 | Â Â Â Â Â Â |
---|
2461 | Â Â Â Â # Phase / Map peaks tab |
---|
2462 | Â Â Â Â self.MapPeaksMenu =Â wx.MenuBar() |
---|
2463 | Â Â Â Â self.PrefillDataMenu(self.MapPeaksMenu) |
---|
2464 | Â Â Â Â self.MapPeaksMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2465 | Â Â Â Â self.MapPeaksEdit =Â wx.Menu(title='') |
---|
2466 |     self.MapPeaksMenu.Append(menu=self.MapPeaksEdit, title='Map peaks') |
---|
2467 |     self.MapPeaksEdit.Append(id=wxID_PEAKSMOVE, kind=wx.ITEM_NORMAL,text='Move peaks', |
---|
2468 | Â Â Â Â Â Â help='Move selected peaks to atom list') |
---|
2469 |     self.MapPeaksEdit.Append(id=wxID_PEAKSVIEWPT, kind=wx.ITEM_NORMAL,text='View point', |
---|
2470 | Â Â Â Â Â Â help='View point is 1st peak selected') |
---|
2471 |     self.MapPeaksEdit.Append(id=wxID_PEAKSDISTVP, kind=wx.ITEM_NORMAL,text='View pt. dist.', |
---|
2472 | Â Â Â Â Â Â help='Compute distance of selected peaks from view point')Â Â |
---|
2473 |     self.MapPeaksEdit.Append(id=wxID_SHOWBONDS, kind=wx.ITEM_NORMAL,text='Hide bonds', |
---|
2474 | Â Â Â Â Â Â help='Hide or show bonds between peak positions')Â Â |
---|
2475 |     self.MapPeaksEdit.Append(id=wxID_PEAKSDA, kind=wx.ITEM_NORMAL,text='Calc dist/ang', |
---|
2476 | Â Â Â Â Â Â help='Calculate distance or angle for selection') |
---|
2477 |     self.MapPeaksEdit.Append(id=wxID_FINDEQVPEAKS, kind=wx.ITEM_NORMAL,text='Equivalent peaks', |
---|
2478 | Â Â Â Â Â Â help='Find equivalent peaks') |
---|
2479 |     self.MapPeaksEdit.Append(id=wxID_PEAKSUNIQUE, kind=wx.ITEM_NORMAL,text='Unique peaks', |
---|
2480 | Â Â Â Â Â Â help='Select unique set') |
---|
2481 |     self.MapPeaksEdit.Append(id=wxID_PEAKSDELETE, kind=wx.ITEM_NORMAL,text='Delete peaks', |
---|
2482 | Â Â Â Â Â Â help='Delete selected peaks') |
---|
2483 |     self.MapPeaksEdit.Append(id=wxID_PEAKSCLEAR, kind=wx.ITEM_NORMAL,text='Clear peaks', |
---|
2484 | Â Â Â Â Â Â help='Clear the map peak list') |
---|
2485 | Â Â Â Â self.PostfillDataMenu() |
---|
2486 | |
---|
2487 | Â Â Â Â # Phase / Rigid bodies tab |
---|
2488 | Â Â Â Â self.RigidBodiesMenu =Â wx.MenuBar() |
---|
2489 | Â Â Â Â self.PrefillDataMenu(self.RigidBodiesMenu) |
---|
2490 | Â Â Â Â self.RigidBodiesMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2491 | Â Â Â Â self.RigidBodiesEdit =Â wx.Menu(title='') |
---|
2492 |     self.RigidBodiesMenu.Append(menu=self.RigidBodiesEdit, title='Edit Body') |
---|
2493 |     self.RigidBodiesEdit.Append(id=wxID_ASSIGNATMS2RB, kind=wx.ITEM_NORMAL,text='Assign atoms to rigid body', |
---|
2494 | Â Â Â Â Â Â help='Select & position rigid body in structure of existing atoms') |
---|
2495 |     self.RigidBodiesEdit.Append(id=wxID_AUTOFINDRESRB, kind=wx.ITEM_NORMAL,text='Auto find residues', |
---|
2496 | Â Â Â Â Â Â help='Auto find of residue RBs in macromolecule') |
---|
2497 |     self.RigidBodiesEdit.Append(id=wxID_COPYRBPARMS, kind=wx.ITEM_NORMAL,text='Copy rigid body parms', |
---|
2498 | Â Â Â Â Â Â help='Copy rigid body location & TLS parameters') |
---|
2499 |     self.RigidBodiesEdit.Append(id=wxID_GLOBALTHERM, kind=wx.ITEM_NORMAL,text='Global thermal motion', |
---|
2500 | Â Â Â Â Â Â help='Global setting of residue thermal motion models') |
---|
2501 |     self.RigidBodiesEdit.Append(id=wxID_GLOBALRESREFINE, kind=wx.ITEM_NORMAL,text='Global residue refine', |
---|
2502 | Â Â Â Â Â Â help='Global setting of residue RB refinement flags') |
---|
2503 |     self.RigidBodiesEdit.Append(id=wxID_RBREMOVEALL, kind=wx.ITEM_NORMAL,text='Remove all rigid bodies', |
---|
2504 | Â Â Â Â Â Â help='Remove all rigid body assignment for atoms') |
---|
2505 | Â Â Â Â self.PostfillDataMenu() |
---|
2506 | Â Â # end of GSAS-II menu definitions |
---|
2507 | Â Â Â Â |
---|
2508 |   def _init_ctrls(self, parent,name=None,size=None,pos=None): |
---|
2509 | Â Â Â Â wx.Frame.__init__( |
---|
2510 | Â Â Â Â Â Â self,parent=parent, |
---|
2511 | Â Â Â Â Â Â #style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX | wx.FRAME_FLOAT_ON_PARENT , |
---|
2512 | Â Â Â Â Â Â style=wx.DEFAULT_FRAME_STYLE ^Â wx.CLOSE_BOX, |
---|
2513 | Â Â Â Â Â Â size=size,pos=pos,title='GSAS-II data display') |
---|
2514 | Â Â Â Â self._init_menus() |
---|
2515 |     if name: |
---|
2516 | Â Â Â Â Â Â self.SetLabel(name) |
---|
2517 | Â Â Â Â self.Show() |
---|
2518 | Â Â Â Â |
---|
2519 |   def __init__(self,parent,frame,data=None,name=None, size=None,pos=None): |
---|
2520 | Â Â Â Â self.G2frame =Â frame |
---|
2521 | Â Â Â Â self._init_ctrls(parent,name,size,pos) |
---|
2522 | Â Â Â Â self.data =Â data |
---|
2523 | Â Â Â Â clientSize =Â wx.ClientDisplayRect() |
---|
2524 | Â Â Â Â Size =Â self.GetSize() |
---|
2525 | Â Â Â Â xPos =Â clientSize[2]-Size[0] |
---|
2526 | Â Â Â Â self.SetPosition(wx.Point(xPos,clientSize[1]+250)) |
---|
2527 | Â Â Â Â self.AtomGrid =Â [] |
---|
2528 | Â Â Â Â self.selectedRow =Â 0 |
---|
2529 |     self.lastSize = Size    |
---|
2530 | Â Â Â Â self.manualPhaseSize =Â None |
---|
2531 | Â Â Â Â self.userReSize =Â False |
---|
2532 | Â Â Â Â wx.Frame.Bind(self,wx.EVT_SIZE,self.OnReSize) |
---|
2533 | Â Â Â Â Â Â |
---|
2534 |   def OnReSize(self,event): |
---|
2535 | Â Â Â Â '''Keep track of size changes for Phase windows |
---|
2536 | Â Â Â Â ''' |
---|
2537 |     id = self.G2frame.PatternTree.GetSelection() |
---|
2538 | Â Â Â Â try: |
---|
2539 | Â Â Â Â Â Â parent =Â self.G2frame.PatternTree.GetItemParent(id) |
---|
2540 | Â Â Â Â except:Â Â Â Â Â #avoid bad tree item on start via gpx file selection |
---|
2541 | Â Â Â Â Â Â parent =Â 0 |
---|
2542 |     if self.userReSize and parent and self.G2frame.PatternTree.GetItemText(parent) == "Phases": |
---|
2543 |       if self.lastSize == event.EventObject.GetSize(): |
---|
2544 | #Â Â Â Â Â Â Â Â if GSASIIpath.GetConfigValue('debug'): |
---|
2545 | #Â Â Â Â Â Â Â Â Â Â print 'no save size=',self.lastSize |
---|
2546 | Â Â Â Â Â Â Â Â return |
---|
2547 | Â Â Â Â Â Â self.manualPhaseSize =Â event.EventObject.GetSize() |
---|
2548 | Â Â Â Â Â Â self.lastSize =Â event.EventObject.GetSize() |
---|
2549 | #Â Â Â Â Â Â if GSASIIpath.GetConfigValue('debug'): |
---|
2550 | #Â Â Â Â Â Â Â Â print 'Saving Phase size=',self.manualPhaseSize |
---|
2551 | Â Â Â Â Â Â Â Â #HowDidIgetHere() |
---|
2552 | Â Â Â Â event.Skip() |
---|
2553 | |
---|
2554 |   def SendSizeEvent(self): |
---|
2555 | Â Â Â Â '''Prevent SendSizeEvent from overriding the saved size |
---|
2556 | Â Â Â Â ''' |
---|
2557 | Â Â Â Â self.userReSize =Â False |
---|
2558 | Â Â Â Â wx.Frame.SendSizeEvent(self) |
---|
2559 | Â Â Â Â self.userReSize =Â True |
---|
2560 | Â Â Â Â |
---|
2561 |   def setSizePosLeft(self,Size): |
---|
2562 | Â Â Â Â '''Place the dataFrame window so that the upper left-hand corner remains in the same place; |
---|
2563 | Â Â Â Â The size is dictated by parameter Width, unless overridden by a previous Phase window resize |
---|
2564 | Â Â Â Â ''' |
---|
2565 | Â Â Â Â self.userReSize =Â False |
---|
2566 | Â Â Â Â Size =Â list(Size) |
---|
2567 |     id = self.G2frame.PatternTree.GetSelection() |
---|
2568 | Â Â Â Â try:Â Â Â Â Â Â #avoid bad tree item on start via gpx file selection |
---|
2569 | Â Â Â Â Â Â pid =Â self.G2frame.PatternTree.GetItemParent(id) |
---|
2570 | Â Â Â Â except: |
---|
2571 | Â Â Â Â Â Â pid =Â 0 |
---|
2572 |     if pid: |
---|
2573 | Â Â Â Â Â Â parent =Â self.G2frame.PatternTree.GetItemText(pid) |
---|
2574 | Â Â Â Â Â Â # is this a phase window and has a previous window has been resized? |
---|
2575 |       if self.manualPhaseSize and parent == "Phases": |
---|
2576 | Â Â Â Â Â Â Â Â Size =Â list(self.manualPhaseSize) |
---|
2577 | Â Â Â Â Pos =Â self.GetPosition() |
---|
2578 | Â Â Â Â clientSize =Â wx.ClientDisplayRect()Â Â Â #display window size (e.g. 1304x768) |
---|
2579 | Â Â Â Â Size[1]Â =Â min(Size[1],clientSize[2]-300) |
---|
2580 | Â Â Â Â Size[0]Â =Â max(Size[0],300) |
---|
2581 | #Â Â Â Â print 'current position/width:',Pos,Width |
---|
2582 | Â Â Â Â self.SetSize(Size) |
---|
2583 | Â Â Â Â Size[1]Â +=Â 1Â Â Â Â #kluge to ensure scrollbar settings & window properly displayed |
---|
2584 | Â Â Â Â self.SetSize(Size) |
---|
2585 | Â Â Â Â Pos[0]Â +=Â self.lastSize[0]-Size[0] |
---|
2586 | Â Â Â Â offSet =Â 0 |
---|
2587 |     if Pos[0] < clientSize[2]: |
---|
2588 | Â Â Â Â Â Â offSet =Â Pos[0]+Size[0]-clientSize[2] |
---|
2589 |     if offSet > 0: |
---|
2590 | Â Â Â Â Â Â Pos[0]Â -=Â offSet |
---|
2591 | Â Â Â Â self.SetPosition(wx.Point(Pos[0],Pos[1])) |
---|
2592 | Â Â Â Â self.lastSize =Â Size |
---|
2593 | Â Â Â Â self.userReSize =Â True |
---|
2594 | Â Â Â Â |
---|
2595 |   def Clear(self): |
---|
2596 | Â Â Â Â self.ClearBackground() |
---|
2597 | Â Â Â Â self.DestroyChildren() |
---|
2598 | Â Â Â Â Â Â Â Â Â Â |
---|
2599 | |
---|
2600 | ################################################################################ |
---|
2601 | #####Â Notebook Tree Item editor |
---|
2602 | ################################################################################Â Â Â Â Â Â Â Â Â |
---|
2603 | def UpdateNotebook(G2frame,data): |
---|
2604 | Â Â '''Called when the data tree notebook entry is selected. Allows for |
---|
2605 | Â Â editing of the text in that tree entry |
---|
2606 | Â Â ''' |
---|
2607 |   def OnNoteBook(event): |
---|
2608 | Â Â Â Â event.Skip() |
---|
2609 | Â Â Â Â data =Â G2frame.dataDisplay.GetValue().split('\n') |
---|
2610 | Â Â Â Â G2frame.PatternTree.SetItemPyData(GetPatternTreeItemId(G2frame,G2frame.root,'Notebook'),data) |
---|
2611 |     if 'nt' not in os.name: |
---|
2612 | Â Â Â Â Â Â G2frame.dataDisplay.AppendText('\n') |
---|
2613 | Â Â Â Â Â Â Â Â Â Â |
---|
2614 |   if G2frame.dataDisplay: |
---|
2615 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
2616 | Â Â G2frame.dataFrame.SetLabel('Notebook') |
---|
2617 | Â Â G2frame.dataDisplay =Â wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(), |
---|
2618 | Â Â Â Â style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER |Â wx.TE_DONTWRAP) |
---|
2619 | Â Â G2frame.dataDisplay.Bind(wx.EVT_TEXT_ENTER,OnNoteBook) |
---|
2620 | Â Â G2frame.dataDisplay.Bind(wx.EVT_KILL_FOCUS,OnNoteBook) |
---|
2621 |   for line in data: |
---|
2622 | Â Â Â Â G2frame.dataDisplay.AppendText(line+"\n") |
---|
2623 | Â Â G2frame.dataDisplay.AppendText('Notebook entry @ '+time.ctime()+"\n") |
---|
2624 | Â Â G2frame.dataFrame.setSizePosLeft([400,250]) |
---|
2625 | Â Â Â Â Â Â |
---|
2626 | ################################################################################ |
---|
2627 | #####Â Controls Tree Item editor |
---|
2628 | ################################################################################Â Â Â Â Â Â |
---|
2629 | def UpdateControls(G2frame,data): |
---|
2630 | Â Â '''Edit overall GSAS-II controls in main Controls data tree entry |
---|
2631 | Â Â ''' |
---|
2632 | Â Â #patch |
---|
2633 |   if 'deriv type' not in data: |
---|
2634 | Â Â Â Â data =Â {} |
---|
2635 | Â Â Â Â data['deriv type']Â =Â 'analytic Hessian' |
---|
2636 | Â Â Â Â data['min dM/M']Â =Â 0.0001 |
---|
2637 | Â Â Â Â data['shift factor']Â =Â 1. |
---|
2638 | Â Â Â Â data['max cyc']Â =Â 3Â Â Â Â |
---|
2639 | Â Â Â Â data['F**2']Â =Â False |
---|
2640 |   if 'shift factor' not in data: |
---|
2641 | Â Â Â Â data['shift factor']Â =Â 1. |
---|
2642 |   if 'max cyc' not in data: |
---|
2643 | Â Â Â Â data['max cyc']Â =Â 3 |
---|
2644 |   if 'F**2' not in data: |
---|
2645 | Â Â Â Â data['F**2']Â =Â False |
---|
2646 |   if 'Author' not in data: |
---|
2647 | Â Â Â Â data['Author']Â =Â 'no name' |
---|
2648 |   if 'FreePrm1' not in data: |
---|
2649 | Â Â Â Â data['FreePrm1']Â =Â 'Sample humidity (%)' |
---|
2650 |   if 'FreePrm2' not in data: |
---|
2651 | Â Â Â Â data['FreePrm2']Â =Â 'Sample voltage (V)' |
---|
2652 |   if 'FreePrm3' not in data: |
---|
2653 | Â Â Â Â data['FreePrm3']Â =Â 'Applied load (MN)' |
---|
2654 |   if 'Copy2Next' not in data: |
---|
2655 | Â Â Â Â data['Copy2Next']Â =Â False |
---|
2656 |   if 'Reverse Seq' not in data: |
---|
2657 | Â Â Â Â data['Reverse Seq']Â =Â False |
---|
2658 |   if 'UsrReject' not in data: |
---|
2659 | Â Â Â Â data['UsrReject']Â =Â {'minF/sig':0,'MinExt':0.01,'MaxDF/F':20.,'MaxD':500.,'MinD':0.05} |
---|
2660 |   if 'HatomFix' not in data: |
---|
2661 | Â Â Â Â data['HatomFix']Â =Â False |
---|
2662 |   if 'Marquardt' not in data: |
---|
2663 | Â Â Â Â data['Marquardt']Â =Â -3 |
---|
2664 | Â Â |
---|
2665 | Â Â #end patch |
---|
2666 | |
---|
2667 |   def SeqSizer(): |
---|
2668 | Â Â Â Â |
---|
2669 |     def OnSelectData(event): |
---|
2670 | Â Â Â Â Â Â choices =Â GetPatternTreeDataNames(G2frame,['PWDR','HKLF',]) |
---|
2671 | Â Â Â Â Â Â sel =Â [] |
---|
2672 | Â Â Â Â Â Â try: |
---|
2673 |         if 'Seq Data' in data: |
---|
2674 |           for item in data['Seq Data']: |
---|
2675 | Â Â Â Â Â Â Â Â Â Â Â Â sel.append(choices.index(item)) |
---|
2676 |           sel = [choices.index(item) for item in data['Seq Data']] |
---|
2677 |       except ValueError: #data changed somehow - start fresh |
---|
2678 | Â Â Â Â Â Â Â Â sel =Â [] |
---|
2679 |       dlg = G2G.G2MultiChoiceDialog(G2frame.dataFrame, 'Sequential refinement', |
---|
2680 | Â Â Â Â Â Â Â Â 'Select dataset to include',choices) |
---|
2681 | Â Â Â Â Â Â dlg.SetSelections(sel) |
---|
2682 | Â Â Â Â Â Â names =Â [] |
---|
2683 |       if dlg.ShowModal() == wx.ID_OK: |
---|
2684 |         for sel in dlg.GetSelections(): |
---|
2685 | Â Â Â Â Â Â Â Â Â Â names.append(choices[sel]) |
---|
2686 |         data['Seq Data'] = names        |
---|
2687 | Â Â Â Â Â Â Â Â G2frame.EnableSeqRefineMenu() |
---|
2688 | Â Â Â Â Â Â dlg.Destroy() |
---|
2689 | Â Â Â Â Â Â wx.CallAfter(UpdateControls,G2frame,data) |
---|
2690 | Â Â Â Â Â Â |
---|
2691 |     def OnReverse(event): |
---|
2692 | Â Â Â Â Â Â data['Reverse Seq']Â =Â reverseSel.GetValue() |
---|
2693 | Â Â Â Â Â Â |
---|
2694 |     def OnCopySel(event): |
---|
2695 | Â Â Â Â Â Â data['Copy2Next']Â =Â copySel.GetValue()Â |
---|
2696 | Â Â Â Â Â Â Â Â Â Â |
---|
2697 | Â Â Â Â seqSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
2698 | Â Â Â Â dataSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2699 | Â Â Â Â dataSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Sequential Refinement: '),0,WACV) |
---|
2700 | Â Â Â Â selSeqData =Â wx.Button(G2frame.dataDisplay,-1,label=' Select data') |
---|
2701 | Â Â Â Â selSeqData.Bind(wx.EVT_BUTTON,OnSelectData) |
---|
2702 | Â Â Â Â dataSizer.Add(selSeqData,0,WACV) |
---|
2703 | Â Â Â Â SeqData =Â data.get('Seq Data',[]) |
---|
2704 |     if not SeqData: |
---|
2705 | Â Â Â Â Â Â lbl =Â ' (no data selected)' |
---|
2706 | Â Â Â Â else: |
---|
2707 | Â Â Â Â Â Â lbl =Â ' ('+str(len(SeqData))+' dataset(s) selected)' |
---|
2708 | |
---|
2709 | Â Â Â Â dataSizer.Add(wx.StaticText(G2frame.dataDisplay,label=lbl),0,WACV) |
---|
2710 | Â Â Â Â seqSizer.Add(dataSizer,0) |
---|
2711 |     if SeqData: |
---|
2712 | Â Â Â Â Â Â selSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2713 | Â Â Â Â Â Â reverseSel =Â wx.CheckBox(G2frame.dataDisplay,-1,label=' Reverse order?') |
---|
2714 | Â Â Â Â Â Â reverseSel.Bind(wx.EVT_CHECKBOX,OnReverse) |
---|
2715 | Â Â Â Â Â Â reverseSel.SetValue(data['Reverse Seq']) |
---|
2716 | Â Â Â Â Â Â selSizer.Add(reverseSel,0,WACV) |
---|
2717 | Â Â Â Â Â Â copySel =Â wx.CheckBox(G2frame.dataDisplay,-1,label=' Copy results to next histogram?') |
---|
2718 | Â Â Â Â Â Â copySel.Bind(wx.EVT_CHECKBOX,OnCopySel) |
---|
2719 | Â Â Â Â Â Â copySel.SetValue(data['Copy2Next']) |
---|
2720 | Â Â Â Â Â Â selSizer.Add(copySel,0,WACV) |
---|
2721 | Â Â Â Â Â Â seqSizer.Add(selSizer,0) |
---|
2722 |     return seqSizer |
---|
2723 | Â Â Â Â |
---|
2724 |   def LSSizer():    |
---|
2725 | Â Â Â Â |
---|
2726 |     def OnDerivType(event): |
---|
2727 | Â Â Â Â Â Â data['deriv type']Â =Â derivSel.GetValue() |
---|
2728 | Â Â Â Â Â Â derivSel.SetValue(data['deriv type']) |
---|
2729 | Â Â Â Â Â Â wx.CallAfter(UpdateControls,G2frame,data) |
---|
2730 | Â Â Â Â Â Â |
---|
2731 |     def OnConvergence(event): |
---|
2732 | Â Â Â Â Â Â event.Skip() |
---|
2733 | Â Â Â Â Â Â try: |
---|
2734 | Â Â Â Â Â Â Â Â value =Â max(1.e-9,min(1.0,float(Cnvrg.GetValue()))) |
---|
2735 |       except ValueError: |
---|
2736 | Â Â Â Â Â Â Â Â value =Â 0.0001 |
---|
2737 | Â Â Â Â Â Â data['min dM/M']Â =Â value |
---|
2738 | Â Â Â Â Â Â Cnvrg.SetValue('%.2g'%(value)) |
---|
2739 | Â Â Â Â Â Â |
---|
2740 |     def OnMaxCycles(event): |
---|
2741 | Â Â Â Â Â Â data['max cyc']Â =Â int(maxCyc.GetValue()) |
---|
2742 | Â Â Â Â Â Â maxCyc.SetValue(str(data['max cyc'])) |
---|
2743 | Â Â Â Â Â Â |
---|
2744 |     def OnMarqLam(event): |
---|
2745 | Â Â Â Â Â Â data['Marquardt']Â =Â int(marqLam.GetValue()) |
---|
2746 | Â Â Â Â Â Â marqLam.SetValue(str(data['Marquardt'])) |
---|
2747 | Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2748 |     def OnFactor(event): |
---|
2749 | Â Â Â Â Â Â event.Skip() |
---|
2750 | Â Â Â Â Â Â try: |
---|
2751 | Â Â Â Â Â Â Â Â value =Â min(max(float(Factr.GetValue()),0.00001),100.) |
---|
2752 |       except ValueError: |
---|
2753 | Â Â Â Â Â Â Â Â value =Â 1.0 |
---|
2754 | Â Â Â Â Â Â data['shift factor']Â =Â value |
---|
2755 | Â Â Â Â Â Â Factr.SetValue('%.5f'%(value)) |
---|
2756 | Â Â Â Â Â Â |
---|
2757 |     def OnFsqRef(event): |
---|
2758 | Â Â Â Â Â Â data['F**2']Â =Â fsqRef.GetValue() |
---|
2759 | Â Â Â Â Â Â |
---|
2760 | #Â Â Â Â def OnHatomFix(event): |
---|
2761 | #Â Â Â Â Â Â data['HatomFix'] = Hfix.GetValue() |
---|
2762 | Â Â Â Â |
---|
2763 |     def OnUsrRej(event): |
---|
2764 | Â Â Â Â Â Â event.Skip() |
---|
2765 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
2766 | Â Â Â Â Â Â item,limits =Â Indx[Obj] |
---|
2767 | Â Â Â Â Â Â try: |
---|
2768 | Â Â Â Â Â Â Â Â value =Â min(max(float(Obj.GetValue()),limits[0]),limits[1]) |
---|
2769 |       except ValueError: |
---|
2770 | Â Â Â Â Â Â Â Â value =Â data['UsrReject'][item] |
---|
2771 | Â Â Â Â Â Â data['UsrReject'][item]Â =Â value |
---|
2772 | Â Â Â Â Â Â Obj.SetValue('%.2f'%(value)) |
---|
2773 | |
---|
2774 | Â Â Â Â LSSizer =Â wx.FlexGridSizer(cols=4,vgap=5,hgap=5) |
---|
2775 | Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Refinement derivatives: '),0,WACV) |
---|
2776 | Â Â Â Â Choice=['analytic Jacobian','numeric','analytic Hessian'] |
---|
2777 | Â Â Â Â derivSel =Â wx.ComboBox(parent=G2frame.dataDisplay,value=data['deriv type'],choices=Choice, |
---|
2778 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2779 | Â Â Â Â derivSel.SetValue(data['deriv type']) |
---|
2780 |     derivSel.Bind(wx.EVT_COMBOBOX, OnDerivType) |
---|
2781 | Â Â Â Â Â Â |
---|
2782 | Â Â Â Â LSSizer.Add(derivSel,0,WACV) |
---|
2783 | Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Min delta-M/M: '),0,WACV) |
---|
2784 | Â Â Â Â Cnvrg =Â wx.TextCtrl(G2frame.dataDisplay,-1,value='%.2g'%(data['min dM/M']),style=wx.TE_PROCESS_ENTER) |
---|
2785 | Â Â Â Â Cnvrg.Bind(wx.EVT_TEXT_ENTER,OnConvergence) |
---|
2786 | Â Â Â Â Cnvrg.Bind(wx.EVT_KILL_FOCUS,OnConvergence) |
---|
2787 | Â Â Â Â LSSizer.Add(Cnvrg,0,WACV) |
---|
2788 | Â Â Â Â Indx =Â {} |
---|
2789 |     if 'Hessian' in data['deriv type']: |
---|
2790 | Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Max cycles: '),0,WACV) |
---|
2791 | Â Â Â Â Â Â Choice =Â ['0','1','2','3','5','10','15','20'] |
---|
2792 | Â Â Â Â Â Â maxCyc =Â wx.ComboBox(parent=G2frame.dataDisplay,value=str(data['max cyc']),choices=Choice, |
---|
2793 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2794 | #Â Â Â Â Â Â maxCyc.SetValue(str(data['max cyc'])) |
---|
2795 |       maxCyc.Bind(wx.EVT_COMBOBOX, OnMaxCycles) |
---|
2796 | Â Â Â Â Â Â LSSizer.Add(maxCyc,0,WACV) |
---|
2797 | Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Initial lambda = 10**'),0,WACV) |
---|
2798 | Â Â Â Â Â Â MarqChoice =Â ['-3','-2','-1','0','1','2','3','4'] |
---|
2799 | Â Â Â Â Â Â marqLam =Â wx.ComboBox(parent=G2frame.dataDisplay,value=str(data['Marquardt']),choices=MarqChoice, |
---|
2800 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
2801 | Â Â Â Â Â Â marqLam.Bind(wx.EVT_COMBOBOX,OnMarqLam) |
---|
2802 | Â Â Â Â Â Â LSSizer.Add(marqLam,0,WACV) |
---|
2803 | Â Â Â Â else: |
---|
2804 | Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Initial shift factor: '),0,WACV) |
---|
2805 | Â Â Â Â Â Â Factr =Â wx.TextCtrl(G2frame.dataDisplay,-1,value='%.5f'%(data['shift factor']),style=wx.TE_PROCESS_ENTER) |
---|
2806 | Â Â Â Â Â Â Factr.Bind(wx.EVT_TEXT_ENTER,OnFactor) |
---|
2807 | Â Â Â Â Â Â Factr.Bind(wx.EVT_KILL_FOCUS,OnFactor) |
---|
2808 | Â Â Â Â Â Â LSSizer.Add(Factr,0,WACV) |
---|
2809 |     if G2frame.Sngl: |
---|
2810 | Â Â Â Â Â Â userReject =Â data['UsrReject'] |
---|
2811 |       usrRej = {'minF/sig':[' Min obs/sig (0-5): ',[0,5], ],'MinExt':[' Min extinct. (0-.9): ',[0,.9],], |
---|
2812 | Â Â Â Â Â Â Â Â 'MaxDF/F':[' Max delt-F/sig (3-1000): ',[3.,1000.],],'MaxD':[' Max d-spacing (3-500): ',[3,500],], |
---|
2813 | Â Â Â Â Â Â Â Â 'MinD':[' Min d-spacing (0.1-2.0): ',[0.1,2.0],]} |
---|
2814 | |
---|
2815 | Â Â Â Â Â Â fsqRef =Â wx.CheckBox(G2frame.dataDisplay,-1,label='Refine HKLF as F^2? ') |
---|
2816 | Â Â Â Â Â Â fsqRef.SetValue(data['F**2']) |
---|
2817 | Â Â Â Â Â Â fsqRef.Bind(wx.EVT_CHECKBOX,OnFsqRef) |
---|
2818 | Â Â Â Â Â Â LSSizer.Add(fsqRef,0,WACV) |
---|
2819 | Â Â Â Â Â Â LSSizer.Add((1,0),) |
---|
2820 |       for item in usrRej: |
---|
2821 | Â Â Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,label=usrRej[item][0]),0,WACV) |
---|
2822 | Â Â Â Â Â Â Â Â usrrej =Â wx.TextCtrl(G2frame.dataDisplay,-1,value='%.2f'%(userReject[item]),style=wx.TE_PROCESS_ENTER) |
---|
2823 | Â Â Â Â Â Â Â Â Indx[usrrej]Â =Â [item,usrRej[item][1]] |
---|
2824 | Â Â Â Â Â Â Â Â usrrej.Bind(wx.EVT_TEXT_ENTER,OnUsrRej) |
---|
2825 | Â Â Â Â Â Â Â Â usrrej.Bind(wx.EVT_KILL_FOCUS,OnUsrRej) |
---|
2826 | Â Â Â Â Â Â Â Â LSSizer.Add(usrrej,0,WACV) |
---|
2827 | #Â Â Â Â Hfix = wx.CheckBox(G2frame.dataDisplay,-1,label='Regularize H atoms? ') |
---|
2828 | #Â Â Â Â Hfix.SetValue(data['HatomFix']) |
---|
2829 | #Â Â Â Â Hfix.Bind(wx.EVT_CHECKBOX,OnHatomFix) |
---|
2830 | #Â Â Â Â LSSizer.Add(Hfix,0,WACV)Â Â #for now |
---|
2831 |     return LSSizer |
---|
2832 | Â Â Â Â |
---|
2833 |   def AuthSizer(): |
---|
2834 | |
---|
2835 |     def OnAuthor(event): |
---|
2836 | Â Â Â Â Â Â event.Skip() |
---|
2837 | Â Â Â Â Â Â data['Author']Â =Â auth.GetValue() |
---|
2838 | |
---|
2839 | Â Â Â Â Author =Â data['Author'] |
---|
2840 | Â Â Â Â authSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
2841 | Â Â Â Â authSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' CIF Author (last, first):'),0,WACV) |
---|
2842 | Â Â Â Â auth =Â wx.TextCtrl(G2frame.dataDisplay,-1,value=Author,style=wx.TE_PROCESS_ENTER) |
---|
2843 | Â Â Â Â auth.Bind(wx.EVT_TEXT_ENTER,OnAuthor) |
---|
2844 | Â Â Â Â auth.Bind(wx.EVT_KILL_FOCUS,OnAuthor) |
---|
2845 | Â Â Â Â authSizer.Add(auth,0,WACV) |
---|
2846 |     return authSizer |
---|
2847 | Â Â Â Â |
---|
2848 | Â Â Â Â |
---|
2849 |   if G2frame.dataDisplay: |
---|
2850 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
2851 |   if not G2frame.dataFrame.GetStatusBar(): |
---|
2852 | Â Â Â Â Status =Â G2frame.dataFrame.CreateStatusBar() |
---|
2853 | Â Â Â Â Status.SetStatusText('') |
---|
2854 | Â Â G2frame.dataFrame.SetLabel('Controls') |
---|
2855 | Â Â G2frame.dataDisplay =Â wx.Panel(G2frame.dataFrame) |
---|
2856 | Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.ControlsMenu) |
---|
2857 | Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
2858 | Â Â mainSizer.Add((5,5),0) |
---|
2859 | Â Â mainSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Refinement Controls:'),0,WACV)Â Â |
---|
2860 | Â Â mainSizer.Add(LSSizer()) |
---|
2861 | Â Â mainSizer.Add((5,5),0) |
---|
2862 | Â Â mainSizer.Add(SeqSizer()) |
---|
2863 | Â Â mainSizer.Add((5,5),0) |
---|
2864 | Â Â mainSizer.Add(AuthSizer()) |
---|
2865 | Â Â mainSizer.Add((5,5),0) |
---|
2866 | Â Â Â Â |
---|
2867 | Â Â mainSizer.Layout()Â Â |
---|
2868 | Â Â G2frame.dataDisplay.SetSizer(mainSizer) |
---|
2869 | Â Â G2frame.dataFrame.setSizePosLeft(mainSizer.Fit(G2frame.dataFrame)) |
---|
2870 | Â Â Â |
---|
2871 | ################################################################################ |
---|
2872 | #####Â Comments |
---|
2873 | ################################################################################Â Â Â Â Â Â |
---|
2874 | Â Â Â Â |
---|
2875 | def UpdateComments(G2frame,data):          |
---|
2876 | |
---|
2877 |   if G2frame.dataDisplay: |
---|
2878 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
2879 | Â Â G2frame.dataFrame.SetLabel('Comments') |
---|
2880 | Â Â G2frame.dataDisplay =Â wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(), |
---|
2881 | Â Â Â Â style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP) |
---|
2882 |   for line in data: |
---|
2883 |     if '\n' not in line: |
---|
2884 | Â Â Â Â Â Â G2frame.dataDisplay.AppendText(line+'\n') |
---|
2885 | Â Â Â Â else: |
---|
2886 | Â Â Â Â Â Â G2frame.dataDisplay.AppendText(line) |
---|
2887 | Â Â G2frame.dataFrame.setSizePosLeft([400,250]) |
---|
2888 | Â Â Â Â Â Â |
---|
2889 | ################################################################################ |
---|
2890 | #####Â Display of Sequential Results |
---|
2891 | ################################################################################Â Â Â Â Â Â |
---|
2892 | Â Â Â Â |
---|
2893 | def UpdateSeqResults(G2frame,data,prevSize=None): |
---|
2894 | Â Â """ |
---|
2895 | Â Â Called when the Sequential Results data tree entry is selected |
---|
2896 | Â Â to show results from a sequential refinement. |
---|
2897 | Â Â |
---|
2898 | Â Â :param wx.Frame G2frame: main GSAS-II data tree windows |
---|
2899 | |
---|
2900 | Â Â :param dict data: a dictionary containing the following items:Â |
---|
2901 | |
---|
2902 | Â Â Â Â Â Â * 'histNames' - list of histogram names in order as processed by Sequential Refinement |
---|
2903 | Â Â Â Â Â Â * 'varyList' - list of variables - identical over all refinements in sequence |
---|
2904 | Â Â Â Â Â Â Â note that this is the original list of variables, prior to processing |
---|
2905 | Â Â Â Â Â Â Â constraints. |
---|
2906 | Â Â Â Â Â Â * 'variableLabels' -- a dict of labels to be applied to each parameter |
---|
2907 | Â Â Â Â Â Â Â (this is created as an empty dict if not present in data). |
---|
2908 | Â Â Â Â Â Â * keyed by histName - dictionaries for all data sets processed, which contains: |
---|
2909 | |
---|
2910 | Â Â Â Â Â Â Â * 'variables'- result[0] from leastsq call |
---|
2911 | Â Â Â Â Â Â Â * 'varyList' - list of variables passed to leastsq call (not same as above) |
---|
2912 | Â Â Â Â Â Â Â * 'sig' - esds for variables |
---|
2913 | Â Â Â Â Â Â Â * 'covMatrix' - covariance matrix from individual refinement |
---|
2914 | Â Â Â Â Â Â Â * 'title' - histogram name; same as dict item name |
---|
2915 | Â Â Â Â Â Â Â * 'newAtomDict' - new atom parameters after shifts applied |
---|
2916 | Â Â Â Â Â Â Â * 'newCellDict' - refined cell parameters after shifts to A0-A5 from Dij terms applied' |
---|
2917 | Â Â """ |
---|
2918 | |
---|
2919 |   def GetSampleParms(): |
---|
2920 | Â Â Â Â '''Make a dictionary of the sample parameters are not the same over the |
---|
2921 | Â Â Â Â refinement series. |
---|
2922 | Â Â Â Â ''' |
---|
2923 |     if 'IMG' in histNames[0]: |
---|
2924 | Â Â Â Â Â Â sampleParmDict =Â {'Sample load':[],} |
---|
2925 | Â Â Â Â else: |
---|
2926 | Â Â Â Â Â Â sampleParmDict =Â {'Temperature':[],'Pressure':[],'Time':[], |
---|
2927 | Â Â Â Â Â Â Â Â 'FreePrm1':[],'FreePrm2':[],'FreePrm3':[],'Omega':[], |
---|
2928 | Â Â Â Â Â Â Â Â 'Chi':[],'Phi':[],'Azimuth':[],} |
---|
2929 | Â Â Â Â Controls =Â G2frame.PatternTree.GetItemPyData( |
---|
2930 |       GetPatternTreeItemId(G2frame,G2frame.root, 'Controls')) |
---|
2931 | Â Â Â Â sampleParm =Â {} |
---|
2932 |     for name in histNames: |
---|
2933 |       if 'IMG' in name: |
---|
2934 |         for item in sampleParmDict: |
---|
2935 | Â Â Â Â Â Â Â Â Â Â sampleParmDict[item].append(data[name]['parmDict'].get(item,0)) |
---|
2936 | Â Â Â Â Â Â else: |
---|
2937 | Â Â Â Â Â Â Â Â Id =Â GetPatternTreeItemId(G2frame,G2frame.root,name) |
---|
2938 | Â Â Â Â Â Â Â Â sampleData =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,Id,'Sample Parameters')) |
---|
2939 |         for item in sampleParmDict: |
---|
2940 | Â Â Â Â Â Â Â Â Â Â sampleParmDict[item].append(sampleData.get(item,0)) |
---|
2941 |     for item in sampleParmDict: |
---|
2942 | Â Â Â Â Â Â frstValue =Â sampleParmDict[item][0] |
---|
2943 |       if np.any(np.array(sampleParmDict[item])-frstValue): |
---|
2944 |         if item.startswith('FreePrm'): |
---|
2945 | Â Â Â Â Â Â Â Â Â Â sampleParm[Controls[item]]Â =Â sampleParmDict[item] |
---|
2946 | Â Â Â Â Â Â Â Â else: |
---|
2947 | Â Â Â Â Â Â Â Â Â Â sampleParm[item]Â =Â sampleParmDict[item] |
---|
2948 |     return sampleParm |
---|
2949 | |
---|
2950 |   def GetColumnInfo(col): |
---|
2951 | Â Â Â Â '''returns column label, lists of values and errors (or None) for each column in the table |
---|
2952 | Â Â Â Â for plotting. The column label is reformatted from Unicode to MatPlotLib encoding |
---|
2953 | Â Â Â Â ''' |
---|
2954 | Â Â Â Â colName =Â G2frame.SeqTable.GetColLabelValue(col) |
---|
2955 | Â Â Â Â plotName =Â variableLabels.get(colName,colName) |
---|
2956 | Â Â Â Â plotName =Â plotSpCharFix(plotName) |
---|
2957 |     return plotName,colList[col],colSigs[col] |
---|
2958 | Â Â Â Â Â Â |
---|
2959 |   def PlotSelect(event): |
---|
2960 | Â Â Â Â 'Plots a row (covariance) or column on double-click' |
---|
2961 | Â Â Â Â cols =Â G2frame.dataDisplay.GetSelectedCols() |
---|
2962 | Â Â Â Â rows =Â G2frame.dataDisplay.GetSelectedRows() |
---|
2963 |     if cols: |
---|
2964 | Â Â Â Â Â Â G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) |
---|
2965 |     elif rows: |
---|
2966 | Â Â Â Â Â Â name =Â histNames[rows[0]]Â Â Â Â #only does 1st one selected |
---|
2967 | Â Â Â Â Â Â G2plt.PlotCovariance(G2frame,data[name]) |
---|
2968 | Â Â Â Â else: |
---|
2969 | Â Â Â Â Â Â G2frame.ErrorDialog( |
---|
2970 | Â Â Â Â Â Â Â Â 'Select row or columns', |
---|
2971 | Â Â Â Â Â Â Â Â 'Nothing selected in table. Click on column or row label(s) to plot. N.B. Grid selection can be a bit funky.' |
---|
2972 | Â Â Â Â Â Â Â Â ) |
---|
2973 | Â Â Â Â Â Â |
---|
2974 |   def OnPlotSelSeq(event): |
---|
2975 | Â Â Â Â 'plot the selected columns or row from menu command' |
---|
2976 | Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
2977 | Â Â Â Â rows =Â G2frame.dataDisplay.GetSelectedRows() |
---|
2978 |     if cols: |
---|
2979 | Â Â Â Â Â Â G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) |
---|
2980 |     elif rows: |
---|
2981 | Â Â Â Â Â Â name =Â histNames[rows[0]]Â Â Â Â #only does 1st one selected |
---|
2982 | Â Â Â Â Â Â G2plt.PlotCovariance(G2frame,data[name]) |
---|
2983 | Â Â Â Â else: |
---|
2984 | Â Â Â Â Â Â G2frame.ErrorDialog( |
---|
2985 | Â Â Â Â Â Â Â Â 'Select columns', |
---|
2986 | Â Â Â Â Â Â Â Â 'No columns or rows selected in table. Click on row or column labels to select fields for plotting.' |
---|
2987 | Â Â Â Â Â Â Â Â ) |
---|
2988 | Â Â Â Â Â Â Â Â |
---|
2989 |   def OnAveSelSeq(event): |
---|
2990 | Â Â Â Â 'average the selected columns from menu command' |
---|
2991 | Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
2992 |     if cols: |
---|
2993 |       for col in cols: |
---|
2994 | Â Â Â Â Â Â Â Â ave =Â np.mean(GetColumnInfo(col)[1]) |
---|
2995 | Â Â Â Â Â Â Â Â sig =Â np.std(GetColumnInfo(col)[1]) |
---|
2996 |         print ' Average for '+G2frame.SeqTable.GetColLabelValue(col)+': '+'%.6g'%(ave)+' +/- '+'%.6g'%(sig) |
---|
2997 | Â Â Â Â else: |
---|
2998 | Â Â Â Â Â Â G2frame.ErrorDialog( |
---|
2999 | Â Â Â Â Â Â Â Â 'Select columns', |
---|
3000 | Â Â Â Â Â Â Â Â 'No columns selected in table. Click on column labels to select fields for averaging.' |
---|
3001 | Â Â Â Â Â Â Â Â ) |
---|
3002 | Â Â Â Â Â Â Â Â |
---|
3003 |   def OnRenameSelSeq(event): |
---|
3004 | Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
3005 |     colNames = [G2frame.SeqTable.GetColLabelValue(c) for c in cols] |
---|
3006 | Â Â Â Â newNames =Â colNames[:] |
---|
3007 |     for i,name in enumerate(colNames): |
---|
3008 |       if name in variableLabels: |
---|
3009 | Â Â Â Â Â Â Â Â newNames[i]Â =Â variableLabels[name] |
---|
3010 |     if not cols: |
---|
3011 | Â Â Â Â Â Â G2frame.ErrorDialog('Select columns', |
---|
3012 | Â Â Â Â Â Â Â Â 'No columns selected in table. Click on column labels to select fields for rename.') |
---|
3013 | Â Â Â Â Â Â return |
---|
3014 | Â Â Â Â dlg =Â G2G.MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames) |
---|
3015 |     if dlg.Show(): |
---|
3016 | Â Â Â Â Â Â newNames =Â dlg.GetValues()Â Â Â Â Â Â |
---|
3017 | Â Â Â Â Â Â variableLabels.update(dict(zip(colNames,newNames))) |
---|
3018 | Â Â Â Â data['variableLabels']Â =Â variableLabels |
---|
3019 | Â Â Â Â dlg.Destroy() |
---|
3020 | Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3021 | Â Â Â Â G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) |
---|
3022 | Â Â Â Â Â Â |
---|
3023 |   def OnReOrgSelSeq(event): |
---|
3024 | Â Â Â Â 'Reorder the columns' |
---|
3025 | Â Â Â Â G2G.GetItemOrder(G2frame,VaryListChanges,vallookup,posdict)Â Â |
---|
3026 | Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3027 | |
---|
3028 |   def OnSaveSelSeqCSV(event): |
---|
3029 | Â Â Â Â 'export the selected columns to a .csv file from menu command' |
---|
3030 | Â Â Â Â OnSaveSelSeq(event,csv=True) |
---|
3031 | Â Â Â Â |
---|
3032 |   def OnSaveSeqCSV(event): |
---|
3033 | Â Â Â Â 'export all columns to a .csv file from menu command' |
---|
3034 | Â Â Â Â OnSaveSelSeq(event,csv=True,allcols=True) |
---|
3035 | Â Â Â Â |
---|
3036 |   def OnSaveSelSeq(event,csv=False,allcols=False): |
---|
3037 | Â Â Â Â 'export the selected columns to a .txt or .csv file from menu command' |
---|
3038 |     def WriteCSV(): |
---|
3039 |       def WriteList(headerItems): |
---|
3040 | Â Â Â Â Â Â Â Â line =Â '' |
---|
3041 |         for lbl in headerItems: |
---|
3042 |           if line: line += ',' |
---|
3043 | Â Â Â Â Â Â Â Â Â Â line +=Â '"'+lbl+'"' |
---|
3044 |         return line |
---|
3045 | Â Â Â Â Â Â head =Â ['name'] |
---|
3046 |       for col in cols: |
---|
3047 | Â Â Â Â Â Â Â Â item =Â G2frame.SeqTable.GetColLabelValue(col) |
---|
3048 | Â Â Â Â Â Â Â Â # get rid of labels that have Unicode characters |
---|
3049 |         if not all([ord(c) < 128 and ord(c) != 0 for c in item]): item = '?' |
---|
3050 |         if col in havesig: |
---|
3051 | Â Â Â Â Â Â Â Â Â Â head +=Â [item,'esd-'+item] |
---|
3052 | Â Â Â Â Â Â Â Â else: |
---|
3053 | Â Â Â Â Â Â Â Â Â Â head +=Â [item] |
---|
3054 | Â Â Â Â Â Â SeqFile.write(WriteList(head)+'\n') |
---|
3055 |       for row,name in enumerate(saveNames): |
---|
3056 | Â Â Â Â Â Â Â Â line =Â '"'+saveNames[row]+'"' |
---|
3057 |         for col in cols: |
---|
3058 |           if col in havesig: |
---|
3059 | Â Â Â Â Â Â Â Â Â Â Â Â line +=Â ','+str(saveData[col][row])+','+str(saveSigs[col][row]) |
---|
3060 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3061 | Â Â Â Â Â Â Â Â Â Â Â Â line +=Â ','+str(saveData[col][row]) |
---|
3062 | Â Â Â Â Â Â Â Â SeqFile.write(line+'\n') |
---|
3063 |     def WriteSeq(): |
---|
3064 | Â Â Â Â Â Â lenName =Â len(saveNames[0]) |
---|
3065 |       line = ' %s '%('name'.center(lenName)) |
---|
3066 |       for col in cols: |
---|
3067 | Â Â Â Â Â Â Â Â item =Â G2frame.SeqTable.GetColLabelValue(col) |
---|
3068 |         if col in havesig: |
---|
3069 |           line += ' %12s %12s '%(item.center(12),'esd'.center(12)) |
---|
3070 | Â Â Â Â Â Â Â Â else: |
---|
3071 |           line += ' %12s '%(item.center(12)) |
---|
3072 | Â Â Â Â Â Â SeqFile.write(line+'\n') |
---|
3073 |       for row,name in enumerate(saveNames): |
---|
3074 | Â Â Â Â Â Â Â Â line =Â " '%s' "%(saveNames[row]) |
---|
3075 |         for col in cols: |
---|
3076 |           if col in havesig: |
---|
3077 |             line += ' %12.6f %12.6f '%(saveData[col][row],saveSigs[col][row]) |
---|
3078 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3079 |             line += ' %12.6f '%saveData[col][row] |
---|
3080 | Â Â Â Â Â Â Â Â SeqFile.write(line+'\n') |
---|
3081 | |
---|
3082 | Â Â Â Â # start of OnSaveSelSeq code |
---|
3083 |     if allcols: |
---|
3084 | Â Â Â Â Â Â cols =Â range(G2frame.SeqTable.GetNumberCols()) |
---|
3085 | Â Â Â Â else: |
---|
3086 | Â Â Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
3087 | Â Â Â Â nrows =Â G2frame.SeqTable.GetNumberRows() |
---|
3088 |     if not cols: |
---|
3089 | Â Â Â Â Â Â G2frame.ErrorDialog('Select columns', |
---|
3090 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'No columns selected in table. Click on column labels to select fields for output.') |
---|
3091 | Â Â Â Â Â Â return |
---|
3092 |     saveNames = [G2frame.SeqTable.GetRowLabelValue(r) for r in range(nrows)] |
---|
3093 | Â Â Â Â saveData =Â {} |
---|
3094 | Â Â Â Â saveSigs =Â {} |
---|
3095 | Â Â Â Â havesig =Â [] |
---|
3096 |     for col in cols: |
---|
3097 | Â Â Â Â Â Â name,vals,sigs =Â GetColumnInfo(col) |
---|
3098 | Â Â Â Â Â Â saveData[col]Â =Â vals |
---|
3099 |       if sigs: |
---|
3100 | Â Â Â Â Â Â Â Â havesig.append(col) |
---|
3101 | Â Â Â Â Â Â Â Â saveSigs[col]Â =Â sigs |
---|
3102 |     if csv: |
---|
3103 | Â Â Â Â Â Â wild =Â 'CSV output file (*.csv)|*.csv' |
---|
3104 | Â Â Â Â else: |
---|
3105 | Â Â Â Â Â Â wild =Â 'Text output file (*.txt)|*.txt' |
---|
3106 | Â Â Â Â pth =Â G2G.GetExportPath(G2frame) |
---|
3107 | Â Â Â Â dlg =Â wx.FileDialog( |
---|
3108 | Â Â Â Â Â Â G2frame, |
---|
3109 |       'Choose text output file for your selection', pth, '', |
---|
3110 | Â Â Â Â Â Â wild,wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) |
---|
3111 | Â Â Â Â try: |
---|
3112 |       if dlg.ShowModal() == wx.ID_OK: |
---|
3113 | Â Â Â Â Â Â Â Â SeqTextFile =Â dlg.GetPath() |
---|
3114 | Â Â Â Â Â Â Â Â SeqTextFile =Â G2IO.FileDlgFixExt(dlg,SeqTextFile)Â |
---|
3115 | Â Â Â Â Â Â Â Â SeqFile =Â open(SeqTextFile,'w') |
---|
3116 |         if csv: |
---|
3117 | Â Â Â Â Â Â Â Â Â Â WriteCSV() |
---|
3118 | Â Â Â Â Â Â Â Â else: |
---|
3119 | Â Â Â Â Â Â Â Â Â Â WriteSeq() |
---|
3120 | Â Â Â Â Â Â Â Â SeqFile.close() |
---|
3121 | Â Â Â Â finally: |
---|
3122 | Â Â Â Â Â Â dlg.Destroy() |
---|
3123 | Â Â Â Â Â Â Â Â |
---|
3124 |   def striphist(var,insChar=''): |
---|
3125 | Â Â Â Â 'strip a histogram number from a var name' |
---|
3126 | Â Â Â Â sv =Â var.split(':') |
---|
3127 |     if len(sv) <= 1: return var |
---|
3128 |     if sv[1]: |
---|
3129 | Â Â Â Â Â Â sv[1]Â =Â insChar |
---|
3130 |     return ':'.join(sv) |
---|
3131 | Â Â Â Â |
---|
3132 |   def plotSpCharFix(lbl): |
---|
3133 | Â Â Â Â 'Change selected unicode characters to their matplotlib equivalent' |
---|
3134 |     for u,p in [ |
---|
3135 | Â Â Â Â Â Â (u'\u03B1',r'$\alpha$'), |
---|
3136 | Â Â Â Â Â Â (u'\u03B2',r'$\beta$'), |
---|
3137 | Â Â Â Â Â Â (u'\u03B3',r'$\gamma$'), |
---|
3138 | Â Â Â Â Â Â (u'\u0394\u03C7',r'$\Delta\chi$'), |
---|
3139 | Â Â Â Â Â Â ]: |
---|
3140 | Â Â Â Â Â Â lbl =Â lbl.replace(u,p) |
---|
3141 |     return lbl |
---|
3142 | Â Â |
---|
3143 |   def SelectXaxis(): |
---|
3144 | Â Â Â Â 'returns a selected column number (or None) as the X-axis selection' |
---|
3145 | Â Â Â Â ncols =Â G2frame.SeqTable.GetNumberCols() |
---|
3146 |     colNames = [G2frame.SeqTable.GetColLabelValue(r) for r in range(ncols)] |
---|
3147 | Â Â Â Â dlg =Â G2G.G2SingleChoiceDialog( |
---|
3148 | Â Â Â Â Â Â G2frame.dataDisplay, |
---|
3149 | Â Â Â Â Â Â 'Select x-axis parameter for plot or Cancel for sequence number', |
---|
3150 | Â Â Â Â Â Â 'Select X-axis', |
---|
3151 | Â Â Â Â Â Â colNames) |
---|
3152 | Â Â Â Â try: |
---|
3153 |       if dlg.ShowModal() == wx.ID_OK: |
---|
3154 | Â Â Â Â Â Â Â Â col =Â dlg.GetSelection() |
---|
3155 | Â Â Â Â Â Â else: |
---|
3156 | Â Â Â Â Â Â Â Â col =Â None |
---|
3157 | Â Â Â Â finally: |
---|
3158 | Â Â Â Â Â Â dlg.Destroy() |
---|
3159 |     return col |
---|
3160 | Â Â |
---|
3161 |   def EnablePseudoVarMenus(): |
---|
3162 | Â Â Â Â 'Enables or disables the PseudoVar menu items that require existing defs' |
---|
3163 |     if Controls['SeqPseudoVars']: |
---|
3164 | Â Â Â Â Â Â val =Â True |
---|
3165 | Â Â Â Â else: |
---|
3166 | Â Â Â Â Â Â val =Â False |
---|
3167 | Â Â Â Â G2frame.dataFrame.SequentialPvars.Enable(wxDELSEQVAR,val) |
---|
3168 | Â Â Â Â G2frame.dataFrame.SequentialPvars.Enable(wxEDITSEQVAR,val) |
---|
3169 | |
---|
3170 |   def DelPseudoVar(event): |
---|
3171 | Â Â Â Â 'Ask the user to select a pseudo var expression to delete' |
---|
3172 | Â Â Â Â choices =Â Controls['SeqPseudoVars'].keys() |
---|
3173 | Â Â Â Â selected =Â G2G.ItemSelector( |
---|
3174 | Â Â Â Â Â Â choices,G2frame.dataFrame, |
---|
3175 | Â Â Â Â Â Â multiple=True, |
---|
3176 | Â Â Â Â Â Â title='Select expressions to remove', |
---|
3177 | Â Â Â Â Â Â header='Delete expression') |
---|
3178 |     if selected is None: return |
---|
3179 |     for item in selected: |
---|
3180 |       del Controls['SeqPseudoVars'][choices[item]] |
---|
3181 |     if selected: |
---|
3182 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3183 | |
---|
3184 |   def EditPseudoVar(event): |
---|
3185 | Â Â Â Â 'Edit an existing pseudo var expression' |
---|
3186 | Â Â Â Â choices =Â Controls['SeqPseudoVars'].keys() |
---|
3187 |     if len(choices) == 1: |
---|
3188 | Â Â Â Â Â Â selected =Â 0 |
---|
3189 | Â Â Â Â else: |
---|
3190 | Â Â Â Â Â Â selected =Â G2G.ItemSelector( |
---|
3191 | Â Â Â Â Â Â Â Â choices,G2frame.dataFrame, |
---|
3192 | Â Â Â Â Â Â Â Â multiple=False, |
---|
3193 | Â Â Â Â Â Â Â Â title='Select an expression to edit', |
---|
3194 | Â Â Â Â Â Â Â Â header='Edit expression') |
---|
3195 |     if selected is not None: |
---|
3196 | Â Â Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3197 | Â Â Â Â Â Â Â Â G2frame.dataDisplay,PSvarDict, |
---|
3198 | Â Â Â Â Â Â Â Â Controls['SeqPseudoVars'][choices[selected]], |
---|
3199 | Â Â Â Â Â Â Â Â header="Edit the PseudoVar expression", |
---|
3200 | Â Â Â Â Â Â Â Â VarLabel="PseudoVar #"+str(selected+1), |
---|
3201 | Â Â Â Â Â Â Â Â fit=False) |
---|
3202 | Â Â Â Â Â Â newobj =Â dlg.Show(True) |
---|
3203 |       if newobj: |
---|
3204 | Â Â Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(newobj) |
---|
3205 |         del Controls['SeqPseudoVars'][choices[selected]] |
---|
3206 | Â Â Â Â Â Â Â Â Controls['SeqPseudoVars'][calcobj.eObj.expression]Â =Â newobj |
---|
3207 | Â Â Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3208 | Â Â Â Â |
---|
3209 |   def AddNewPseudoVar(event): |
---|
3210 | Â Â Â Â 'Create a new pseudo var expression' |
---|
3211 | Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3212 | Â Â Â Â Â Â G2frame.dataDisplay,PSvarDict, |
---|
3213 | Â Â Â Â Â Â header='Enter an expression for a PseudoVar here', |
---|
3214 | Â Â Â Â Â Â VarLabel =Â "New PseudoVar", |
---|
3215 | Â Â Â Â Â Â fit=False) |
---|
3216 | Â Â Â Â obj =Â dlg.Show(True) |
---|
3217 | Â Â Â Â dlg.Destroy() |
---|
3218 |     if obj: |
---|
3219 | Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3220 | Â Â Â Â Â Â Controls['SeqPseudoVars'][calcobj.eObj.expression]Â =Â obj |
---|
3221 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3222 | Â Â Â Â Â Â |
---|
3223 |   def AddNewDistPseudoVar(event): |
---|
3224 | Â Â Â Â obj =Â None |
---|
3225 | Â Â Â Â dlg =Â G2exG.BondDialog( |
---|
3226 | Â Â Â Â Â Â G2frame.dataDisplay,Phases,PSvarDict, |
---|
3227 | Â Â Â Â Â Â header='Select a Bond here', |
---|
3228 | Â Â Â Â Â Â VarLabel =Â "New Bond") |
---|
3229 |     if dlg.ShowModal() == wx.ID_OK: |
---|
3230 | Â Â Â Â Â Â pName,Oatom,Tatom =Â dlg.GetSelection() |
---|
3231 |       if Tatom: |
---|
3232 | Â Â Â Â Â Â Â Â Phase =Â Phases[pName] |
---|
3233 | Â Â Â Â Â Â Â Â General =Â Phase['General'] |
---|
3234 | Â Â Â Â Â Â Â Â cx,ct =Â General['AtomPtrs'][:2] |
---|
3235 | Â Â Â Â Â Â Â Â pId =Â Phase['pId'] |
---|
3236 | Â Â Â Â Â Â Â Â SGData =Â General['SGData'] |
---|
3237 | Â Â Â Â Â Â Â Â sB =Â Tatom.find('(')+1 |
---|
3238 | Â Â Â Â Â Â Â Â symNo =Â 0 |
---|
3239 |         if sB: |
---|
3240 | Â Â Â Â Â Â Â Â Â Â sF =Â Tatom.find(')') |
---|
3241 | Â Â Â Â Â Â Â Â Â Â symNo =Â int(Tatom[sB:sF]) |
---|
3242 | Â Â Â Â Â Â Â Â cellNo =Â [0,0,0] |
---|
3243 | Â Â Â Â Â Â Â Â cB =Â Tatom.find('[') |
---|
3244 |         if cB>0: |
---|
3245 | Â Â Â Â Â Â Â Â Â Â cF =Â Tatom.find(']')+1 |
---|
3246 | Â Â Â Â Â Â Â Â Â Â cellNo =Â eval(Tatom[cB:cF]) |
---|
3247 | Â Â Â Â Â Â Â Â Atoms =Â Phase['Atoms'] |
---|
3248 |         aNames = [atom[ct-1] for atom in Atoms] |
---|
3249 | Â Â Â Â Â Â Â Â oId =Â aNames.index(Oatom) |
---|
3250 | Â Â Â Â Â Â Â Â tId =Â aNames.index(Tatom.split(' +')[0]) |
---|
3251 | Â Â Â Â Â Â Â Â # create an expression object |
---|
3252 | Â Â Â Â Â Â Â Â obj =Â G2obj.ExpressionObj() |
---|
3253 | Â Â Â Â Â Â Â Â obj.expression =Â 'Dist(%s,\n%s)'%(Oatom,Tatom.split(' d=')[0].replace(' ','')) |
---|
3254 | Â Â Â Â Â Â Â Â obj.distance_dict =Â {'pId':pId,'SGData':SGData,'symNo':symNo,'cellNo':cellNo} |
---|
3255 | Â Â Â Â Â Â Â Â obj.distance_atoms =Â [oId,tId] |
---|
3256 | Â Â Â Â else:Â |
---|
3257 | Â Â Â Â Â Â dlg.Destroy() |
---|
3258 | Â Â Â Â Â Â return |
---|
3259 | Â Â Â Â dlg.Destroy() |
---|
3260 |     if obj: |
---|
3261 | Â Â Â Â Â Â Controls['SeqPseudoVars'][obj.expression]Â =Â obj |
---|
3262 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3263 | |
---|
3264 |   def AddNewAnglePseudoVar(event): |
---|
3265 | Â Â Â Â obj =Â None |
---|
3266 | Â Â Â Â dlg =Â G2exG.AngleDialog( |
---|
3267 | Â Â Â Â Â Â G2frame.dataDisplay,Phases,PSvarDict, |
---|
3268 | Â Â Â Â Â Â header='Enter an Angle here', |
---|
3269 | Â Â Â Â Â Â VarLabel =Â "New Angle") |
---|
3270 |     if dlg.ShowModal() == wx.ID_OK: |
---|
3271 | Â Â Â Â Â Â pName,Oatom,Tatoms =Â dlg.GetSelection() |
---|
3272 |       if Tatoms: |
---|
3273 | Â Â Â Â Â Â Â Â Phase =Â Phases[pName] |
---|
3274 | Â Â Â Â Â Â Â Â General =Â Phase['General'] |
---|
3275 | Â Â Â Â Â Â Â Â cx,ct =Â General['AtomPtrs'][:2] |
---|
3276 | Â Â Â Â Â Â Â Â pId =Â Phase['pId'] |
---|
3277 | Â Â Â Â Â Â Â Â SGData =Â General['SGData'] |
---|
3278 | Â Â Â Â Â Â Â Â Atoms =Â Phase['Atoms'] |
---|
3279 |         aNames = [atom[ct-1] for atom in Atoms] |
---|
3280 | Â Â Â Â Â Â Â Â tIds =Â [] |
---|
3281 | Â Â Â Â Â Â Â Â symNos =Â [] |
---|
3282 | Â Â Â Â Â Â Â Â cellNos =Â [] |
---|
3283 | Â Â Â Â Â Â Â Â oId =Â aNames.index(Oatom) |
---|
3284 | Â Â Â Â Â Â Â Â Tatoms =Â Tatoms.split(';') |
---|
3285 |         for Tatom in Tatoms: |
---|
3286 | Â Â Â Â Â Â Â Â Â Â sB =Â Tatom.find('(')+1 |
---|
3287 | Â Â Â Â Â Â Â Â Â Â symNo =Â 0 |
---|
3288 |           if sB: |
---|
3289 | Â Â Â Â Â Â Â Â Â Â Â Â sF =Â Tatom.find(')') |
---|
3290 | Â Â Â Â Â Â Â Â Â Â Â Â symNo =Â int(Tatom[sB:sF]) |
---|
3291 | Â Â Â Â Â Â Â Â Â Â symNos.append(symNo) |
---|
3292 | Â Â Â Â Â Â Â Â Â Â cellNo =Â [0,0,0] |
---|
3293 | Â Â Â Â Â Â Â Â Â Â cB =Â Tatom.find('[') |
---|
3294 |           if cB>0: |
---|
3295 | Â Â Â Â Â Â Â Â Â Â Â Â cF =Â Tatom.find(']')+1 |
---|
3296 | Â Â Â Â Â Â Â Â Â Â Â Â cellNo =Â eval(Tatom[cB:cF]) |
---|
3297 | Â Â Â Â Â Â Â Â Â Â cellNos.append(cellNo) |
---|
3298 | Â Â Â Â Â Â Â Â Â Â tIds.append(aNames.index(Tatom.split('+')[0])) |
---|
3299 | Â Â Â Â Â Â Â Â # create an expression object |
---|
3300 | Â Â Â Â Â Â Â Â obj =Â G2obj.ExpressionObj() |
---|
3301 | Â Â Â Â Â Â Â Â obj.expression =Â 'Angle(%s,%s,\n%s)'%(Tatoms[0],Oatom,Tatoms[1]) |
---|
3302 | Â Â Â Â Â Â Â Â obj.angle_dict =Â {'pId':pId,'SGData':SGData,'symNo':symNos,'cellNo':cellNos} |
---|
3303 | Â Â Â Â Â Â Â Â obj.angle_atoms =Â [oId,tIds] |
---|
3304 | Â Â Â Â else:Â |
---|
3305 | Â Â Â Â Â Â dlg.Destroy() |
---|
3306 | Â Â Â Â Â Â return |
---|
3307 | Â Â Â Â dlg.Destroy() |
---|
3308 |     if obj: |
---|
3309 | Â Â Â Â Â Â Controls['SeqPseudoVars'][obj.expression]Â =Â obj |
---|
3310 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3311 | Â Â Â Â Â Â |
---|
3312 |   def UpdateParmDict(parmDict): |
---|
3313 | Â Â Â Â '''generate the atom positions and the direct & reciprocal cell values, |
---|
3314 | Â Â Â Â because they might be needed to evaluate the pseudovar |
---|
3315 | Â Â Â Â ''' |
---|
3316 | Â Â Â Â Ddict =Â dict(zip(['D11','D22','D33','D12','D13','D23'], |
---|
3317 |              ['A'+str(i) for i in range(6)]) |
---|
3318 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3319 | Â Â Â Â delList =Â [] |
---|
3320 | Â Â Â Â phaselist =Â [] |
---|
3321 |     for item in parmDict: |
---|
3322 |       if ':' not in item: continue |
---|
3323 | Â Â Â Â Â Â key =Â item.split(':') |
---|
3324 |       if len(key) < 3: continue |
---|
3325 | Â Â Â Â Â Â # remove the dA[xyz] terms, they would only bring confusion |
---|
3326 |       if key[2].startswith('dA'): |
---|
3327 | Â Â Â Â Â Â Â Â delList.append(item) |
---|
3328 | Â Â Â Â Â Â # compute and update the corrected reciprocal cell terms using the Dij values |
---|
3329 |       elif key[2] in Ddict: |
---|
3330 |         if key[0] not in phaselist: phaselist.append(key[0]) |
---|
3331 | Â Â Â Â Â Â Â Â akey =Â key[0]+'::'+Ddict[key[2]] |
---|
3332 | Â Â Â Â Â Â Â Â parmDict[akey]Â -=Â parmDict[item] |
---|
3333 | Â Â Â Â Â Â Â Â delList.append(item) |
---|
3334 |     for item in delList: |
---|
3335 |       del parmDict[item]        |
---|
3336 |     for i in phaselist: |
---|
3337 | Â Â Â Â Â Â pId =Â int(i) |
---|
3338 | Â Â Â Â Â Â # apply cell symmetry |
---|
3339 | Â Â Â Â Â Â A,zeros =Â G2stIO.cellFill(str(pId)+'::',SGdata[pId],parmDict,zeroDict[pId]) |
---|
3340 | Â Â Â Â Â Â # convert to direct cell & add the unique terms to the dictionary |
---|
3341 |       for i,val in enumerate(G2lat.A2cell(A)): |
---|
3342 |         if i in uniqCellIndx[pId]: |
---|
3343 | Â Â Â Â Â Â Â Â Â Â lbl =Â str(pId)+'::'+cellUlbl[i] |
---|
3344 | Â Â Â Â Â Â Â Â Â Â parmDict[lbl]Â =Â val |
---|
3345 | Â Â Â Â Â Â lbl =Â str(pId)+'::'+'Vol' |
---|
3346 | Â Â Â Â Â Â parmDict[lbl]Â =Â G2lat.calc_V(A) |
---|
3347 |     return parmDict |
---|
3348 | |
---|
3349 |   def EvalPSvarDeriv(calcobj,parmDict,sampleDict,var,ESD): |
---|
3350 | Â Â Â Â '''Evaluate an expression derivative with respect to a |
---|
3351 | Â Â Â Â GSAS-II variable name. |
---|
3352 | |
---|
3353 | Â Â Â Â Note this likely could be faster if the loop over calcobjs were done |
---|
3354 | Â Â Â Â inside after the Dict was created. |
---|
3355 | Â Â Â Â ''' |
---|
3356 | Â Â Â Â step =Â ESD/10 |
---|
3357 | Â Â Â Â Ddict =Â dict(zip(['D11','D22','D33','D12','D13','D23'], |
---|
3358 |              ['A'+str(i) for i in range(6)]) |
---|
3359 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3360 | Â Â Â Â results =Â [] |
---|
3361 | Â Â Â Â phaselist =Â [] |
---|
3362 | Â Â Â Â VparmDict =Â sampleDict.copy() |
---|
3363 |     for incr in step,-step: |
---|
3364 | Â Â Â Â Â Â VparmDict.update(parmDict.copy())Â Â Â Â Â Â |
---|
3365 | Â Â Â Â Â Â # as saved, the parmDict has updated 'A[xyz]' values, but 'dA[xyz]' |
---|
3366 | Â Â Â Â Â Â # values are not zeroed: fix that! |
---|
3367 |       VparmDict.update({item:0.0 for item in parmDict if 'dA' in item}) |
---|
3368 | Â Â Â Â Â Â VparmDict[var]Â +=Â incr |
---|
3369 | Â Â Â Â Â Â G2mv.Dict2Map(VparmDict,[])Â # apply constraints |
---|
3370 | Â Â Â Â Â Â # generate the atom positions and the direct & reciprocal cell values now, because they might |
---|
3371 | Â Â Â Â Â Â # needed to evaluate the pseudovar |
---|
3372 |       for item in VparmDict: |
---|
3373 |         if item in sampleDict: |
---|
3374 |           continue |
---|
3375 |         if ':' not in item: continue |
---|
3376 | Â Â Â Â Â Â Â Â key =Â item.split(':') |
---|
3377 |         if len(key) < 3: continue |
---|
3378 | Â Â Â Â Â Â Â Â # apply any new shifts to atom positions |
---|
3379 |         if key[2].startswith('dA'): |
---|
3380 | Â Â Â Â Â Â Â Â Â Â VparmDict[''.join(item.split('d'))]Â +=Â VparmDict[item] |
---|
3381 | Â Â Â Â Â Â Â Â Â Â VparmDict[item]Â =Â 0.0 |
---|
3382 | Â Â Â Â Â Â Â Â # compute and update the corrected reciprocal cell terms using the Dij values |
---|
3383 |         if key[2] in Ddict: |
---|
3384 |           if key[0] not in phaselist: phaselist.append(key[0]) |
---|
3385 | Â Â Â Â Â Â Â Â Â Â akey =Â key[0]+'::'+Ddict[key[2]] |
---|
3386 | Â Â Â Â Â Â Â Â Â Â VparmDict[akey]Â -=Â VparmDict[item] |
---|
3387 |       for i in phaselist: |
---|
3388 | Â Â Â Â Â Â Â Â pId =Â int(i) |
---|
3389 | Â Â Â Â Â Â Â Â # apply cell symmetry |
---|
3390 | Â Â Â Â Â Â Â Â A,zeros =Â G2stIO.cellFill(str(pId)+'::',SGdata[pId],VparmDict,zeroDict[pId]) |
---|
3391 | Â Â Â Â Â Â Â Â # convert to direct cell & add the unique terms to the dictionary |
---|
3392 |         for i,val in enumerate(G2lat.A2cell(A)): |
---|
3393 |           if i in uniqCellIndx[pId]: |
---|
3394 | Â Â Â Â Â Â Â Â Â Â Â Â lbl =Â str(pId)+'::'+cellUlbl[i] |
---|
3395 | Â Â Â Â Â Â Â Â Â Â Â Â VparmDict[lbl]Â =Â val |
---|
3396 | Â Â Â Â Â Â Â Â lbl =Â str(pId)+'::'+'Vol' |
---|
3397 | Â Â Â Â Â Â Â Â VparmDict[lbl]Â =Â G2lat.calc_V(A) |
---|
3398 | Â Â Â Â Â Â # dict should be fully updated, use it & calculate |
---|
3399 | Â Â Â Â Â Â calcobj.SetupCalc(VparmDict) |
---|
3400 | Â Â Â Â Â Â results.append(calcobj.EvalExpression()) |
---|
3401 |     return (results[0] - results[1]) / (2.*step) |
---|
3402 | Â Â Â Â |
---|
3403 |   def EnableParFitEqMenus(): |
---|
3404 | Â Â Â Â 'Enables or disables the Parametric Fit menu items that require existing defs' |
---|
3405 |     if Controls['SeqParFitEqList']: |
---|
3406 | Â Â Â Â Â Â val =Â True |
---|
3407 | Â Â Â Â else: |
---|
3408 | Â Â Â Â Â Â val =Â False |
---|
3409 | Â Â Â Â G2frame.dataFrame.SequentialPfit.Enable(wxDELPARFIT,val) |
---|
3410 | Â Â Â Â G2frame.dataFrame.SequentialPfit.Enable(wxEDITPARFIT,val) |
---|
3411 | Â Â Â Â G2frame.dataFrame.SequentialPfit.Enable(wxDOPARFIT,val) |
---|
3412 | |
---|
3413 |   def ParEqEval(Values,calcObjList,varyList): |
---|
3414 | Â Â Â Â '''Evaluate the parametric expression(s) |
---|
3415 | Â Â Â Â :param list Values: a list of values for each variable parameter |
---|
3416 | Â Â Â Â :param list calcObjList: a list of :class:`GSASIIobj.ExpressionCalcObj` |
---|
3417 | Â Â Â Â Â expression objects to evaluate |
---|
3418 | Â Â Â Â :param list varyList: a list of variable names for each value in Values |
---|
3419 | Â Â Â Â ''' |
---|
3420 | Â Â Â Â result =Â [] |
---|
3421 |     for calcobj in calcObjList: |
---|
3422 | Â Â Â Â Â Â calcobj.UpdateVars(varyList,Values) |
---|
3423 | Â Â Â Â Â Â result.append((calcobj.depVal-calcobj.EvalExpression())/calcobj.depSig) |
---|
3424 |     return result |
---|
3425 | |
---|
3426 |   def DoParEqFit(event,eqObj=None): |
---|
3427 | Â Â Â Â 'Parametric fit minimizer' |
---|
3428 | Â Â Â Â varyValueDict =Â {}Â # dict of variables and their initial values |
---|
3429 | Â Â Â Â calcObjList =Â []Â # expression objects, ready to go for each data point |
---|
3430 |     if eqObj is not None: |
---|
3431 | Â Â Â Â Â Â eqObjList =Â [eqObj,] |
---|
3432 | Â Â Â Â else: |
---|
3433 | Â Â Â Â Â Â eqObjList =Â Controls['SeqParFitEqList'] |
---|
3434 | Â Â Â Â UseFlags =Â G2frame.SeqTable.GetColValues(0)Â Â Â Â Â |
---|
3435 |     for obj in eqObjList: |
---|
3436 | Â Â Â Â Â Â # assemble refined vars for this equation |
---|
3437 |       varyValueDict.update({var:val for var,val in obj.GetVariedVarVal()}) |
---|
3438 | Â Â Â Â Â Â # lookup dependent var position |
---|
3439 | Â Â Â Â Â Â depVar =Â obj.GetDepVar() |
---|
3440 |       if depVar in colLabels: |
---|
3441 | Â Â Â Â Â Â Â Â indx =Â colLabels.index(depVar) |
---|
3442 | Â Â Â Â Â Â else: |
---|
3443 |         raise Exception('Dependent variable '+depVar+' not found') |
---|
3444 | Â Â Â Â Â Â # assemble a list of the independent variables |
---|
3445 | Â Â Â Â Â Â indepVars =Â obj.GetIndependentVars() |
---|
3446 | Â Â Â Â Â Â # loop over each datapoint |
---|
3447 |       for j,row in enumerate(zip(*colList)): |
---|
3448 |         if not UseFlags[j]: continue |
---|
3449 | Â Â Â Â Â Â Â Â # assemble equations to fit |
---|
3450 | Â Â Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3451 | Â Â Â Â Â Â Â Â # prepare a dict of needed independent vars for this expression |
---|
3452 |         indepVarDict = {var:row[i] for i,var in enumerate(colLabels) if var in indepVars} |
---|
3453 | Â Â Â Â Â Â Â Â calcobj.SetupCalc(indepVarDict)Â Â Â Â Â Â Â Â |
---|
3454 | Â Â Â Â Â Â Â Â # values and sigs for current value of dependent var |
---|
3455 | Â Â Â Â Â Â Â Â calcobj.depVal =Â row[indx] |
---|
3456 | Â Â Â Â Â Â Â Â calcobj.depSig =Â colSigs[indx][j] |
---|
3457 | Â Â Â Â Â Â Â Â calcObjList.append(calcobj) |
---|
3458 | Â Â Â Â # varied parameters |
---|
3459 | Â Â Â Â varyList =Â varyValueDict.keys() |
---|
3460 |     values = varyValues = [varyValueDict[key] for key in varyList] |
---|
3461 |     if not varyList: |
---|
3462 |       print 'no variables to refine!' |
---|
3463 | Â Â Â Â Â Â return |
---|
3464 | Â Â Â Â try: |
---|
3465 |       result = so.leastsq(ParEqEval,varyValues,full_output=True,  #ftol=Ftol, |
---|
3466 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â args=(calcObjList,varyList) |
---|
3467 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3468 | Â Â Â Â Â Â values =Â result[0] |
---|
3469 | Â Â Â Â Â Â covar =Â result[1] |
---|
3470 |       if covar is None: |
---|
3471 |         raise Exception |
---|
3472 | Â Â Â Â Â Â esdDict =Â {} |
---|
3473 |       for i,avar in enumerate(varyList): |
---|
3474 | Â Â Â Â Â Â Â Â esdDict[avar]Â =Â np.sqrt(covar[i,i]) |
---|
3475 | Â Â Â Â except: |
---|
3476 | Â Â Â Â Â Â print('====> Fit failed') |
---|
3477 | Â Â Â Â Â Â return |
---|
3478 | Â Â Â Â print('==== Fit Results ====') |
---|
3479 |     for obj in eqObjList: |
---|
3480 | Â Â Â Â Â Â obj.UpdateVariedVars(varyList,values) |
---|
3481 | Â Â Â Â Â Â ind =Â 'Â Â Â ' |
---|
3482 | Â Â Â Â Â Â print('Â '+obj.GetDepVar()+' = '+obj.expression) |
---|
3483 |       for var in obj.assgnVars: |
---|
3484 | Â Â Â Â Â Â Â Â print(ind+var+' = '+obj.assgnVars[var]) |
---|
3485 |       for var in obj.freeVars: |
---|
3486 | Â Â Â Â Â Â Â Â avar =Â "::"+obj.freeVars[var][0] |
---|
3487 | Â Â Â Â Â Â Â Â val =Â obj.freeVars[var][1] |
---|
3488 |         if obj.freeVars[var][2]: |
---|
3489 | Â Â Â Â Â Â Â Â Â Â print(ind+var+' = '+avar +Â " = "Â +Â G2mth.ValEsd(val,esdDict[avar])) |
---|
3490 | Â Â Â Â Â Â Â Â else: |
---|
3491 | Â Â Â Â Â Â Â Â Â Â print(ind+var+' = '+avar +Â " ="Â +Â G2mth.ValEsd(val,0)) |
---|
3492 | Â Â Â Â # create a plot for each parametric variable |
---|
3493 |     for fitnum,obj in enumerate(eqObjList): |
---|
3494 | Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3495 | Â Â Â Â Â Â # lookup dependent var position |
---|
3496 | Â Â Â Â Â Â indx =Â colLabels.index(obj.GetDepVar()) |
---|
3497 | Â Â Â Â Â Â # assemble a list of the independent variables |
---|
3498 | Â Â Â Â Â Â indepVars =Â obj.GetIndependentVars()Â Â Â Â Â Â |
---|
3499 | Â Â Â Â Â Â # loop over each datapoint |
---|
3500 | Â Â Â Â Â Â fitvals =Â [] |
---|
3501 |       for j,row in enumerate(zip(*colList)): |
---|
3502 | Â Â Â Â Â Â Â Â calcobj.SetupCalc( |
---|
3503 |           {var:row[i] for i,var in enumerate(colLabels) if var in indepVars} |
---|
3504 | Â Â Â Â Â Â Â Â Â Â ) |
---|
3505 | Â Â Â Â Â Â Â Â fitvals.append(calcobj.EvalExpression()) |
---|
3506 | Â Â Â Â Â Â G2plt.PlotSelectedSequence( |
---|
3507 | Â Â Â Â Â Â Â Â G2frame,[indx],GetColumnInfo,SelectXaxis, |
---|
3508 | Â Â Â Â Â Â Â Â fitnum,fitvals) |
---|
3509 | |
---|
3510 |   def SingleParEqFit(eqObj): |
---|
3511 | Â Â Â Â DoParEqFit(None,eqObj) |
---|
3512 | |
---|
3513 |   def DelParFitEq(event): |
---|
3514 | Â Â Â Â 'Ask the user to select function to delete' |
---|
3515 |     txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] |
---|
3516 | Â Â Â Â selected =Â G2G.ItemSelector( |
---|
3517 | Â Â Â Â Â Â txtlst,G2frame.dataFrame, |
---|
3518 | Â Â Â Â Â Â multiple=True, |
---|
3519 | Â Â Â Â Â Â title='Select a parametric equation(s) to remove', |
---|
3520 | Â Â Â Â Â Â header='Delete equation') |
---|
3521 |     if selected is None: return |
---|
3522 |     Controls['SeqParFitEqList'] = [obj for i,obj in enumerate(Controls['SeqParFitEqList']) if i not in selected] |
---|
3523 | Â Â Â Â EnableParFitEqMenus() |
---|
3524 |     if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3525 | Â Â Â Â |
---|
3526 |   def EditParFitEq(event): |
---|
3527 | Â Â Â Â 'Edit an existing parametric equation' |
---|
3528 |     txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] |
---|
3529 |     if len(txtlst) == 1: |
---|
3530 | Â Â Â Â Â Â selected =Â 0 |
---|
3531 | Â Â Â Â else: |
---|
3532 | Â Â Â Â Â Â selected =Â G2G.ItemSelector( |
---|
3533 | Â Â Â Â Â Â Â Â txtlst,G2frame.dataFrame, |
---|
3534 | Â Â Â Â Â Â Â Â multiple=False, |
---|
3535 | Â Â Â Â Â Â Â Â title='Select a parametric equation to edit', |
---|
3536 | Â Â Â Â Â Â Â Â header='Edit equation') |
---|
3537 |     if selected is not None: |
---|
3538 | Â Â Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3539 | Â Â Â Â Â Â Â Â G2frame.dataDisplay,indepVarDict, |
---|
3540 | Â Â Â Â Â Â Â Â Controls['SeqParFitEqList'][selected], |
---|
3541 | Â Â Â Â Â Â Â Â depVarDict=depVarDict, |
---|
3542 | Â Â Â Â Â Â Â Â header="Edit the formula for this minimization function", |
---|
3543 | Â Â Â Â Â Â Â Â ExtraButton=['Fit',SingleParEqFit]) |
---|
3544 | Â Â Â Â Â Â newobj =Â dlg.Show(True) |
---|
3545 |       if newobj: |
---|
3546 | Â Â Â Â Â Â Â Â Controls['SeqParFitEqList'][selected]Â =Â newobj |
---|
3547 | Â Â Â Â Â Â Â Â EnableParFitEqMenus() |
---|
3548 |       if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3549 | |
---|
3550 |   def AddNewParFitEq(event): |
---|
3551 | Â Â Â Â 'Create a new parametric equation to be fit to sequential results' |
---|
3552 | |
---|
3553 | Â Â Â Â # compile the variable names used in previous freevars to avoid accidental name collisions |
---|
3554 | Â Â Â Â usedvarlist =Â [] |
---|
3555 |     for obj in Controls['SeqParFitEqList']: |
---|
3556 |       for var in obj.freeVars: |
---|
3557 |         if obj.freeVars[var][0] not in usedvarlist: usedvarlist.append(obj.freeVars[var][0]) |
---|
3558 | |
---|
3559 | Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3560 | Â Â Â Â Â Â G2frame.dataDisplay,indepVarDict, |
---|
3561 | Â Â Â Â Â Â depVarDict=depVarDict, |
---|
3562 | Â Â Â Â Â Â header='Define an equation to minimize in the parametric fit', |
---|
3563 | Â Â Â Â Â Â ExtraButton=['Fit',SingleParEqFit], |
---|
3564 | Â Â Â Â Â Â usedVars=usedvarlist) |
---|
3565 | Â Â Â Â obj =Â dlg.Show(True) |
---|
3566 | Â Â Â Â dlg.Destroy() |
---|
3567 |     if obj: |
---|
3568 | Â Â Â Â Â Â Controls['SeqParFitEqList'].append(obj) |
---|
3569 | Â Â Â Â Â Â EnableParFitEqMenus() |
---|
3570 |       if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3571 | Â Â Â Â Â Â Â Â |
---|
3572 |   def CopyParFitEq(event): |
---|
3573 | Â Â Â Â 'Copy an existing parametric equation to be fit to sequential results' |
---|
3574 | Â Â Â Â # compile the variable names used in previous freevars to avoid accidental name collisions |
---|
3575 | Â Â Â Â usedvarlist =Â [] |
---|
3576 |     for obj in Controls['SeqParFitEqList']: |
---|
3577 |       for var in obj.freeVars: |
---|
3578 |         if obj.freeVars[var][0] not in usedvarlist: usedvarlist.append(obj.freeVars[var][0]) |
---|
3579 |     txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] |
---|
3580 |     if len(txtlst) == 1: |
---|
3581 | Â Â Â Â Â Â selected =Â 0 |
---|
3582 | Â Â Â Â else: |
---|
3583 | Â Â Â Â Â Â selected =Â G2G.ItemSelector( |
---|
3584 | Â Â Â Â Â Â Â Â txtlst,G2frame.dataFrame, |
---|
3585 | Â Â Â Â Â Â Â Â multiple=False, |
---|
3586 | Â Â Â Â Â Â Â Â title='Select a parametric equation to copy', |
---|
3587 | Â Â Â Â Â Â Â Â header='Copy equation') |
---|
3588 |     if selected is not None: |
---|
3589 | Â Â Â Â Â Â newEqn =Â copy.deepcopy(Controls['SeqParFitEqList'][selected]) |
---|
3590 |       for var in newEqn.freeVars: |
---|
3591 | Â Â Â Â Â Â Â Â newEqn.freeVars[var][0]Â =Â G2obj.MakeUniqueLabel(newEqn.freeVars[var][0],usedvarlist) |
---|
3592 | Â Â Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3593 | Â Â Â Â Â Â Â Â G2frame.dataDisplay,indepVarDict, |
---|
3594 | Â Â Â Â Â Â Â Â newEqn, |
---|
3595 | Â Â Â Â Â Â Â Â depVarDict=depVarDict, |
---|
3596 | Â Â Â Â Â Â Â Â header="Edit the formula for this minimization function", |
---|
3597 | Â Â Â Â Â Â Â Â ExtraButton=['Fit',SingleParEqFit]) |
---|
3598 | Â Â Â Â Â Â newobj =Â dlg.Show(True) |
---|
3599 |       if newobj: |
---|
3600 | Â Â Â Â Â Â Â Â Controls['SeqParFitEqList'].append(newobj) |
---|
3601 | Â Â Â Â Â Â Â Â EnableParFitEqMenus() |
---|
3602 |       if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3603 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3604 |   def GridSetToolTip(row,col): |
---|
3605 | Â Â Â Â '''Routine to show standard uncertainties for each element in table |
---|
3606 | Â Â Â Â as a tooltip |
---|
3607 | Â Â Â Â ''' |
---|
3608 |     if colSigs[col]: |
---|
3609 |       return u'\u03c3 = '+str(colSigs[col][row]) |
---|
3610 |     return '' |
---|
3611 | Â Â Â Â |
---|
3612 |   def GridColLblToolTip(col): |
---|
3613 | Â Â Â Â '''Define a tooltip for a column. This will be the user-entered value |
---|
3614 | Â Â Â Â (from data['variableLabels']) or the default name |
---|
3615 | Â Â Â Â ''' |
---|
3616 |     if col < 0 or col > len(colLabels): |
---|
3617 |       print 'Illegal column #',col |
---|
3618 | Â Â Â Â Â Â return |
---|
3619 | Â Â Â Â var =Â colLabels[col] |
---|
3620 |     return variableLabels.get(var,G2obj.fmtVarDescr(var)) |
---|
3621 | Â Â Â Â |
---|
3622 |   def SetLabelString(event): |
---|
3623 | Â Â Â Â '''Define or edit the label for a column in the table, to be used |
---|
3624 | Â Â Â Â as a tooltip and for plotting |
---|
3625 | Â Â Â Â ''' |
---|
3626 | Â Â Â Â col =Â event.GetCol() |
---|
3627 |     if col < 0 or col > len(colLabels): |
---|
3628 | Â Â Â Â Â Â return |
---|
3629 | Â Â Â Â var =Â colLabels[col] |
---|
3630 | Â Â Â Â lbl =Â variableLabels.get(var,G2obj.fmtVarDescr(var)) |
---|
3631 | Â Â Â Â dlg =Â G2G.SingleStringDialog(G2frame.dataFrame,'Set variable label', |
---|
3632 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Set a new name for variable '+var,lbl,size=(400,-1)) |
---|
3633 |     if dlg.Show(): |
---|
3634 | Â Â Â Â Â Â variableLabels[var]Â =Â dlg.GetValue() |
---|
3635 | Â Â Â Â dlg.Destroy() |
---|
3636 | |
---|
3637 |   def DoSequentialExport(event): |
---|
3638 | Â Â Â Â '''Event handler for all Sequential Export menu items |
---|
3639 | Â Â Â Â ''' |
---|
3640 | Â Â Â Â vals =Â G2frame.dataFrame.SeqExportLookup.get(event.GetId()) |
---|
3641 |     if vals is None: |
---|
3642 | Â Â Â Â Â Â print('Error: Id not found. This should not happen!') |
---|
3643 | Â Â Â Â G2IO.ExportSequential(G2frame,data,*vals) |
---|
3644 | Â Â |
---|
3645 | Â Â #def GridRowLblToolTip(row): return 'Row ='+str(row) |
---|
3646 | Â Â |
---|
3647 | Â Â # lookup table for unique cell parameters by symmetry |
---|
3648 | Â Â cellGUIlist =Â [ |
---|
3649 | Â Â Â Â [['m3','m3m'],(0,)], |
---|
3650 | Â Â Â Â [['3R','3mR'],(0,3)], |
---|
3651 | Â Â Â Â [['3','3m1','31m','6/m','6/mmm','4/m','4/mmm'],(0,2)], |
---|
3652 | Â Â Â Â [['mmm'],(0,1,2)], |
---|
3653 | Â Â Â Â [['2/m'+'a'],(0,1,2,3)], |
---|
3654 | Â Â Â Â [['2/m'+'b'],(0,1,2,4)], |
---|
3655 | Â Â Â Â [['2/m'+'c'],(0,1,2,5)], |
---|
3656 | Â Â Â Â [['-1'],(0,1,2,3,4,5)], |
---|
3657 | Â Â Â Â ] |
---|
3658 | Â Â # cell labels |
---|
3659 | Â Â cellUlbl =Â ('a','b','c',u'\u03B1',u'\u03B2',u'\u03B3')Â # unicode a,b,c,alpha,beta,gamma |
---|
3660 | |
---|
3661 | Â Â #====================================================================== |
---|
3662 | Â Â # start processing sequential results here (UpdateSeqResults) |
---|
3663 | Â Â #====================================================================== |
---|
3664 |   if not data: |
---|
3665 |     print 'No sequential refinement results' |
---|
3666 | Â Â Â Â return |
---|
3667 | Â Â variableLabels =Â data.get('variableLabels',{}) |
---|
3668 | Â Â data['variableLabels']Â =Â variableLabels |
---|
3669 | Â Â Histograms,Phases =Â G2frame.GetUsedHistogramsAndPhasesfromTree() |
---|
3670 | Â Â Controls =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.root,'Controls')) |
---|
3671 | Â Â # create a place to store Pseudo Vars & Parametric Fit functions, if not present |
---|
3672 |   if 'SeqPseudoVars' not in Controls: Controls['SeqPseudoVars'] = {} |
---|
3673 |   if 'SeqParFitEqList' not in Controls: Controls['SeqParFitEqList'] = [] |
---|
3674 | Â Â histNames =Â data['histNames'] |
---|
3675 |   if G2frame.dataDisplay: |
---|
3676 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
3677 |   if not G2frame.dataFrame.GetStatusBar(): |
---|
3678 | Â Â Â Â Status =Â G2frame.dataFrame.CreateStatusBar() |
---|
3679 | Â Â Â Â Status.SetStatusText("Select column to export; Double click on column to plot data; on row for Covariance") |
---|
3680 | Â Â sampleParms =Â GetSampleParms() |
---|
3681 | |
---|
3682 | Â Â # make dict of varied atom coords keyed by absolute position |
---|
3683 | Â Â newAtomDict =Â data[histNames[0]].get('newAtomDict',{})Â # dict with atom positions; relative & absolute |
---|
3684 | Â Â # Possible error: the next might need to be data[histNames[0]]['varyList'] |
---|
3685 | Â Â # error will arise if there constraints on coordinates? |
---|
3686 |   atomLookup = {newAtomDict[item][0]:item for item in newAtomDict if item in data['varyList']} |
---|
3687 | Â Â |
---|
3688 | Â Â # make dict of varied cell parameters equivalents |
---|
3689 | Â Â ESDlookup =Â {}Â # provides the Dij term for each Ak term (where terms are refined) |
---|
3690 | Â Â Dlookup =Â {}Â # provides the Ak term for each Dij term (where terms are refined) |
---|
3691 | Â Â # N.B. These Dij vars are missing a histogram # |
---|
3692 | Â Â newCellDict =Â data[histNames[0]].get('newCellDict',{}) |
---|
3693 |   for item in newCellDict: |
---|
3694 |     if item in data['varyList']: |
---|
3695 | Â Â Â Â Â Â ESDlookup[newCellDict[item][0]]Â =Â item |
---|
3696 | Â Â Â Â Â Â Dlookup[item]Â =Â newCellDict[item][0] |
---|
3697 | Â Â # add coordinate equivalents to lookup table |
---|
3698 |   for parm in atomLookup: |
---|
3699 | Â Â Â Â Dlookup[atomLookup[parm]]Â =Â parm |
---|
3700 | Â Â Â Â ESDlookup[parm]Â =Â atomLookup[parm] |
---|
3701 | |
---|
3702 | Â Â # get unit cell & symmetry for all phases & initial stuff for later use |
---|
3703 | Â Â RecpCellTerms =Â {} |
---|
3704 | Â Â SGdata =Â {} |
---|
3705 | Â Â uniqCellIndx =Â {} |
---|
3706 | Â Â initialCell =Â {} |
---|
3707 | Â Â RcellLbls =Â {} |
---|
3708 | Â Â zeroDict =Â {} |
---|
3709 |   for phase in Phases: |
---|
3710 | Â Â Â Â phasedict =Â Phases[phase] |
---|
3711 | Â Â Â Â pId =Â phasedict['pId'] |
---|
3712 | Â Â Â Â pfx =Â str(pId)+'::'Â # prefix for A values from phase |
---|
3713 |     RcellLbls[pId] = [pfx+'A'+str(i) for i in range(6)] |
---|
3714 | Â Â Â Â RecpCellTerms[pId]Â =Â G2lat.cell2A(phasedict['General']['Cell'][1:7]) |
---|
3715 | Â Â Â Â zeroDict[pId]Â =Â dict(zip(RcellLbls[pId],6*[0.,])) |
---|
3716 | Â Â Â Â SGdata[pId]Â =Â phasedict['General']['SGData'] |
---|
3717 | Â Â Â Â laue =Â SGdata[pId]['SGLaue'] |
---|
3718 |     if laue == '2/m': |
---|
3719 | Â Â Â Â Â Â laue +=Â SGdata[pId]['SGUniq'] |
---|
3720 |     for symlist,celllist in cellGUIlist: |
---|
3721 |       if laue in symlist: |
---|
3722 | Â Â Â Â Â Â Â Â uniqCellIndx[pId]Â =Â celllist |
---|
3723 | Â Â Â Â Â Â Â Â break |
---|
3724 | Â Â Â Â else:Â # should not happen |
---|
3725 | Â Â Â Â Â Â uniqCellIndx[pId]Â =Â range(6) |
---|
3726 |     for i in uniqCellIndx[pId]: |
---|
3727 | Â Â Â Â Â Â initialCell[str(pId)+'::A'+str(i)]Â =Â RecpCellTerms[pId][i] |
---|
3728 | |
---|
3729 | Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.SequentialMenu) |
---|
3730 | Â Â G2frame.dataFrame.SetLabel('Sequential refinement results') |
---|
3731 |   if not G2frame.dataFrame.GetStatusBar(): |
---|
3732 | Â Â Â Â Status =Â G2frame.dataFrame.CreateStatusBar() |
---|
3733 | Â Â Â Â Status.SetStatusText('') |
---|
3734 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnRenameSelSeq, id=wxID_RENAMESEQSEL) |
---|
3735 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeq, id=wxID_SAVESEQSEL) |
---|
3736 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeqCSV, id=wxID_SAVESEQSELCSV) |
---|
3737 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSeqCSV, id=wxID_SAVESEQCSV) |
---|
3738 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlotSelSeq, id=wxID_PLOTSEQSEL) |
---|
3739 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnAveSelSeq, id=wxID_AVESEQSEL) |
---|
3740 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnReOrgSelSeq, id=wxID_ORGSEQSEL) |
---|
3741 |   G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewPseudoVar, id=wxADDSEQVAR) |
---|
3742 |   G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewDistPseudoVar, id=wxADDSEQDIST) |
---|
3743 |   G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewAnglePseudoVar, id=wxADDSEQANGLE) |
---|
3744 |   G2frame.dataFrame.Bind(wx.EVT_MENU, DelPseudoVar, id=wxDELSEQVAR) |
---|
3745 |   G2frame.dataFrame.Bind(wx.EVT_MENU, EditPseudoVar, id=wxEDITSEQVAR) |
---|
3746 |   G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewParFitEq, id=wxADDPARFIT) |
---|
3747 |   G2frame.dataFrame.Bind(wx.EVT_MENU, CopyParFitEq, id=wxCOPYPARFIT) |
---|
3748 |   G2frame.dataFrame.Bind(wx.EVT_MENU, DelParFitEq, id=wxDELPARFIT) |
---|
3749 |   G2frame.dataFrame.Bind(wx.EVT_MENU, EditParFitEq, id=wxEDITPARFIT) |
---|
3750 |   G2frame.dataFrame.Bind(wx.EVT_MENU, DoParEqFit, id=wxDOPARFIT) |
---|
3751 | |
---|
3752 |   for id in G2frame.dataFrame.SeqExportLookup:    |
---|
3753 |     G2frame.dataFrame.Bind(wx.EVT_MENU, DoSequentialExport, id=id) |
---|
3754 | |
---|
3755 | Â Â EnablePseudoVarMenus() |
---|
3756 | Â Â EnableParFitEqMenus() |
---|
3757 | |
---|
3758 | Â Â # scan for locations where the variables change |
---|
3759 | Â Â VaryListChanges =Â []Â # histograms where there is a change |
---|
3760 | Â Â combinedVaryList =Â [] |
---|
3761 | Â Â firstValueDict =Â {} |
---|
3762 | Â Â vallookup =Â {} |
---|
3763 | Â Â posdict =Â {} |
---|
3764 | Â Â prevVaryList =Â [] |
---|
3765 | Â Â foundNames =Â [] |
---|
3766 |   for i,name in enumerate(histNames): |
---|
3767 |     if name not in data: |
---|
3768 | Â Â Â Â Â Â print("Error: "+name+" not found!") |
---|
3769 | Â Â Â Â Â Â continue |
---|
3770 | Â Â Â Â foundNames.append(name) |
---|
3771 |     for var,val,sig in zip(data[name]['varyList'],data[name]['variables'],data[name]['sig']): |
---|
3772 | Â Â Â Â Â Â svar =Â striphist(var,'*')Â # wild-carded |
---|
3773 |       if svar not in combinedVaryList: |
---|
3774 | Â Â Â Â Â Â Â Â # add variables to list as they appear |
---|
3775 | Â Â Â Â Â Â Â Â combinedVaryList.append(svar) |
---|
3776 | Â Â Â Â Â Â Â Â firstValueDict[svar]Â =Â (val,sig) |
---|
3777 |     if prevVaryList != data[name]['varyList']: # this refinement has a different refinement list from previous |
---|
3778 | Â Â Â Â Â Â prevVaryList =Â data[name]['varyList'] |
---|
3779 | Â Â Â Â Â Â vallookup[name]Â =Â dict(zip(data[name]['varyList'],data[name]['variables'])) |
---|
3780 | Â Â Â Â Â Â posdict[name]Â =Â {} |
---|
3781 |       for var in data[name]['varyList']: |
---|
3782 | Â Â Â Â Â Â Â Â svar =Â striphist(var,'*') |
---|
3783 | Â Â Â Â Â Â Â Â posdict[name][combinedVaryList.index(svar)]Â =Â svar |
---|
3784 | Â Â Â Â Â Â VaryListChanges.append(name) |
---|
3785 |   if len(VaryListChanges) > 1: |
---|
3786 | Â Â Â Â G2frame.dataFrame.SequentialFile.Enable(wxID_ORGSEQSEL,True) |
---|
3787 | Â Â else: |
---|
3788 | Â Â Â Â G2frame.dataFrame.SequentialFile.Enable(wxID_ORGSEQSEL,False) |
---|
3789 | Â Â #----------------------------------------------------------------------------------- |
---|
3790 | Â Â # build up the data table by columns ----------------------------------------------- |
---|
3791 | Â Â histNames =Â foundNames |
---|
3792 | Â Â nRows =Â len(histNames) |
---|
3793 | Â Â colList =Â [nRows*[True]] |
---|
3794 | Â Â colSigs =Â [None] |
---|
3795 | Â Â colLabels =Â ['Use'] |
---|
3796 | Â Â Types =Â [wg.GRID_VALUE_BOOL] |
---|
3797 | Â Â # start with Rwp values |
---|
3798 |   if 'IMG ' not in histNames[0][:4]: |
---|
3799 |     colList += [[data[name]['Rvals']['Rwp'] for name in histNames]] |
---|
3800 | Â Â Â Â colSigs +=Â [None] |
---|
3801 | Â Â Â Â colLabels +=Â ['Rwp'] |
---|
3802 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT+':10,3',] |
---|
3803 | Â Â # add % change in Chi^2 in last cycle |
---|
3804 |   if histNames[0][:4] not in ['SASD','IMG '] and Controls.get('ShowCell'): |
---|
3805 |     colList += [[100.*data[name]['Rvals'].get('DelChi2',-1) for name in histNames]] |
---|
3806 | Â Â Â Â colSigs +=Â [None] |
---|
3807 | Â Â Â Â colLabels +=Â [u'\u0394\u03C7\u00B2Â (%)'] |
---|
3808 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
3809 | Â Â deltaChiCol =Â len(colLabels)-1 |
---|
3810 | Â Â # add changing sample parameters to table |
---|
3811 |   for key in sampleParms: |
---|
3812 | Â Â Â Â colList +=Â [sampleParms[key]] |
---|
3813 | Â Â Â Â colSigs +=Â [None] |
---|
3814 | Â Â Â Â colLabels +=Â [key] |
---|
3815 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
3816 | Â Â sampleDict =Â {} |
---|
3817 |   for i,name in enumerate(histNames): |
---|
3818 |     sampleDict[name] = dict(zip(sampleParms.keys(),[sampleParms[key][i] for key in sampleParms.keys()])) |
---|
3819 | Â Â # add unique cell parameters TODO: review this where the cell symmetry changes (when possible) |
---|
3820 |   if Controls.get('ShowCell',False): |
---|
3821 |     for pId in sorted(RecpCellTerms): |
---|
3822 | Â Â Â Â Â Â pfx =Â str(pId)+'::'Â # prefix for A values from phase |
---|
3823 | Â Â Â Â Â Â cells =Â [] |
---|
3824 | Â Â Â Â Â Â cellESDs =Â [] |
---|
3825 |       colLabels += [pfx+cellUlbl[i] for i in uniqCellIndx[pId]] |
---|
3826 | Â Â Â Â Â Â colLabels +=Â [pfx+'Vol'] |
---|
3827 | Â Â Â Â Â Â Types +=Â (1+len(uniqCellIndx[pId]))*[wg.GRID_VALUE_FLOAT,] |
---|
3828 |       for name in histNames: |
---|
3829 | Â Â Â Â Â Â Â Â covData =Â { |
---|
3830 |           'varyList': [Dlookup.get(striphist(v),v) for v in data[name]['varyList']], |
---|
3831 | Â Â Â Â Â Â Â Â Â Â 'covMatrix':Â data[name]['covMatrix'] |
---|
3832 | Â Â Â Â Â Â Â Â Â Â } |
---|
3833 | Â Â Â Â Â Â Â Â A =Â RecpCellTerms[pId][:]Â # make copy of starting A values |
---|
3834 | Â Â Â Â Â Â Â Â # update with refined values |
---|
3835 |         for i in range(6): |
---|
3836 | Â Â Â Â Â Â Â Â Â Â var =Â str(pId)+'::A'+str(i) |
---|
3837 |           if var in ESDlookup: |
---|
3838 | Â Â Â Â Â Â Â Â Â Â Â Â val =Â data[name]['newCellDict'][ESDlookup[var]][1]Â # get refined value |
---|
3839 | Â Â Â Â Â Â Â Â Â Â Â Â A[i]Â =Â val # override with updated value |
---|
3840 | Â Â Â Â Â Â Â Â # apply symmetry |
---|
3841 |         Albls = [pfx+'A'+str(i) for i in range(6)] |
---|
3842 | Â Â Â Â Â Â Â Â cellDict =Â dict(zip(Albls,A)) |
---|
3843 | Â Â Â Â Â Â Â Â A,zeros =Â G2stIO.cellFill(pfx,SGdata[pId],cellDict,zeroDict[pId]) |
---|
3844 | Â Â Â Â Â Â Â Â # convert to direct cell & add only unique values to table |
---|
3845 | Â Â Â Â Â Â Â Â c =Â G2lat.A2cell(A) |
---|
3846 | Â Â Â Â Â Â Â Â vol =Â G2lat.calc_V(A) |
---|
3847 | Â Â Â Â Â Â Â Â cE =Â G2stIO.getCellEsd(pfx,SGdata[pId],A,covData) |
---|
3848 |         cells += [[c[i] for i in uniqCellIndx[pId]]+[vol]] |
---|
3849 |         cellESDs += [[cE[i] for i in uniqCellIndx[pId]]+[cE[-1]]] |
---|
3850 | Â Â Â Â Â Â colList +=Â zip(*cells) |
---|
3851 | Â Â Â Â Â Â colSigs +=Â zip(*cellESDs) |
---|
3852 | Â Â # sort out the variables in their selected order |
---|
3853 | Â Â varcols =Â 0 |
---|
3854 |   for d in posdict.itervalues(): |
---|
3855 | Â Â Â Â varcols =Â max(varcols,max(d.keys())+1) |
---|
3856 | Â Â # get labels for each column |
---|
3857 |   for i in range(varcols): |
---|
3858 | Â Â Â Â lbl =Â '' |
---|
3859 |     for h in VaryListChanges: |
---|
3860 |       if posdict[h].get(i): |
---|
3861 |         if posdict[h].get(i) in lbl: continue |
---|
3862 |         if lbl != "": lbl += '/' |
---|
3863 | Â Â Â Â Â Â Â Â lbl +=Â posdict[h].get(i) |
---|
3864 | Â Â Â Â colLabels.append(lbl) |
---|
3865 | Â Â Types +=Â varcols*[wg.GRID_VALUE_FLOAT] |
---|
3866 | Â Â vals =Â [] |
---|
3867 | Â Â esds =Â [] |
---|
3868 |   varsellist = None    # will be a list of variable names in the order they are selected to appear |
---|
3869 | Â Â # tabulate values for each hist, leaving None for blank columns |
---|
3870 |   for name in histNames: |
---|
3871 |     if name in posdict: |
---|
3872 |       varsellist = [posdict[name].get(i) for i in range(varcols)] |
---|
3873 | Â Â Â Â Â Â # translate variable names to how they will be used in the headings |
---|
3874 |       vs = [striphist(v,'*') for v in data[name]['varyList']] |
---|
3875 | Â Â Â Â Â Â # determine the index for each column (or None) in the data[]['variables'] and ['sig'] lists |
---|
3876 |       sellist = [vs.index(v) if v is not None else None for v in varsellist] |
---|
3877 | Â Â Â Â Â Â #sellist = [i if striphist(v,'*') in varsellist else None for i,v in enumerate(data[name]['varyList'])] |
---|
3878 |     if not varsellist: raise Exception() |
---|
3879 |     vals.append([data[name]['variables'][s] if s is not None else None for s in sellist]) |
---|
3880 |     esds.append([data[name]['sig'][s] if s is not None else None for s in sellist]) |
---|
3881 | Â Â Â Â #GSASIIpath.IPyBreak() |
---|
3882 | Â Â colList +=Â zip(*vals) |
---|
3883 | Â Â colSigs +=Â zip(*esds) |
---|
3884 | Â Â # compute and add weight fractions to table if varied |
---|
3885 |   for phase in Phases: |
---|
3886 | Â Â Â Â var =Â str(Phases[phase]['pId'])+':*:Scale' |
---|
3887 |     if var not in combinedVaryList: continue |
---|
3888 | Â Â Â Â wtFrList =Â [] |
---|
3889 | Â Â Â Â sigwtFrList =Â [] |
---|
3890 |     for i,name in enumerate(histNames): |
---|
3891 | Â Â Â Â Â Â wtFrSum =Â 0. |
---|
3892 |       for phase1 in Phases: |
---|
3893 | Â Â Â Â Â Â Â Â wtFrSum +=Â Phases[phase1]['Histograms'][name]['Scale'][0]*Phases[phase1]['General']['Mass'] |
---|
3894 | Â Â Â Â Â Â var =Â str(Phases[phase]['pId'])+':'+str(i)+':Scale' |
---|
3895 | Â Â Â Â Â Â wtFr =Â Phases[phase]['Histograms'][name]['Scale'][0]*Phases[phase]['General']['Mass']/wtFrSum |
---|
3896 | Â Â Â Â Â Â wtFrList.append(wtFr) |
---|
3897 |       if var in data[name]['varyList']: |
---|
3898 | Â Â Â Â Â Â Â Â sig =Â data[name]['sig'][data[name]['varyList'].index(var)]*wtFr/Phases[phase]['Histograms'][name]['Scale'][0] |
---|
3899 | Â Â Â Â Â Â else: |
---|
3900 | Â Â Â Â Â Â Â Â sig =Â 0.0 |
---|
3901 | Â Â Â Â Â Â sigwtFrList.append(sig) |
---|
3902 | Â Â Â Â colLabels.append(str(Phases[phase]['pId'])+':*:WgtFrac') |
---|
3903 | Â Â Â Â colList +=Â [wtFrList] |
---|
3904 | Â Â Â Â colSigs +=Â [sigwtFrList] |
---|
3905 | Â Â Â Â Â Â Â Â |
---|
3906 | Â Â # tabulate constrained variables, removing histogram numbers if needed |
---|
3907 | Â Â # from parameter label |
---|
3908 | Â Â depValDict =Â {} |
---|
3909 | Â Â depSigDict =Â {} |
---|
3910 |   for name in histNames: |
---|
3911 |     for var in data[name].get('depParmDict',{}): |
---|
3912 | Â Â Â Â Â Â val,sig =Â data[name]['depParmDict'][var] |
---|
3913 | Â Â Â Â Â Â svar =Â striphist(var,'*') |
---|
3914 |       if svar not in depValDict: |
---|
3915 | Â Â Â Â Â Â Â Â depValDict[svar]Â =Â [val] |
---|
3916 | Â Â Â Â Â Â Â Â depSigDict[svar]Â =Â [sig] |
---|
3917 | Â Â Â Â Â Â else: |
---|
3918 | Â Â Â Â Â Â Â Â depValDict[svar].append(val) |
---|
3919 | Â Â Â Â Â Â Â Â depSigDict[svar].append(sig) |
---|
3920 | Â Â # add the dependent constrained variables to the table |
---|
3921 |   for var in sorted(depValDict): |
---|
3922 |     if len(depValDict[var]) != len(histNames): continue |
---|
3923 | Â Â Â Â colLabels.append(var) |
---|
3924 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
3925 | Â Â Â Â colSigs +=Â [depSigDict[var]] |
---|
3926 | Â Â Â Â colList +=Â [depValDict[var]] |
---|
3927 | |
---|
3928 | Â Â # add atom parameters to table |
---|
3929 | Â Â colLabels +=Â atomLookup.keys() |
---|
3930 | Â Â Types +=Â len(atomLookup)*[wg.GRID_VALUE_FLOAT] |
---|
3931 |   for parm in sorted(atomLookup): |
---|
3932 |     colList += [[data[name]['newAtomDict'][atomLookup[parm]][1] for name in histNames]] |
---|
3933 |     if atomLookup[parm] in data[histNames[0]]['varyList']: |
---|
3934 | Â Â Â Â Â Â col =Â data[histNames[0]]['varyList'].index(atomLookup[parm]) |
---|
3935 |       colSigs += [[data[name]['sig'][col] for name in histNames]] |
---|
3936 | Â Â Â Â else: |
---|
3937 | Â Â Â Â Â Â colSigs +=Â [None]Â # should not happen |
---|
3938 | Â Â # evaluate Pseudovars, their ESDs and add them to grid |
---|
3939 |   for expr in Controls['SeqPseudoVars']: |
---|
3940 | Â Â Â Â obj =Â Controls['SeqPseudoVars'][expr] |
---|
3941 | Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3942 | Â Â Â Â valList =Â [] |
---|
3943 | Â Â Â Â esdList =Â [] |
---|
3944 |     for seqnum,name in enumerate(histNames): |
---|
3945 | Â Â Â Â Â Â sigs =Â data[name]['sig'] |
---|
3946 | Â Â Â Â Â Â G2mv.InitVars() |
---|
3947 | Â Â Â Â Â Â parmDict =Â data[name].get('parmDict') |
---|
3948 | Â Â Â Â Â Â constraintInfo =Â data[name].get('constraintInfo',[[],[],{},[],seqnum]) |
---|
3949 | Â Â Â Â Â Â groups,parmlist,constrDict,fixedList,ihst =Â constraintInfo |
---|
3950 | Â Â Â Â Â Â varyList =Â data[name]['varyList'] |
---|
3951 | Â Â Â Â Â Â parmDict =Â data[name]['parmDict'] |
---|
3952 | Â Â Â Â Â Â G2mv.GenerateConstraints(groups,parmlist,varyList,constrDict,fixedList,parmDict,SeqHist=ihst) |
---|
3953 |       if 'Dist' in expr: |
---|
3954 |         derivs = G2mth.CalcDistDeriv(obj.distance_dict,obj.distance_atoms, parmDict) |
---|
3955 | Â Â Â Â Â Â Â Â pId =Â obj.distance_dict['pId'] |
---|
3956 | Â Â Â Â Â Â Â Â aId,bId =Â obj.distance_atoms |
---|
3957 |         varyNames = ['%d::dA%s:%d'%(pId,ip,aId) for ip in ['x','y','z']] |
---|
3958 |         varyNames += ['%d::dA%s:%d'%(pId,ip,bId) for ip in ['x','y','z']] |
---|
3959 | Â Â Â Â Â Â Â Â VCoV =Â G2mth.getVCov(varyNames,varyList,data[name]['covMatrix']) |
---|
3960 | Â Â Â Â Â Â Â Â esdList.append(np.sqrt(np.inner(derivs,np.inner(VCoV,derivs.T))Â )) |
---|
3961 | #Â Â Â Â Â Â Â Â GSASIIpath.IPyBreak() |
---|
3962 |       elif 'Angle' in expr: |
---|
3963 |         derivs = G2mth.CalcAngleDeriv(obj.angle_dict,obj.angle_atoms, parmDict) |
---|
3964 | Â Â Â Â Â Â Â Â pId =Â obj.angle_dict['pId'] |
---|
3965 | Â Â Â Â Â Â Â Â aId,bId =Â obj.angle_atoms |
---|
3966 |         varyNames = ['%d::dA%s:%d'%(pId,ip,aId) for ip in ['x','y','z']] |
---|
3967 |         varyNames += ['%d::dA%s:%d'%(pId,ip,bId[0]) for ip in ['x','y','z']] |
---|
3968 |         varyNames += ['%d::dA%s:%d'%(pId,ip,bId[1]) for ip in ['x','y','z']] |
---|
3969 | Â Â Â Â Â Â Â Â VCoV =Â G2mth.getVCov(varyNames,varyList,data[name]['covMatrix']) |
---|
3970 | Â Â Â Â Â Â Â Â esdList.append(np.sqrt(np.inner(derivs,np.inner(VCoV,derivs.T))Â )) |
---|
3971 | Â Â Â Â Â Â else: |
---|
3972 | Â Â Â Â Â Â Â Â derivs =Â np.array( |
---|
3973 | Â Â Â Â Â Â Â Â Â Â [EvalPSvarDeriv(calcobj,parmDict.copy(),sampleDict[name],var,ESD) |
---|
3974 |            for var,ESD in zip(varyList,sigs)]) |
---|
3975 | Â Â Â Â Â Â Â Â esdList.append(np.sqrt( |
---|
3976 | Â Â Â Â Â Â Â Â Â Â np.inner(derivs,np.inner(data[name]['covMatrix'],derivs.T))Â )) |
---|
3977 | Â Â Â Â Â Â PSvarDict =Â parmDict.copy() |
---|
3978 | Â Â Â Â Â Â PSvarDict.update(sampleDict[name]) |
---|
3979 | Â Â Â Â Â Â UpdateParmDict(PSvarDict) |
---|
3980 | Â Â Â Â Â Â calcobj.UpdateDict(PSvarDict) |
---|
3981 | Â Â Â Â Â Â valList.append(calcobj.EvalExpression()) |
---|
3982 | #Â Â Â Â Â Â if calcobj.su is not None: esdList[-1] = calcobj.su |
---|
3983 |     if not esdList: |
---|
3984 | Â Â Â Â Â Â esdList =Â None |
---|
3985 | Â Â Â Â colList +=Â [valList] |
---|
3986 | Â Â Â Â colSigs +=Â [esdList] |
---|
3987 | Â Â Â Â colLabels +=Â [expr] |
---|
3988 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
3989 | Â Â #---- table build done ------------------------------------------------------------- |
---|
3990 | |
---|
3991 | Â Â # Make dict needed for creating & editing pseudovars (PSvarDict). |
---|
3992 | Â Â name =Â histNames[0] |
---|
3993 | Â Â parmDict =Â data[name].get('parmDict',{}) |
---|
3994 | Â Â PSvarDict =Â parmDict.copy() |
---|
3995 | Â Â PSvarDict.update(sampleParms) |
---|
3996 | Â Â UpdateParmDict(PSvarDict) |
---|
3997 | Â Â # Also dicts of dependent (depVarDict) & independent vars (indepVarDict) |
---|
3998 | Â Â # for Parametric fitting from the data table |
---|
3999 | Â Â parmDict =Â dict(zip(colLabels,zip(*colList)[0]))Â # scratch dict w/all values in table |
---|
4000 | Â Â parmDict.update( |
---|
4001 |     {var:val for var,val in data[name].get('newCellDict',{}).values()} # add varied reciprocal cell terms |
---|
4002 | Â Â ) |
---|
4003 | Â Â name =Â histNames[0] |
---|
4004 | |
---|
4005 | Â Â #****************************************************************************** |
---|
4006 | Â Â # create a set of values for example evaluation of pseudovars and |
---|
4007 | Â Â # this does not work for refinements that have differing numbers of variables. |
---|
4008 | Â Â #raise Exception |
---|
4009 | Â Â indepVarDict =Â {}Â Â Â #Â values in table w/o ESDs |
---|
4010 | Â Â depVarDict =Â {} |
---|
4011 |   for i,var in enumerate(colLabels): |
---|
4012 |     if var == 'Use': continue |
---|
4013 |     if colList[i][0] is None: |
---|
4014 | Â Â Â Â Â Â val,sig =Â firstValueDict.get(var,[None,None]) |
---|
4015 |     elif colSigs[i]: |
---|
4016 | Â Â Â Â Â Â val,sig =Â colList[i][0],colSigs[i][0] |
---|
4017 | Â Â Â Â else: |
---|
4018 | Â Â Â Â Â Â val,sig =Â colList[i][0],None |
---|
4019 |     if val is None: |
---|
4020 | Â Â Â Â Â Â continue |
---|
4021 |     elif sig is None: |
---|
4022 | Â Â Â Â Â Â indepVarDict[var]Â =Â val |
---|
4023 |     elif striphist(var) not in Dlookup: |
---|
4024 | Â Â Â Â Â Â depVarDict[var]Â =Â val |
---|
4025 | Â Â # add recip cell coeff. values |
---|
4026 |   depVarDict.update({var:val for var,val in data[name].get('newCellDict',{}).values()}) |
---|
4027 | |
---|
4028 | Â Â G2frame.dataFrame.currentGrids =Â [] |
---|
4029 | Â Â G2frame.dataDisplay =Â G2G.GSGrid(parent=G2frame.dataFrame) |
---|
4030 | Â Â G2frame.SeqTable =Â G2G.Table( |
---|
4031 |     [list(cl) for cl in zip(*colList)],   # convert from columns to rows |
---|
4032 | Â Â Â Â colLabels=colLabels,rowLabels=histNames,types=Types) |
---|
4033 |   G2frame.dataDisplay.SetTable(G2frame.SeqTable, True) |
---|
4034 | Â Â #G2frame.dataDisplay.EnableEditing(False) |
---|
4035 | Â Â # make all but first column read-only |
---|
4036 |   for c in range(1,len(colLabels)): |
---|
4037 |     for r in range(nRows): |
---|
4038 | Â Â Â Â Â Â G2frame.dataDisplay.SetCellReadOnly(r,c) |
---|
4039 |   G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, PlotSelect) |
---|
4040 |   G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, SetLabelString) |
---|
4041 | Â Â G2frame.dataDisplay.SetRowLabelSize(8*len(histNames[0]))Â Â Â Â #pretty arbitrary 8 |
---|
4042 | Â Â G2frame.dataDisplay.SetMargins(0,0) |
---|
4043 | Â Â G2frame.dataDisplay.AutoSizeColumns(True) |
---|
4044 |   if prevSize: |
---|
4045 | Â Â Â Â G2frame.dataFrame.setSizePosLeft(prevSize) |
---|
4046 | Â Â else: |
---|
4047 | Â Â Â Â G2frame.dataFrame.setSizePosLeft([700,350]) |
---|
4048 | Â Â # highlight unconverged shifts |
---|
4049 |   if histNames[0][:4] not in ['SASD','IMG ']: |
---|
4050 |     for row,name in enumerate(histNames): |
---|
4051 | Â Â Â Â Â Â deltaChi =Â G2frame.SeqTable.GetValue(row,deltaChiCol) |
---|
4052 |       if deltaChi > 10.: |
---|
4053 | Â Â Â Â Â Â Â Â G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,0,0)) |
---|
4054 |       elif deltaChi > 1.0: |
---|
4055 | Â Â Â Â Â Â Â Â G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,255,0)) |
---|
4056 | Â Â G2frame.dataDisplay.InstallGridToolTip(GridSetToolTip,GridColLblToolTip) |
---|
4057 | Â Â G2frame.dataDisplay.SendSizeEvent()Â # resize needed on mac |
---|
4058 | Â Â G2frame.dataDisplay.Refresh()Â # shows colored text on mac |
---|
4059 | Â Â |
---|
4060 | ################################################################################ |
---|
4061 | #####Â Main PWDR panel |
---|
4062 | ################################################################################Â Â Â Â Â Â |
---|
4063 | Â Â Â Â |
---|
4064 | def UpdatePWHKPlot(G2frame,kind,item): |
---|
4065 | Â Â '''Called when the histogram main tree entry is called. Displays the |
---|
4066 | Â Â histogram weight factor, refinement statistics for the histogram |
---|
4067 | Â Â and the range of data for a simulation. |
---|
4068 | |
---|
4069 | Â Â Also invokes a plot of the histogram. |
---|
4070 | Â Â ''' |
---|
4071 |   def onEditSimRange(event): |
---|
4072 | Â Â Â Â 'Edit simulation range' |
---|
4073 | Â Â Â Â inp =Â [ |
---|
4074 | Â Â Â Â Â Â min(data[1][0]), |
---|
4075 | Â Â Â Â Â Â max(data[1][0]), |
---|
4076 | Â Â Â Â Â Â None |
---|
4077 | Â Â Â Â Â Â ] |
---|
4078 | Â Â Â Â inp[2]Â =Â (inp[1]Â -Â inp[0])/(len(data[1][0])-1.) |
---|
4079 |     names = ('start angle', 'end angle', 'step size') |
---|
4080 | Â Â Â Â dlg =Â G2G.ScrolledMultiEditor( |
---|
4081 |       G2frame,[inp] * len(inp), range(len(inp)), names, |
---|
4082 | Â Â Â Â Â Â header='Edit simulation range', |
---|
4083 | Â Â Â Â Â Â minvals=(0.001,0.001,0.0001), |
---|
4084 | Â Â Â Â Â Â maxvals=(180.,180.,.1), |
---|
4085 | Â Â Â Â Â Â ) |
---|
4086 | Â Â Â Â dlg.CenterOnParent() |
---|
4087 | Â Â Â Â val =Â dlg.ShowModal() |
---|
4088 | Â Â Â Â dlg.Destroy() |
---|
4089 |     if val != wx.ID_OK: return |
---|
4090 |     if inp[0] > inp[1]: |
---|
4091 | Â Â Â Â Â Â end,start,step =Â inp |
---|
4092 | Â Â Â Â else:Â Â Â Â Â Â Â Â |
---|
4093 | Â Â Â Â Â Â start,end,step =Â inp |
---|
4094 | Â Â Â Â step =Â abs(step) |
---|
4095 | Â Â Â Â N =Â int((end-start)/step)+1 |
---|
4096 | Â Â Â Â newdata =Â np.linspace(start,end,N,True) |
---|
4097 |     if len(newdata) < 2: return # too small a range - reject |
---|
4098 | Â Â Â Â data[1]Â =Â [newdata,np.zeros_like(newdata),np.ones_like(newdata), |
---|
4099 | Â Â Â Â Â Â np.zeros_like(newdata),np.zeros_like(newdata),np.zeros_like(newdata)] |
---|
4100 | Â Â Â Â Tmin =Â newdata[0] |
---|
4101 | Â Â Â Â Tmax =Â newdata[-1] |
---|
4102 | Â Â Â Â G2frame.PatternTree.SetItemPyData(GetPatternTreeItemId(G2frame,item,'Limits'), |
---|
4103 | Â Â Â Â Â Â [(Tmin,Tmax),[Tmin,Tmax]]) |
---|
4104 | Â Â Â Â UpdatePWHKPlot(G2frame,kind,item)Â # redisplay data screen |
---|
4105 | |
---|
4106 |   def OnPlot3DHKL(event): |
---|
4107 | Â Â Â Â refList =Â data[1]['RefList'] |
---|
4108 | Â Â Â Â FoMax =Â np.max(refList.T[8+Super]) |
---|
4109 | Â Â Â Â Hmin =Â np.array([int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))]) |
---|
4110 | Â Â Â Â Hmax =Â np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))]) |
---|
4111 | Â Â Â Â Vpoint =Â np.array([int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))]) |
---|
4112 | Â Â Â Â controls =Â {'Type'Â :Â 'Fosq','Iscale'Â :Â False,'HKLmax'Â :Â Hmax,'HKLmin'Â :Â Hmin,'Zone':False,'viewKey':'L', |
---|
4113 | Â Â Â Â Â Â 'FoMax'Â :Â FoMax,'Scale'Â :Â 1.0,'Drawing':{'viewPoint':[Vpoint,[]],'default':Vpoint[:], |
---|
4114 | Â Â Â Â Â Â 'backColor':[0,0,0],'depthFog':False,'Zclip':10.0,'cameraPos':10.,'Zstep':0.05,'viewUp':[0,1,0], |
---|
4115 | Â Â Â Â Â Â 'Scale':1.0,'oldxy':[],'viewDir':[0,0,1]},'Super':Super,'SuperVec':SuperVec} |
---|
4116 | Â Â Â Â G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName) |
---|
4117 | Â Â Â Â |
---|
4118 |   def OnPlotAll3DHKL(event): |
---|
4119 | Â Â Â Â choices =Â GetPatternTreeDataNames(G2frame,['HKLF',]) |
---|
4120 |     dlg = G2G.G2MultiChoiceDialog(G2frame, 'Select reflection sets to plot', |
---|
4121 | Â Â Â Â Â Â 'Use data',choices) |
---|
4122 | Â Â Â Â try: |
---|
4123 |       if dlg.ShowModal() == wx.ID_OK: |
---|
4124 |         refNames = [choices[i] for i in dlg.GetSelections()] |
---|
4125 | Â Â Â Â Â Â else: |
---|
4126 | Â Â Â Â Â Â Â Â return |
---|
4127 | Â Â Â Â finally: |
---|
4128 | Â Â Â Â Â Â dlg.Destroy() |
---|
4129 | Â Â Â Â refList =Â np.zeros(0) |
---|
4130 |     for name in refNames: |
---|
4131 |       Id = GetPatternTreeItemId(G2frame,G2frame.root, name) |
---|
4132 | Â Â Â Â Â Â reflData =Â G2frame.PatternTree.GetItemPyData(Id)[1] |
---|
4133 |       if len(refList): |
---|
4134 | Â Â Â Â Â Â Â Â refList =Â np.concatenate((refList,reflData['RefList'])) |
---|
4135 | Â Â Â Â Â Â else: |
---|
4136 | Â Â Â Â Â Â Â Â refList =Â reflData['RefList'] |
---|
4137 | Â Â Â Â Â Â |
---|
4138 | Â Â Â Â FoMax =Â np.max(refList.T[8+Super]) |
---|
4139 | Â Â Â Â Hmin =Â np.array([int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))]) |
---|
4140 | Â Â Â Â Hmax =Â np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))]) |
---|
4141 | Â Â Â Â Vpoint =Â [int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))] |
---|
4142 | Â Â Â Â controls =Â {'Type'Â :Â 'Fosq','Iscale'Â :Â False,'HKLmax'Â :Â Hmax,'HKLmin'Â :Â Hmin,'Zone':False,'viewKey':'L', |
---|
4143 | Â Â Â Â Â Â 'FoMax'Â :Â FoMax,'Scale'Â :Â 1.0,'Drawing':{'viewPoint':[Vpoint,[]],'default':Vpoint[:], |
---|
4144 | Â Â Â Â Â Â 'backColor':[0,0,0],'depthFog':False,'Zclip':10.0,'cameraPos':10.,'Zstep':0.05,'viewUp':[0,1,0], |
---|
4145 | Â Â Â Â Â Â 'Scale':1.0,'oldxy':[],'viewDir':[1,0,0]},'Super':Super,'SuperVec':SuperVec} |
---|
4146 | Â Â Â Â G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName) |
---|
4147 | Â Â Â Â Â Â Â Â Â |
---|
4148 |   def OnMergeHKL(event): |
---|
4149 | Â Â Â Â Name =Â G2frame.PatternTree.GetItemText(G2frame.PatternId) |
---|
4150 | Â Â Â Â Inst =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame, |
---|
4151 | Â Â Â Â Â Â G2frame.PatternId,'Instrument Parameters')) |
---|
4152 | Â Â Â Â CId =Â GetPatternTreeItemId(G2frame,G2frame.PatternId,'Comments') |
---|
4153 |     if CId: |
---|
4154 | Â Â Â Â Â Â Comments =Â G2frame.PatternTree.GetItemPyData(CId) |
---|
4155 | Â Â Â Â else: |
---|
4156 | Â Â Â Â Â Â Comments =Â [] |
---|
4157 | Â Â Â Â refList =Â np.copy(data[1]['RefList']) |
---|
4158 |     Comments.append(' Merging %d reflections from %s'%(len(refList),Name)) |
---|
4159 | Â Â Â Â dlg =Â MergeDialog(G2frame,data) |
---|
4160 | Â Â Â Â try: |
---|
4161 |       if dlg.ShowModal() == wx.ID_OK: |
---|
4162 | Â Â Â Â Â Â Â Â Trans,Cent,Laue =Â dlg.GetSelection() |
---|
4163 | Â Â Â Â Â Â else: |
---|
4164 | Â Â Â Â Â Â Â Â return |
---|
4165 | Â Â Â Â finally: |
---|
4166 | Â Â Â Â Â Â dlg.Destroy() |
---|
4167 | Â Â Â Â Super =Â data[1]['Super'] |
---|
4168 | Â Â Â Â refList,badRefs =Â G2lat.transposeHKLF(Trans,Super,refList) |
---|
4169 |     if len(badRefs):  #do I want to list badRefs? |
---|
4170 | Â Â Â Â Â Â G2frame.ErrorDialog('Failed transformation','Matrix yields fractional hkl indices') |
---|
4171 | Â Â Â Â Â Â return |
---|
4172 | Â Â Â Â Comments.append(" Transformation M*H = H' applied; M=") |
---|
4173 | Â Â Â Â Comments.append(str(Trans)) |
---|
4174 | Â Â Â Â refList =Â G2lat.LaueUnique(Laue,refList) |
---|
4175 |     dlg = wx.ProgressDialog('Build HKL dictonary','',len(refList)+1, |
---|
4176 | Â Â Â Â Â Â style =Â wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) |
---|
4177 | Â Â Â Â HKLdict =Â {} |
---|
4178 |     for ih,hkl in enumerate(refList): |
---|
4179 |       if str(hkl[:3+Super]) not in HKLdict: |
---|
4180 | Â Â Â Â Â Â Â Â HKLdict[str(hkl[:3+Super])]Â =Â [hkl[:3+Super],[hkl[3+Super:],]] |
---|
4181 | Â Â Â Â Â Â else: |
---|
4182 | Â Â Â Â Â Â Â Â HKLdict[str(hkl[:3+Super])][1].append(hkl[3+Super:]) |
---|
4183 | Â Â Â Â Â Â dlg.Update(ih) |
---|
4184 | Â Â Â Â dlg.Destroy() |
---|
4185 | Â Â Â Â mergeRef =Â [] |
---|
4186 |     dlg = wx.ProgressDialog('Processing merge','',len(HKLdict)+1, |
---|
4187 | Â Â Â Â Â Â style =Â wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) |
---|
4188 | Â Â Â Â sumDf =Â 0. |
---|
4189 | Â Â Â Â sumFo =Â 0. |
---|
4190 |     for ih,hkl in enumerate(HKLdict): |
---|
4191 | Â Â Â Â Â Â HKL =Â HKLdict[hkl] |
---|
4192 | Â Â Â Â Â Â newHKL =Â list(HKL[0])+list(HKL[1][0]) |
---|
4193 |       if len(HKL[1]) > 1: |
---|
4194 | Â Â Â Â Â Â Â Â fos =Â np.array(HKL[1]) |
---|
4195 | Â Â Â Â Â Â Â Â wFo =Â 1/fos[:,3]**2 |
---|
4196 | Â Â Â Â Â Â Â Â Fo =Â np.average(fos[:,2],weights=wFo) |
---|
4197 | Â Â Â Â Â Â Â Â std =Â np.std(fos[:,2]) |
---|
4198 | Â Â Â Â Â Â Â Â sig =Â np.sqrt(np.mean(fos[:,3])**2+std**2) |
---|
4199 | Â Â Â Â Â Â Â Â sumFo +=Â np.sum(fos[:,2]) |
---|
4200 | Â Â Â Â Â Â Â Â sumDf +=Â np.sum(np.abs(fos[:,2]-Fo)) |
---|
4201 | Â Â Â Â Â Â Â Â dlg.Update(ih) |
---|
4202 | Â Â Â Â Â Â Â Â newHKL[5+Super]Â =Â Fo |
---|
4203 | Â Â Â Â Â Â Â Â newHKL[6+Super]Â =Â sig |
---|
4204 | Â Â Â Â Â Â Â Â newHKL[8+Super]Â =Â Fo |
---|
4205 |       if newHKL[5+Super] > 0.: |
---|
4206 | Â Â Â Â Â Â Â Â mergeRef.append(list(newHKL))Â |
---|
4207 | Â Â Â Â dlg.Destroy() |
---|
4208 |     if Super: |
---|
4209 | Â Â Â Â Â Â mergeRef =Â G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(mergeRef,3),2),1),0) |
---|
4210 | Â Â Â Â else: |
---|
4211 | Â Â Â Â Â Â mergeRef =Â G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(mergeRef,2),1),0) |
---|
4212 | Â Â Â Â mergeRef =Â np.array(mergeRef) |
---|
4213 |     if sumFo: |
---|
4214 |       mtext = ' merge R = %6.2f%s for %d reflections in %s'%(100.*sumDf/sumFo,'%',mergeRef.shape[0],Laue) |
---|
4215 |       print mtext |
---|
4216 | Â Â Â Â Â Â Comments.append(mtext) |
---|
4217 | Â Â Â Â else: |
---|
4218 |       print 'nothing to merge for %s reflections'%(mergeRef.shape[0]) |
---|
4219 | Â Â Â Â HKLFlist =Â [] |
---|
4220 | Â Â Â Â newName =Â Name+' '+Laue |
---|
4221 |     if G2frame.PatternTree.GetCount(): |
---|
4222 |       item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root) |
---|
4223 |       while item: |
---|
4224 | Â Â Â Â Â Â Â Â name =Â G2frame.PatternTree.GetItemText(item) |
---|
4225 |         if name.startswith('HKLF ') and name not in HKLFlist: |
---|
4226 | Â Â Â Â Â Â Â Â Â Â HKLFlist.append(name) |
---|
4227 |         item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) |
---|
4228 | Â Â Â Â newName =Â G2obj.MakeUniqueLabel(newName,HKLFlist) |
---|
4229 | Â Â Â Â newData =Â copy.deepcopy(data) |
---|
4230 | Â Â Â Â newData[0]['ranId']Â =Â ran.randint(0,sys.maxint) |
---|
4231 | Â Â Â Â newData[1]['RefList']Â =Â mergeRef |
---|
4232 | Â Â Â Â Id =Â G2frame.PatternTree.AppendItem(parent=G2frame.root,text=newName) |
---|
4233 | Â Â Â Â G2frame.PatternTree.SetItemPyData( |
---|
4234 | Â Â Â Â Â Â G2frame.PatternTree.AppendItem(Id,text='Comments'),Comments) |
---|
4235 | Â Â Â Â G2frame.PatternTree.SetItemPyData(Id,newData) |
---|
4236 | Â Â Â Â G2frame.PatternTree.SetItemPyData( |
---|
4237 | Â Â Â Â Â Â G2frame.PatternTree.AppendItem(Id,text='Instrument Parameters'),Inst) |
---|
4238 | Â Â Â Â G2frame.PatternTree.SetItemPyData( |
---|
4239 | Â Â Â Â Â Â G2frame.PatternTree.AppendItem(Id,text='Reflection List'),{})Â #dummy entry for GUI use |
---|
4240 | Â Â Â Â Â Â Â Â Â Â |
---|
4241 |   def OnErrorAnalysis(event): |
---|
4242 | Â Â Â Â G2plt.PlotDeltSig(G2frame,kind) |
---|
4243 | Â Â Â Â |
---|
4244 |   def OnWtFactor(event): |
---|
4245 | Â Â Â Â event.Skip() |
---|
4246 | Â Â Â Â try: |
---|
4247 | Â Â Â Â Â Â val =Â float(wtval.GetValue()) |
---|
4248 |     except ValueError: |
---|
4249 | Â Â Â Â Â Â val =Â data[0]['wtFactor'] |
---|
4250 | Â Â Â Â data[0]['wtFactor']Â =Â val |
---|
4251 | Â Â Â Â wtval.SetValue('%.3f'%(val)) |
---|
4252 | Â Â Â Â |
---|
4253 | #Â Â def OnCompression(event): |
---|
4254 | #Â Â Â Â data[0] = int(comp.GetValue()) |
---|
4255 | Â Â Â Â |
---|
4256 |   def onCopyPlotCtrls(event): |
---|
4257 | Â Â Â Â '''Respond to menu item to copy multiple sections from a histogram. |
---|
4258 | Â Â Â Â Need this here to pass on the G2frame object. |
---|
4259 | Â Â Â Â ''' |
---|
4260 | Â Â Â Â G2pdG.CopyPlotCtrls(G2frame) |
---|
4261 | |
---|
4262 |   def onCopySelectedItems(event): |
---|
4263 | Â Â Â Â '''Respond to menu item to copy multiple sections from a histogram. |
---|
4264 | Â Â Â Â Need this here to pass on the G2frame object. |
---|
4265 | Â Â Â Â ''' |
---|
4266 | Â Â Â Â G2pdG.CopySelectedHistItems(G2frame) |
---|
4267 | Â Â Â Â Â Â |
---|
4268 | Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4269 | #patches |
---|
4270 |   if not data: |
---|
4271 | Â Â Â Â return |
---|
4272 |   if 'wtFactor' not in data[0]: |
---|
4273 | Â Â Â Â data[0]Â =Â {'wtFactor':1.0} |
---|
4274 | #Â Â if kind == 'PWDR' and 'Compression' not in data[0]: |
---|
4275 | #Â Â Â Â data[0]['Compression'] = 1 |
---|
4276 | Â Â #if isinstance(data[1],list) and kind == 'HKLF': |
---|
4277 |   if 'list' in str(type(data[1])) and kind == 'HKLF': |
---|
4278 | Â Â Â Â RefData =Â {'RefList':[],'FF':[]} |
---|
4279 |     for ref in data[1]: |
---|
4280 | Â Â Â Â Â Â RefData['RefList'].append(ref[:11]+[ref[13],]) |
---|
4281 | Â Â Â |
---|