Changeset 1143


Ignore:
Timestamp:
Nov 10, 2013 8:32:26 PM (8 years ago)
Author:
toby
Message:

rework constraints to handle names and refine flag for new var (input linear constraints); redo powder 'Sample Parameters'

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1141 r1143  
    16131613        if not G2gd.GetPatternTreeItemId(self,self.root,'Controls'):
    16141614            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))
    16181616        if not G2gd.GetPatternTreeItemId(self,self.root,'Covariance'):
    16191617            sub = self.PatternTree.AppendItem(parent=self.root,text='Covariance')
  • trunk/GSASIIgrid.py

    r1138 r1143  
    141141
    142142VERY_LIGHT_GREY = wx.Colour(235,235,235)
    143 
     143DefaultControls = {
     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    }
    144152################################################################################
    145153#### GSAS-II class definitions
     
    314322                else:
    315323                    self.invalid = True
    316             wx.TextCtrl.SetValue(self,str(val))
     324            wx.TextCtrl.SetValue(self,str(G2py3.FormatValue(val)))
    317325        else:
    318326            wx.TextCtrl.SetValue(self,str(val))
     
    397405        if not self.evaluated: return # true when an expression is evaluated
    398406        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])
    401408        self.evaluated = False # expression has been recast as value, reset flag
    402409       
     
    716723            self.dct[self.item] = self.values[0] # unknown
    717724
     725################################################################################
     726class 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()
    718749################################################################################   
    719750def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[],
     
    28812912    if 'Author' not in data:
    28822913        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)'
    28832920    #end patch
    28842921
     
    30853122       
    30863123    def GetSampleParms():
    3087         sampleParmDict = {'Temperature':[],'Pressure':[],'Humidity':[],'Voltage':[],'Force':[],}
     3124        sampleParmDict = {'Temperature':300.,'Pressure':1.,
     3125                          'FreePrm1':0.,'FreePrm2':0.,'FreePrm3':0.,}
    30883126        sampleParm = {}
    30893127        for name in histNames:
     
    35133551            data = G2frame.PatternTree.GetItemPyData(item)
    35143552            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
    35183554                G2frame.PatternTree.SetItemPyData(item,data)                             
    35193555            for i in G2frame.Refine: i.Enable(True)
     
    36683704        if 'Temperature' not in data:           #temp fix for old gpx files
    36693705            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}
    36723709            G2frame.PatternTree.SetItemPyData(item,data)
    36733710   
  • trunk/GSASIImapvars.py

    r1138 r1143  
    8383A list of parameters that will be varied is specified as input to GenerateConstraints
    8484(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.
     85parameter from being varied. Note that all parameters in a constraint relationship
     86must specified as varied (appear in varyList) or none can be varied. This is
     87checked 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.
    9395 
    9496* If all parameters in a fixed constraint equation are varied, the generated "missing"
     
    221223
    222224# prefix for parameter names
    223 paramPrefix = "::constr;"
     225paramPrefix = "::constr"
    224226consNum = 0 # number of the next constraint to be created
    225227
     
    235237    fixedVarList = []
    236238
     239def 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
    237254def GroupConstraints(constrDict):
    238255    """divide the constraints into groups that share no parameters.
     
    244261       constrDict = [{<constr1>}, {<constr2>}, ...]
    245262
    246     where {<constr1>} is {'param1': mult1, 'param2': mult2,...}
     263    where {<constr1>} is {'var1': mult1, 'var2': mult2,... }
    247264
    248265    :returns: two lists of lists:
     
    261278        grouplist = [i,]
    262279        assignedlist.append(i)
    263         groupset = set(consi.keys())
     280        groupset = set(VarKeys(consi))
    264281        changes = True # always loop at least once
    265282        while(changes): # loop until we can't find anything to add to the current group
     
    267284            for j,consj in enumerate(constrDict):
    268285                if j in assignedlist: continue # already in a group, skip
    269                 if len(set(consj.keys()) & groupset) > 0: # true if this needs to be added
     286                if len(set(VarKeys(consj)) & groupset) > 0: # true if this needs to be added
    270287                    changes = True
    271288                    grouplist.append(j)
    272289                    assignedlist.append(j)
    273                     groupset = groupset | set(consj.keys())
     290                    groupset = groupset | set(VarKeys(consj))
    274291        group = sorted(grouplist)
    275292        varlist = sorted(list(groupset))
     
    302319      If there are no errors, both strings will be empty
    303320    '''
     321    import re
    304322    global dependentParmList,arrayList,invarrayList,indParmList,consNum
    305323    errmsg = ''
    306324    warnmsg = ''
    307325    fixVlist = []
    308     # process fixed (held) variables
     326    # process fixed variables (holds)
    309327    for cdict in constrDict:
     328        # N.B. No "_" names in holds
    310329        if len(cdict) == 1:
    311330            fixVlist.append(cdict.keys()[0])
     
    389408    for group,varlist in zip(groups,parmlist):
    390409        if len(varlist) == 1: continue
    391         VaryFree = False
    392410        for rel in group:
    393411            varied = 0
    394412            notvaried = ''
    395413            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 ':'"
    396417                if var in varyList:
    397418                    varied += 1
     
    402423                    errmsg += '\nParameter '+var+" is Fixed and used in a constraint:\n\t"
    403424                    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])):
    405426                warnmsg += "\nNot all variables refined in constraint:\n\t"
    406427                warnmsg += _FormatConstraint(constrDict[rel],fixedList[rel])
     
    453474                rel = group.pop(0)
    454475                fixedval = fixedList[rel]
    455                 for var in constrDict[rel]:
     476                for var in VarKeys(constrDict[rel]):
    456477                    if var in varyList:
    457478                        varied += 1
     
    462483                fixedval = None
    463484            if fixedval is None:
    464                 varname = paramPrefix + str(consNum)
     485                varname = paramPrefix + str(consNum) # assign a name to a variable
    465486                mapvar.append(varname)
    466487                consNum += 1
    467                 if VaryFree or varied > 0:
    468                     varyList.append(varname)
    469488            else:
    470489                mapvar.append(fixedval)
     
    593612    # scan through parameters in each relationship. Are all varied? If only some are
    594613    # varied, create an error message.
    595     # If all are varied and this is a constraint equation, then set VaryFree flag
    596     # so that newly created relationships will be varied
    597614    for group,varlist in zip(groups,parmlist):
    598615        if len(varlist) == 1: continue
    599         VaryFree = False
    600616        for rel in group:
    601617            varied = 0
    602618            notvaried = ''
    603619            for var in constrDict[rel]:
     620                if var.startswith('_'): continue
    604621                if var in varyList:
    605622                    varied += 1
     
    610627                    msg += '\nError: parameter '+var+" is Fixed and used in a constraint:\n\t"
    611628                    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])):
    613630                msg += "\nNot all variables refined in constraint:\n\t"
    614631                msg += _FormatConstraint(constrDict[rel],fixedList[rel])
    615632                msg += '\nNot refined: ' + notvaried + '\n'
    616             if fixedList[rel] is not None and varied > 0:
    617                 VaryFree = True
    618633    # if there were errors found, go no farther
    619634    if msg:
     
    624639    # now process each group and create the relations that are needed to form
    625640    # 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
    626643    for group,varlist in zip(groups,parmlist):
    627644        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
    628658        if len(varlist) < len(group): # too many relationships -- no can do
    629659            msg = 'too many relationships'
     660            break
     661        # fill in additional degrees of freedom
    630662        try:
    631663            arr = _FillArray(group,constrDict,varlist)
     
    635667        except:
    636668            msg = 'Singular relationships'
    637 
     669            break
    638670        mapvar = []
    639671        group = group[:]
    640         # scan through all generated and input variables, add to the varied list
     672        # scan through all generated and input relationships, we need to add to the varied list
    641673        # all the new parameters where VaryFree has been set or where all the
    642674        # dependent parameters are varied. Check again for inconsistent variable use
     
    645677        # it does not hurt to check again.
    646678        for i in range(len(varlist)):
    647             varied = 0
    648             notvaried = ''
    649679            if len(group) > 0: # get the original equation reference
    650680                rel = group.pop(0)
    651                 if debug:
    652                     print rel
    653                     print fixedList[rel]
    654                     print constrDict[rel]
    655681                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 = ''
    663687                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
    666692                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:
    669696                    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)
    670700            else:
    671701                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'
    675702        dependentParmList.append(varlist)
    676703        arrayList.append(constrArr)
     
    692719        print 50*'-'
    693720        print VarRemapShow(varyList)
     721        print 'Varied: ',varyList
     722        print 'Not Varied: ',fixedVarList
    694723
    695724def StoreEquivalence(independentVar,dependentList):
     
    815844    s = [""]
    816845    for var,val in RelDict.items():
     846        if var.startswith('_'): continue
    817847        if len(s[-1]) > linelen: s.append(' ')
    818848        m = val
  • trunk/GSASIIpwdGUI.py

    r1107 r1143  
    6363def SetDefaultSample():
    6464    'Needs a doc string'
    65     return {'ranId':ran.randint(0,sys.maxint),
     65    return {
     66        'ranId':ran.randint(0,sys.maxint),
    6667        'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False],
    6768        '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        }
    7174                         
    7275################################################################################
     
    12391242            dlg.Destroy()
    12401243
     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    ######################################################################
    12411279    if G2frame.dataDisplay:
    12421280        G2frame.dataFrame.Clear()
     
    12501288        Status = G2frame.dataFrame.CreateStatusBar()   
    12511289    G2frame.dataDisplay = wx.Panel(G2frame.dataFrame)
    1252 
     1290    Controls = G2frame.PatternTree.GetItemPyData(
     1291        G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls'))
    12531292#patch
    12541293    if 'ranId' not in data:
     
    12581297    if not 'Omega' in data:
    12591298        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.
    12601313#patch end
    12611314   
    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): '])
    12631318    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): '],]
    12671322    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): ',])
    13291330               
    13301331    mainSizer = wx.BoxSizer(wx.VERTICAL)
    13311332    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    13321333    topSizer.Add((-1,-1),1,wx.EXPAND,1)
    1333     topSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Sample and Experimental Parameters'))
     1334    topSizer.Add(wx.StaticText(G2frame.dataDisplay,label='Sample and Experimental Parameters'))
    13341335    topSizer.Add((-1,-1),1,wx.EXPAND,1)
    13351336    mainSizer.Add(topSizer,0,wx.EXPAND,1)
    13361337    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'),
    13381339                0,wx.ALIGN_CENTER_VERTICAL)
    13391340    nameSizer.Add((-1,-1),1,wx.EXPAND,1)
     
    13431344    instNameVal.Bind(wx.EVT_CHAR,OnNameVal)
    13441345    mainSizer.Add(nameSizer,0,wx.EXPAND,1)
    1345     mainSizer.Add((0,5),0)
     1346    mainSizer.Add((5,5),0)
    13461347
    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)
    13591351    choices = ['Debye-Scherrer','Bragg-Brentano',]
    13601352    histoType = wx.ComboBox(G2frame.dataDisplay,wx.ID_ANY,value=data['Type'],choices=choices,
    13611353        style=wx.CB_READONLY|wx.CB_DROPDOWN)
    13621354    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)
    13751365        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)
    13831369        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)
    13851377    mainSizer.Add((0,5),0)   
    13861378   
  • trunk/GSASIIstrIO.py

    r1141 r1143  
    4848    :return: dictionary of control items
    4949    '''
    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)
    5251    fl = open(GPXfile,'rb')
    5352    while True:
     
    123122            D = {}
    124123            varyFlag = item[-2]
    125             name = item[-3]
     124            varname = item[-3]
    126125            for term in item[:-3]:
    127126                var = str(term[1])
     
    130129            if len(D) > 1:
    131130                # add extra dict terms for input variable name and vary flag
    132                 #if name is not None:
    133                 #    D['_name'] = name
    134                 #D['_vary'] = varyFlag == True # force to bool
     131                if varname is not None:
     132                    D['_name'] = varname
     133                D['_vary'] = varyFlag == True # force to bool
    135134                constDict.append(D)
    136135            else:
  • trunk/GSASIIstrMain.py

    r1141 r1143  
    9292    try:
    9393        groups,parmlist = G2mv.GroupConstraints(constrDict)
    94         #G2mv.debug = True # DEBUG
    9594        G2mv.GenerateConstraints(groups,parmlist,varyList,constrDict,fixedList)
    96         #G2mv.debug = False # DEBUG
    9795    except:
    9896        print ' *** ERROR - your constraints are internally inconsistent ***'
     
    10199        if warnmsg: print 'Warnings',warnmsg
    102100        raise Exception(' *** Refine aborted ***')
    103     #raise Exception(' *** Refine DEBUG ***') # DEBUG
    104101    # # check to see which generated parameters are fully varied
    105102    # msg = G2mv.SetVaryFlags(varyList)
Note: See TracChangeset for help on using the changeset viewer.