Changeset 1143
- Timestamp:
- Nov 10, 2013 8:32:26 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1141 r1143 1613 1613 if not G2gd.GetPatternTreeItemId(self,self.root,'Controls'): 1614 1614 sub = self.PatternTree.AppendItem(parent=self.root,text='Controls') 1615 self.PatternTree.SetItemPyData(sub,{'deriv type':'analytic Hessian', #default controls 1616 'min dM/M':0.0001,'shift factor':1.,'max cyc':3,'F**2':True, 1617 'minF/sig':0,}) 1615 self.PatternTree.SetItemPyData(sub,copy.copy(G2gd.DefaultControls)) 1618 1616 if not G2gd.GetPatternTreeItemId(self,self.root,'Covariance'): 1619 1617 sub = self.PatternTree.AppendItem(parent=self.root,text='Covariance') -
trunk/GSASIIgrid.py
r1138 r1143 141 141 142 142 VERY_LIGHT_GREY = wx.Colour(235,235,235) 143 143 DefaultControls = { 144 'deriv type':'analytic Hessian', #default controls 145 'min dM/M':0.0001,'shift factor':1.,'max cyc':3,'F**2':True, 146 'minF/sig':0, 147 'Author':'no name', 148 'FreeVar1':'Sample humidity (%)', 149 'FreeVar2':'Sample voltage (V)', 150 'FreeVar3':'Applied load (MN)', 151 } 144 152 ################################################################################ 145 153 #### GSAS-II class definitions … … 314 322 else: 315 323 self.invalid = True 316 wx.TextCtrl.SetValue(self,str( val))324 wx.TextCtrl.SetValue(self,str(G2py3.FormatValue(val))) 317 325 else: 318 326 wx.TextCtrl.SetValue(self,str(val)) … … 397 405 if not self.evaluated: return # true when an expression is evaluated 398 406 if self.result is not None: # retrieve the stored result 399 val = self.result[self.key] 400 self.SetValue(G2py3.FormatValue(val)) 407 self.SetValue(self.result[self.key]) 401 408 self.evaluated = False # expression has been recast as value, reset flag 402 409 … … 716 723 self.dct[self.item] = self.values[0] # unknown 717 724 725 ################################################################################ 726 class G2CheckBox(wx.CheckBox): 727 '''A customized version of a CheckBox that automatically initializes 728 the control to match a supplied 729 730 :param wx.Panel parent: name of panel or frame that will be 731 the parent to the TextCtrl. Can be None. 732 :param str label: text to put on check button 733 :param dict/list loc: the dict or list with the initial value to be 734 placed in the CheckBox. 735 :param int/str key: the dict key or the list index for the value to be 736 edited by the CheckBox. The ``loc[key]`` element must exist. 737 The CheckBox will be initialized from this value. 738 If the value is anything other that True (or 1), it will be taken as 739 False. 740 ''' 741 def __init__(self,parent,label,loc,key): 742 wx.CheckBox.__init__(self,parent,id=wx.ID_ANY,label=label) 743 self.loc = loc 744 self.key = key 745 self.SetValue(self.loc[self.key]==True) 746 self.Bind(wx.EVT_CHECKBOX, self._OnCheckBox) 747 def _OnCheckBox(self,event): 748 self.loc[self.key] = self.GetValue() 718 749 ################################################################################ 719 750 def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[], … … 2881 2912 if 'Author' not in data: 2882 2913 data['Author'] = 'no name' 2914 if 'FreePrm1' not in data: 2915 data['FreePrm1'] = 'Sample humidity (%)' 2916 if 'FreePrm2' not in data: 2917 data['FreePrm2'] = 'Sample voltage (V)' 2918 if 'FreePrm3' not in data: 2919 data['FreePrm3'] = 'Applied load (MN)' 2883 2920 #end patch 2884 2921 … … 3085 3122 3086 3123 def GetSampleParms(): 3087 sampleParmDict = {'Temperature':[],'Pressure':[],'Humidity':[],'Voltage':[],'Force':[],} 3124 sampleParmDict = {'Temperature':300.,'Pressure':1., 3125 'FreePrm1':0.,'FreePrm2':0.,'FreePrm3':0.,} 3088 3126 sampleParm = {} 3089 3127 for name in histNames: … … 3513 3551 data = G2frame.PatternTree.GetItemPyData(item) 3514 3552 if not data: #fill in defaults 3515 data = { 3516 #least squares controls 3517 'deriv type':'analytic Hessian','min dM/M':0.0001,'shift factor':1.0,'max cyc':3} 3553 data = copy.copy(DefaultControls) #least squares controls 3518 3554 G2frame.PatternTree.SetItemPyData(item,data) 3519 3555 for i in G2frame.Refine: i.Enable(True) … … 3668 3704 if 'Temperature' not in data: #temp fix for old gpx files 3669 3705 data = {'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False],'DisplaceX':[0.0,False], 3670 'DisplaceY':[0.0,False],'Diffuse':[],'Temperature':300.,'Pressure':1.0,'Humidity':0.0,'Voltage':0.0, 3671 'Force':0.0,'Gonio. radius':200.0} 3706 'DisplaceY':[0.0,False],'Diffuse':[],'Temperature':300.,'Pressure':1.0, 3707 'FreePrm1':0.,'FreePrm2':0.,'FreePrm3':0., 3708 'Gonio. radius':200.0} 3672 3709 G2frame.PatternTree.SetItemPyData(item,data) 3673 3710 -
trunk/GSASIImapvars.py
r1138 r1143 83 83 A list of parameters that will be varied is specified as input to GenerateConstraints 84 84 (varyList). A fixed parameter will simply be removed from this list preventing that 85 parameter from being varied. Note that all parameters in a relationship must specified as 86 varied (appear in varyList) or none can be varied. This is checked in GenerateConstraints 87 (as well as for generated relationships in SetVaryFlags). 88 89 * If all parameters in a parameter redefinition (new var) relationship are varied, the 90 parameter assigned to this expression (::constr:n, see paramPrefix) newly generated 91 parameter is varied. Note that any generated "missing" relations are not varied. Only 92 the input relations are varied. 85 parameter from being varied. Note that all parameters in a constraint relationship 86 must specified as varied (appear in varyList) or none can be varied. This is 87 checked in GenerateConstraints (as well as for generated relationships in SetVaryFlags). 88 89 * When a new variable is created, the variable is assigned the name associated 90 in the constraint definition or it is assigned a default name of form 91 ``::constr<n>`` (see paramPrefix). The vary setting for variables used in the 92 constraint are ignored. 93 Note that any generated "missing" relations are not varied. Only 94 the input relations can be are varied. 93 95 94 96 * If all parameters in a fixed constraint equation are varied, the generated "missing" … … 221 223 222 224 # prefix for parameter names 223 paramPrefix = "::constr ;"225 paramPrefix = "::constr" 224 226 consNum = 0 # number of the next constraint to be created 225 227 … … 235 237 fixedVarList = [] 236 238 239 def VarKeys(constr): 240 """Finds the keys in a constraint that represent variables 241 e.g. eliminates any that start with '_' 242 243 :param dict constr: a single constraint entry of form:: 244 245 {'var1': mult1, 'var2': mult2,... '_notVar': val,...} 246 247 (see :func:`GroupConstraints`) 248 :returns: a list of keys where any keys beginning with '_' are 249 removed. 250 """ 251 return [i for i in constr.keys() if not i.startswith('_')] 252 253 237 254 def GroupConstraints(constrDict): 238 255 """divide the constraints into groups that share no parameters. … … 244 261 constrDict = [{<constr1>}, {<constr2>}, ...] 245 262 246 where {<constr1>} is {' param1': mult1, 'param2': mult2,...}263 where {<constr1>} is {'var1': mult1, 'var2': mult2,... } 247 264 248 265 :returns: two lists of lists: … … 261 278 grouplist = [i,] 262 279 assignedlist.append(i) 263 groupset = set( consi.keys())280 groupset = set(VarKeys(consi)) 264 281 changes = True # always loop at least once 265 282 while(changes): # loop until we can't find anything to add to the current group … … 267 284 for j,consj in enumerate(constrDict): 268 285 if j in assignedlist: continue # already in a group, skip 269 if len(set( consj.keys()) & groupset) > 0: # true if this needs to be added286 if len(set(VarKeys(consj)) & groupset) > 0: # true if this needs to be added 270 287 changes = True 271 288 grouplist.append(j) 272 289 assignedlist.append(j) 273 groupset = groupset | set( consj.keys())290 groupset = groupset | set(VarKeys(consj)) 274 291 group = sorted(grouplist) 275 292 varlist = sorted(list(groupset)) … … 302 319 If there are no errors, both strings will be empty 303 320 ''' 321 import re 304 322 global dependentParmList,arrayList,invarrayList,indParmList,consNum 305 323 errmsg = '' 306 324 warnmsg = '' 307 325 fixVlist = [] 308 # process fixed (held) variables326 # process fixed variables (holds) 309 327 for cdict in constrDict: 328 # N.B. No "_" names in holds 310 329 if len(cdict) == 1: 311 330 fixVlist.append(cdict.keys()[0]) … … 389 408 for group,varlist in zip(groups,parmlist): 390 409 if len(varlist) == 1: continue 391 VaryFree = False392 410 for rel in group: 393 411 varied = 0 394 412 notvaried = '' 395 413 for var in constrDict[rel]: 414 if var.startswith('_'): continue 415 if not re.match('[0-9]*:[0-9]*:',var): 416 warnmsg += "\nVariable "+str(var)+" does not begin with a ':'" 396 417 if var in varyList: 397 418 varied += 1 … … 402 423 errmsg += '\nParameter '+var+" is Fixed and used in a constraint:\n\t" 403 424 errmsg += _FormatConstraint(constrDict[rel],fixedList[rel])+"\n" 404 if varied > 0 and varied != len( constrDict[rel]):425 if varied > 0 and varied != len(VarKeys(constrDict[rel])): 405 426 warnmsg += "\nNot all variables refined in constraint:\n\t" 406 427 warnmsg += _FormatConstraint(constrDict[rel],fixedList[rel]) … … 453 474 rel = group.pop(0) 454 475 fixedval = fixedList[rel] 455 for var in constrDict[rel]:476 for var in VarKeys(constrDict[rel]): 456 477 if var in varyList: 457 478 varied += 1 … … 462 483 fixedval = None 463 484 if fixedval is None: 464 varname = paramPrefix + str(consNum) 485 varname = paramPrefix + str(consNum) # assign a name to a variable 465 486 mapvar.append(varname) 466 487 consNum += 1 467 if VaryFree or varied > 0:468 varyList.append(varname)469 488 else: 470 489 mapvar.append(fixedval) … … 593 612 # scan through parameters in each relationship. Are all varied? If only some are 594 613 # varied, create an error message. 595 # If all are varied and this is a constraint equation, then set VaryFree flag596 # so that newly created relationships will be varied597 614 for group,varlist in zip(groups,parmlist): 598 615 if len(varlist) == 1: continue 599 VaryFree = False600 616 for rel in group: 601 617 varied = 0 602 618 notvaried = '' 603 619 for var in constrDict[rel]: 620 if var.startswith('_'): continue 604 621 if var in varyList: 605 622 varied += 1 … … 610 627 msg += '\nError: parameter '+var+" is Fixed and used in a constraint:\n\t" 611 628 msg += _FormatConstraint(constrDict[rel],fixedList[rel])+"\n" 612 if varied > 0 and varied != len( constrDict[rel]):629 if varied > 0 and varied != len(VarKeys(constrDict[rel])): 613 630 msg += "\nNot all variables refined in constraint:\n\t" 614 631 msg += _FormatConstraint(constrDict[rel],fixedList[rel]) 615 632 msg += '\nNot refined: ' + notvaried + '\n' 616 if fixedList[rel] is not None and varied > 0:617 VaryFree = True618 633 # if there were errors found, go no farther 619 634 if msg: … … 624 639 # now process each group and create the relations that are needed to form 625 640 # non-singular square matrix 641 # If all are varied and this is a constraint equation, then set VaryFree flag 642 # so that the newly created relationships will be varied 626 643 for group,varlist in zip(groups,parmlist): 627 644 if len(varlist) == 1: continue 645 # for constraints, if all included variables are refined, 646 # set the VaryFree flag, and remaining degrees of freedom will be 647 # varied (since consistency was checked, if any one variable is 648 # refined, then assume that all are) 649 varsList = [] # make a list of all the referenced variables as well 650 VaryFree = False 651 for rel in group: 652 varied = 0 653 for var in VarKeys(constrDict[rel]): 654 if var not in varsList: varsList.append(var) 655 if var in varyList: varied += 1 656 if fixedList[rel] is not None and varied > 0: 657 VaryFree = True 628 658 if len(varlist) < len(group): # too many relationships -- no can do 629 659 msg = 'too many relationships' 660 break 661 # fill in additional degrees of freedom 630 662 try: 631 663 arr = _FillArray(group,constrDict,varlist) … … 635 667 except: 636 668 msg = 'Singular relationships' 637 669 break 638 670 mapvar = [] 639 671 group = group[:] 640 # scan through all generated and input variables,add to the varied list672 # scan through all generated and input relationships, we need to add to the varied list 641 673 # all the new parameters where VaryFree has been set or where all the 642 674 # dependent parameters are varied. Check again for inconsistent variable use … … 645 677 # it does not hurt to check again. 646 678 for i in range(len(varlist)): 647 varied = 0648 notvaried = ''649 679 if len(group) > 0: # get the original equation reference 650 680 rel = group.pop(0) 651 if debug:652 print rel653 print fixedList[rel]654 print constrDict[rel]655 681 fixedval = fixedList[rel] 656 for var in constrDict[rel]: 657 if var in varyList: 658 varied += 1 659 else: 660 if notvaried: notvaried += ', ' 661 notvaried += var 662 else: 682 varyflag = constrDict[rel].get('_vary',False) 683 varname = constrDict[rel].get('_name','') 684 else: # relationship has been generated 685 varyflag = False 686 varname = '' 663 687 fixedval = None 664 if fixedval is None: 665 varname = paramPrefix + str(consNum) 688 if fixedval is None: # this is a new variable, not a constraint 689 if not varname: 690 varname = paramPrefix + str(consNum) # no assigned name, create one 691 consNum += 1 666 692 mapvar.append(varname) 667 consNum += 1 668 if VaryFree or varied > 0: 693 # vary the new relationship if it is a degree of freedom in 694 # a set of contraint equations or if a new variable is flagged to be varied. 695 if VaryFree or varyflag: 669 696 varyList.append(varname) 697 # fix (prevent varying) of all the variables inside the constraint group 698 for var in varsList: 699 if var in varyList: varyList.remove(var) 670 700 else: 671 701 mapvar.append(fixedval) 672 if varied > 0 and notvaried != '':673 msg += "\nNot all variables refined in generated constraint\n\t"674 msg += '\nNot refined: ' + notvaried + '\n'675 702 dependentParmList.append(varlist) 676 703 arrayList.append(constrArr) … … 692 719 print 50*'-' 693 720 print VarRemapShow(varyList) 721 print 'Varied: ',varyList 722 print 'Not Varied: ',fixedVarList 694 723 695 724 def StoreEquivalence(independentVar,dependentList): … … 815 844 s = [""] 816 845 for var,val in RelDict.items(): 846 if var.startswith('_'): continue 817 847 if len(s[-1]) > linelen: s.append(' ') 818 848 m = val -
trunk/GSASIIpwdGUI.py
r1107 r1143 63 63 def SetDefaultSample(): 64 64 'Needs a doc string' 65 return {'ranId':ran.randint(0,sys.maxint), 65 return { 66 'ranId':ran.randint(0,sys.maxint), 66 67 'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False], 67 68 'DisplaceX':[0.0,False],'DisplaceY':[0.0,False],'Diffuse':[], 68 'Temperature':300.,'Pressure':1.0,'Humidity':0.0, 69 'Voltage':0.0,'Force':0.0,'Gonio. radius':200.0, 70 'Omega':0.0,'Chi':0.0,'Phi':0.0} 69 'Temperature':300.,'Pressure':1.0, 70 'FreePrm1':0.,'FreePrm2':0.,'FreePrm3':0., 71 'Gonio. radius':200.0, 72 'Omega':0.0,'Chi':0.0,'Phi':0.0 73 } 71 74 72 75 ################################################################################ … … 1239 1242 dlg.Destroy() 1240 1243 1244 def OnScaleRef(event): 1245 Obj = event.GetEventObject() 1246 data['Scale'][1] = Obj.GetValue() 1247 1248 def OnScaleVal(event): 1249 Obj = event.GetEventObject() 1250 try: 1251 scale = float(Obj.GetValue()) 1252 if scale > 0: 1253 data['Scale'][0] = scale 1254 except ValueError: 1255 pass 1256 Obj.SetValue("%.4f"%(data['Scale'][0])) #reset in case of error 1257 1258 def OnHistoType(event): 1259 Obj = event.GetEventObject() 1260 data['Type'] = Obj.GetValue() 1261 if data['Type'] == 'Bragg-Brentano' and 'Shift' not in data: #set up defaults for new type(s) 1262 data['Shift'] = [0.0,False] 1263 data['Transparency'] = [0.0,False] 1264 wx.CallAfter(UpdateSampleGrid,G2frame,data) 1265 1266 def SetNameVal(): 1267 inst = instNameVal.GetValue() 1268 data['InstrName'] = inst.strip() 1269 1270 def OnNameVal(event): 1271 event.Skip() 1272 wx.CallAfter(SetNameVal) 1273 1274 ######## DEBUG ####################################################### 1275 #import GSASIIpwdGUI 1276 #reload(GSASIIpwdGUI) 1277 #reload(G2gd) 1278 ###################################################################### 1241 1279 if G2frame.dataDisplay: 1242 1280 G2frame.dataFrame.Clear() … … 1250 1288 Status = G2frame.dataFrame.CreateStatusBar() 1251 1289 G2frame.dataDisplay = wx.Panel(G2frame.dataFrame) 1252 1290 Controls = G2frame.PatternTree.GetItemPyData( 1291 G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls')) 1253 1292 #patch 1254 1293 if 'ranId' not in data: … … 1258 1297 if not 'Omega' in data: 1259 1298 data.update({'Omega':0.0,'Chi':0.0,'Phi':0.0}) 1299 if type(data['Temperature']) is int: 1300 data['Temperature'] = float(data['Temperature']) 1301 if 'FreePrm1' not in Controls: 1302 Controls['FreePrm1'] = 'Sample humidity (%)' 1303 if 'FreePrm2' not in Controls: 1304 Controls['FreePrm2'] = 'Sample voltage (V)' 1305 if 'FreePrm3' not in Controls: 1306 Controls['FreePrm3'] = 'Applied load (MN)' 1307 if 'FreePrm1' not in data: 1308 data['FreePrm1'] = 0. 1309 if 'FreePrm2' not in data: 1310 data['FreePrm2'] = 0. 1311 if 'FreePrm3' not in data: 1312 data['FreePrm3'] = 0. 1260 1313 #patch end 1261 1314 1262 parms = [['Gonio. radius',' Goniometer radius(mm): ','%.2f',]] 1315 parms = [] 1316 parms.append(['Scale','Histogram scale factor: ']) 1317 parms.append(['Gonio. radius','Goniometer radius (mm): ']) 1263 1318 if data['Type'] == 'Debye-Scherrer': 1264 parms += [['DisplaceX',u' Sample X displ. perp. to beam (\xb5m): ','%.2f',],1265 ['DisplaceY',u' Sample Y displ. || to beam (\xb5m): ','%.2f',],1266 ['Absorption',u' Sample absorption(\xb5r): ','%.4f',],]1319 parms += [['DisplaceX',u'Sample X displ. perp. to beam (\xb5m): '], 1320 ['DisplaceY',u'Sample Y displ. || to beam (\xb5m): '], 1321 ['Absorption',u'Sample absorption (\xb5\xb7r): '],] 1267 1322 elif data['Type'] == 'Bragg-Brentano': 1268 parms += [['Shift',u' Sample displacement(\xb5m): ','%.2f',], 1269 ['Transparency',u' Sample transparency(1/\xb5eff,cm): ','%.4f'],] 1270 parms.append(['Omega','Goniometer omega:','%.2f']) 1271 parms.append(['Chi','Goniometer chi:','%.2f']) 1272 parms.append(['Phi','Goniometer phi:','%.2f']) 1273 parms.append(['Temperature',' Sample temperature(K): ','%.2f']) 1274 parms.append(['Pressure',' Sample pressure(MPa): ','%.3f']) 1275 parms.append(['Humidity',' Sample humidity(%): ','%.1f']) 1276 parms.append(['Voltage',' Sample voltage(V): ','%.3f']) 1277 parms.append(['Force',' Applied load(MN): ','%.3f']) 1278 objList = {} 1279 1280 def OnScaleRef(event): 1281 Obj = event.GetEventObject() 1282 data['Scale'][1] = Obj.GetValue() 1283 1284 def OnScaleVal(event): 1285 Obj = event.GetEventObject() 1286 try: 1287 scale = float(Obj.GetValue()) 1288 if scale > 0: 1289 data['Scale'][0] = scale 1290 except ValueError: 1291 pass 1292 Obj.SetValue("%.4f"%(data['Scale'][0])) #reset in case of error 1293 1294 def OnHistoType(event): 1295 Obj = event.GetEventObject() 1296 data['Type'] = Obj.GetValue() 1297 if data['Type'] == 'Bragg-Brentano' and 'Shift' not in data: #set up defaults for new type(s) 1298 data['Shift'] = [0.0,False] 1299 data['Transparency'] = [0.0,False] 1300 wx.CallAfter(UpdateSampleGrid,G2frame,data) 1301 1302 def OnParmRef(event): 1303 Obj = event.GetEventObject() 1304 parm = objList[Obj.GetId()] 1305 data[parm][1] = Obj.GetValue() 1306 1307 def OnParmVal(event): 1308 Obj = event.GetEventObject() 1309 parm = objList[Obj.GetId()] 1310 try: 1311 if 'list' in str(type(data[parm[0]])): 1312 data[parm[0]][0] = float(Obj.GetValue()) 1313 else: 1314 data[parm[0]] = float(Obj.GetValue()) 1315 except ValueError: 1316 pass 1317 if 'list' in str(type(data[parm[0]])): 1318 Obj.SetValue(parm[2]%(data[parm[0]][0])) #reset in case of error 1319 else: 1320 Obj.SetValue(parm[2]%(data[parm[0]])) #reset in case of error 1321 1322 def SetNameVal(): 1323 inst = instNameVal.GetValue() 1324 data['InstrName'] = inst.strip() 1325 1326 def OnNameVal(event): 1327 event.Skip() 1328 wx.CallAfter(SetNameVal) 1323 parms += [['Shift',u'Sample displacement(\xb5m): '], 1324 ['Transparency',u'Sample transparency(1/\xb5eff, cm): '],] 1325 parms.append(['Omega','Goniometer omega:',]) 1326 parms.append(['Chi','Goniometer chi:',]) 1327 parms.append(['Phi','Goniometer phi:',]) 1328 parms.append(['Temperature','Sample temperature (K): ',]) 1329 parms.append(['Pressure','Sample pressure (MPa): ',]) 1329 1330 1330 1331 mainSizer = wx.BoxSizer(wx.VERTICAL) 1331 1332 topSizer = wx.BoxSizer(wx.HORIZONTAL) 1332 1333 topSizer.Add((-1,-1),1,wx.EXPAND,1) 1333 topSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' 1334 topSizer.Add(wx.StaticText(G2frame.dataDisplay,label='Sample and Experimental Parameters')) 1334 1335 topSizer.Add((-1,-1),1,wx.EXPAND,1) 1335 1336 mainSizer.Add(topSizer,0,wx.EXPAND,1) 1336 1337 nameSizer = wx.BoxSizer(wx.HORIZONTAL) 1337 nameSizer.Add(wx.StaticText(G2frame.dataDisplay,wx.ID_ANY,' Instrument Name'),1338 nameSizer.Add(wx.StaticText(G2frame.dataDisplay,wx.ID_ANY,' Instrument Name'), 1338 1339 0,wx.ALIGN_CENTER_VERTICAL) 1339 1340 nameSizer.Add((-1,-1),1,wx.EXPAND,1) … … 1343 1344 instNameVal.Bind(wx.EVT_CHAR,OnNameVal) 1344 1345 mainSizer.Add(nameSizer,0,wx.EXPAND,1) 1345 mainSizer.Add(( 0,5),0)1346 mainSizer.Add((5,5),0) 1346 1347 1347 mainSizer.Add((5,5),0) 1348 parmSizer = wx.FlexGridSizer(10,2,5,0) 1349 scaleRef = wx.CheckBox(G2frame.dataDisplay,label=' Histogram scale factor: ') 1350 scaleRef.SetValue(data['Scale'][1]) 1351 scaleRef.Bind(wx.EVT_CHECKBOX, OnScaleRef) 1352 parmSizer.Add(scaleRef,0,wx.ALIGN_CENTER_VERTICAL) 1353 scaleVal = wx.TextCtrl(G2frame.dataDisplay,wx.ID_ANY, 1354 '%.4f'%(data['Scale'][0]),style=wx.TE_PROCESS_ENTER) 1355 scaleVal.Bind(wx.EVT_TEXT_ENTER,OnScaleVal) 1356 scaleVal.Bind(wx.EVT_KILL_FOCUS,OnScaleVal) 1357 parmSizer.Add(scaleVal,0,wx.ALIGN_CENTER_VERTICAL) 1358 typeSizer = wx.BoxSizer(wx.HORIZONTAL) 1348 nameSizer = wx.BoxSizer(wx.HORIZONTAL) 1349 nameSizer.Add(wx.StaticText(G2frame.dataDisplay,wx.ID_ANY,' Diffractometer type: '), 1350 0,wx.ALIGN_CENTER_VERTICAL) 1359 1351 choices = ['Debye-Scherrer','Bragg-Brentano',] 1360 1352 histoType = wx.ComboBox(G2frame.dataDisplay,wx.ID_ANY,value=data['Type'],choices=choices, 1361 1353 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1362 1354 histoType.Bind(wx.EVT_COMBOBOX, OnHistoType) 1363 parmSizer.Add(histoType) 1364 parmSizer.Add((5,5),0) 1365 1366 for parm in parms: 1367 if 'list' in str(type(data[parm[0]])): 1368 parmRef = wx.CheckBox(G2frame.dataDisplay,label=parm[1]) 1369 objList[parmRef.GetId()] = parm[0] 1370 parmRef.SetValue(data[parm[0]][1]) 1371 parmRef.Bind(wx.EVT_CHECKBOX, OnParmRef) 1372 parmSizer.Add(parmRef,0,wx.ALIGN_CENTER_VERTICAL) 1373 parmVal = wx.TextCtrl(G2frame.dataDisplay,wx.ID_ANY, 1374 parm[2]%(data[parm[0]][0]),style=wx.TE_PROCESS_ENTER) 1355 nameSizer.Add(histoType) 1356 mainSizer.Add(nameSizer,0,wx.EXPAND,1) 1357 mainSizer.Add((5,5),0) 1358 1359 parmSizer = wx.FlexGridSizer(10,2,5,0) 1360 for key,lbl in parms: 1361 if 'list' in str(type(data[key])): 1362 parmRef = G2gd.G2CheckBox(G2frame.dataDisplay,' '+lbl,data[key],1) 1363 parmSizer.Add(parmRef,0,wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) 1364 parmVal = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,data[key],0,typeHint=float) 1375 1365 else: 1376 parmSizer.Add(wx.StaticText(G2frame.dataDisplay,label=parm[1]), 1377 0,wx.ALIGN_CENTER_VERTICAL) 1378 parmVal = wx.TextCtrl(G2frame.dataDisplay,wx.ID_ANY, 1379 parm[2]%(data[parm[0]]),style=wx.TE_PROCESS_ENTER) 1380 objList[parmVal.GetId()] = parm 1381 parmVal.Bind(wx.EVT_TEXT_ENTER,OnParmVal) 1382 parmVal.Bind(wx.EVT_KILL_FOCUS,OnParmVal) 1366 parmSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' '+lbl), 1367 0,wx.ALIGN_CENTER_VERTICAL|wx.EXPAND) 1368 parmVal = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,data,key,typeHint=float) 1383 1369 parmSizer.Add(parmVal,1,wx.EXPAND) 1384 mainSizer.Add(parmSizer) 1370 for key in ('FreePrm1','FreePrm2','FreePrm3'): 1371 parmVal = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,Controls,key,typeHint=str, 1372 notBlank=False) 1373 parmSizer.Add(parmVal,1,wx.EXPAND) 1374 parmVal = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,data,key,typeHint=float) 1375 parmSizer.Add(parmVal,1,wx.EXPAND) 1376 mainSizer.Add(parmSizer,1,wx.EXPAND) 1385 1377 mainSizer.Add((0,5),0) 1386 1378 -
trunk/GSASIIstrIO.py
r1141 r1143 48 48 :return: dictionary of control items 49 49 ''' 50 Controls = {'deriv type':'analytic Hessian','max cyc':3,'max Hprocess':1, 51 'max Rprocess':1,'min dM/M':0.0001,'shift factor':1.} 50 Controls = copy.copy(G2.DefaultControls) 52 51 fl = open(GPXfile,'rb') 53 52 while True: … … 123 122 D = {} 124 123 varyFlag = item[-2] 125 name = item[-3]124 varname = item[-3] 126 125 for term in item[:-3]: 127 126 var = str(term[1]) … … 130 129 if len(D) > 1: 131 130 # add extra dict terms for input variable name and vary flag 132 #ifname is not None:133 # D['_name'] =name134 #D['_vary'] = varyFlag == True # force to bool131 if varname is not None: 132 D['_name'] = varname 133 D['_vary'] = varyFlag == True # force to bool 135 134 constDict.append(D) 136 135 else: -
trunk/GSASIIstrMain.py
r1141 r1143 92 92 try: 93 93 groups,parmlist = G2mv.GroupConstraints(constrDict) 94 #G2mv.debug = True # DEBUG95 94 G2mv.GenerateConstraints(groups,parmlist,varyList,constrDict,fixedList) 96 #G2mv.debug = False # DEBUG97 95 except: 98 96 print ' *** ERROR - your constraints are internally inconsistent ***' … … 101 99 if warnmsg: print 'Warnings',warnmsg 102 100 raise Exception(' *** Refine aborted ***') 103 #raise Exception(' *** Refine DEBUG ***') # DEBUG104 101 # # check to see which generated parameters are fully varied 105 102 # msg = G2mv.SetVaryFlags(varyList)
Note: See TracChangeset
for help on using the changeset viewer.