Changeset 1160
- Timestamp:
- Nov 28, 2013 9:16:02 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1147 r1160 2603 2603 def MakeLSParmDict(self): 2604 2604 '''Load all parameters used for computation from the tree into a 2605 dict 2605 dict of paired values [value, refine flag]. Note that this is 2606 different than the parmDict used in the refinement, which only has 2607 values. 2606 2608 2607 2609 :returns: (parmDict,varyList) where: … … 2646 2648 ''' 2647 2649 parmDict,varyList = self.MakeLSParmDict() 2648 dlg = G2gd.ShowLSParms(self,'Least Squares Parameters',parmDict,varyList) 2650 parmValDict = {} 2651 for i in parmDict: 2652 parmValDict[i] = parmDict[i][0] 2653 2654 reqVaryList = tuple(varyList) # save requested variables 2655 try: 2656 # process constraints 2657 sub = G2gd.GetPatternTreeItemId(self,self.root,'Constraints') 2658 Constraints = self.PatternTree.GetItemPyData(sub) 2659 constList = [] 2660 for item in Constraints: 2661 if item.startswith('_'): continue 2662 constList += Constraints[item] 2663 G2mv.InitVars() 2664 constrDict,fixedList,ignored = G2stIO.ProcessConstraints(constList) 2665 groups,parmlist = G2mv.GroupConstraints(constrDict) 2666 G2mv.GenerateConstraints(groups,parmlist,varyList,constrDict,fixedList) 2667 G2mv.Map2Dict(parmValDict,varyList) 2668 except: 2669 pass 2670 dlg = G2gd.ShowLSParms(self,'Least Squares Parameters',parmValDict,varyList,reqVaryList) 2649 2671 dlg.ShowModal() 2650 2672 dlg.Destroy() -
trunk/GSASIIIO.py
r1157 r1160 2018 2018 constList = [] 2019 2019 for item in consDict: 2020 if item.startswith('_'): continue 2020 2021 constList += consDict[item] 2021 2022 # now process the constraints -
trunk/GSASIIconstrGUI.py
r1147 r1160 511 511 ''' 512 512 allcons = [] 513 for key in ['Hist','HAP','Phase','Global']: 513 for key in data: 514 if key.startswith('_'): continue 514 515 allcons += data[key] 515 516 allcons += newcons … … 538 539 ''' 539 540 allcons = [] 540 for key in 'Hist','HAP','Phase': 541 for key in data: 542 if key.startswith('_'): continue 541 543 allcons += data[key] 542 544 if not len(allcons): return True … … 675 677 :returns: wx.Sizer created by method 676 678 ''' 677 constSizer = wx.FlexGridSizer(1, 5,0,0)679 constSizer = wx.FlexGridSizer(1,6,0,0) 678 680 maxlen = 70 # characters before wrapping a constraint 679 681 for Id,item in enumerate(data[name]): 682 refineflag = False 680 683 helptext = "" 681 684 eqString = ['',] … … 693 696 Indx[constEdit.GetId()] = [Id,name] 694 697 if item[-1] == 'f': 695 helptext = "A new variable is created from a linear combination of the following variables:" 698 helptext = "A new variable" 699 if item[-3]: 700 helptext += " named "+str(item[-3]) 701 helptext += " is created from a linear combination of the following variables:\n" 696 702 for term in item[:-3]: 697 703 var = str(term[1]) … … 712 718 helptext += '\n\n' 713 719 helptext += data['_Explain'][item[-3]] 714 typeString = 'NEWVAR' 720 # typeString = 'NEWVAR' 721 # if item[-3]: 722 # eqString[-1] += ' = '+item[-3] 723 # else: 724 # eqString[-1] += ' = New Variable' 715 725 if item[-3]: 716 eqString[-1] += ' = '+item[-3]726 typeString = item[-3] + ' = ' 717 727 else: 718 eqString[-1] += ' = New Variable' 728 typeString = 'New Variable = ' 729 #print 'refine',item[-2] 730 refineflag = True 719 731 elif item[-1] == 'c': 720 732 helptext = "The following variables constrained to equal a constant:" … … 732 744 helptext += "\n" + var + " ("+ varMean + ")" 733 745 typeString = 'CONST' 734 eqString[-1] += ' = %.3f'%(item[-3])+' '746 eqString[-1] += ' = '+str(item[-3]) 735 747 elif item[-1] == 'e': 736 748 helptext = "The following variables are set to be equivalent, noting multipliers:" … … 763 775 constSizer.Add(ch,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER,1) 764 776 else: 777 constSizer.Add((-1,-1)) 778 if refineflag: 779 ch = G2gd.G2CheckBox(pageDisplay,'',item,-2) 780 constSizer.Add(ch,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER,1) 781 else: 765 782 constSizer.Add((-1,-1)) 766 constSizer.Add(wx.StaticText(pageDisplay,-1,typeString),0,wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER|wx.RIGHT|wx.LEFT,3) 783 constSizer.Add(wx.StaticText(pageDisplay,-1,typeString), 784 0,wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER|wx.RIGHT|wx.LEFT,3) 767 785 if len(eqString) > 1: 768 786 Eq = wx.BoxSizer(wx.VERTICAL) … … 815 833 result = dlg.GetData() 816 834 for i in range(len(data[name][Id][:-3])): 835 if type(data[name][Id][i]) is tuple: # fix non-mutable construct 836 data[name][Id][i] = list(data[name][Id][i]) 817 837 data[name][Id][i][0] = result[i][0] 818 838 if data[name][Id][-1] == 'c': … … 825 845 varname = varname.replace(':',';') 826 846 if varname: 827 data[name][Id][-3] = '::' +varname847 data[name][Id][-3] = varname 828 848 else: 829 849 data[name][Id][-3] = '' … … 925 945 # validate all the constrants -- should not see any errors here normally 926 946 allcons = [] 927 for key in 'Hist','HAP','Phase': 947 for key in data: 948 if key.startswith('_'): continue 928 949 allcons += data[key] 929 950 if not len(allcons): return -
trunk/GSASIIgrid.py
r1147 r1160 1567 1567 '''Create frame to show least-squares parameters 1568 1568 ''' 1569 def __init__(self,parent,title,parmDict,varyList =None,1569 def __init__(self,parent,title,parmDict,varyList,fullVaryList, 1570 1570 size=(300,430)): 1571 1571 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=size, … … 1577 1577 #size=size, 1578 1578 style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) 1579 if varyList: 1580 num = len(varyList) 1581 mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number of refined variables: '+str(num))) 1579 num = len(varyList) 1580 mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number of refined variables: '+str(num))) 1581 num = len(fullVaryList) 1582 mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number dependent and refined variables: '+str(num))) 1582 1583 1583 1584 subSizer = wx.FlexGridSizer(rows=len(parmDict)+1,cols=4,hgap=2,vgap=2) 1584 1585 parmNames = parmDict.keys() 1585 1586 parmNames.sort() 1586 #parmText = ' p:h:Parameter refine? value\n'1587 1587 subSizer.Add((-1,-1)) 1588 1588 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'Parameter name ')) 1589 1589 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'refine?')) 1590 1590 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'value'),0,wx.ALIGN_RIGHT) 1591 explainRefine = False 1591 1592 for name in parmNames: 1593 # skip entries without numerical values 1594 if isinstance(parmDict[name],basestring): continue 1595 try: 1596 value = G2py3.FormatValue(parmDict[name]) 1597 except TypeError: 1598 value = str(parmDict[name])+' -?' # unexpected 1599 #continue 1592 1600 v = G2obj.getVarDescr(name) 1593 1601 if v is None or v[-1] is None: … … 1597 1605 subSizer.Add(ch,0,wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER,1) 1598 1606 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(name))) 1599 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(parmDict[name][1]))) 1600 try: 1601 value = G2py3.FormatValue(parmDict[name][0]) 1602 except TypeError: 1603 value = str(parmDict[name][0]) 1607 if name in varyList: 1608 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'R')) 1609 elif name in fullVaryList: 1610 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'C')) 1611 explainRefine = True 1612 else: 1613 subSizer.Add((-1,-1)) 1604 1614 subSizer.Add(wx.StaticText(panel,wx.ID_ANY,value),0,wx.ALIGN_RIGHT) 1605 1615 … … 1610 1620 mainSizer.Add(panel,1, wx.ALL|wx.EXPAND,1) 1611 1621 1622 if explainRefine: 1623 mainSizer.Add( 1624 wx.StaticText(self,wx.ID_ANY, 1625 '"R" indicates a refined variable\n'+ 1626 '"C" is generated from a constraint' 1627 ), 1628 0, wx.ALL,0) 1612 1629 # make OK button 1613 1630 btnsizer = wx.BoxSizer(wx.HORIZONTAL) … … 1618 1635 # Allow window to be enlarged but not made smaller 1619 1636 self.SetSizer(mainSizer) 1620 #mainSizer.Fit(self)1621 1637 self.SetMinSize(self.GetSize()) 1622 1638 … … 1974 1990 self.msg=msg 1975 1991 self.parent = parent 1992 def _onClose(self,event): 1993 self.dlg.EndModal(wx.ID_CANCEL) 1976 1994 def _onPress(self,event): 1977 1995 'Respond to a button press by displaying the requested text' 1978 dlg = wx.MessageDialog(self.parent,self.msg,'Help info',wx.OK) 1979 dlg.ShowModal() 1980 dlg.Destroy() 1996 #dlg = wx.MessageDialog(self.parent,self.msg,'Help info',wx.OK) 1997 self.dlg = wx.Dialog(self.parent,wx.ID_ANY,'Help information', 1998 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 1999 #self.dlg.SetBackgroundColour(wx.WHITE) 2000 mainSizer = wx.BoxSizer(wx.VERTICAL) 2001 txt = wx.StaticText(self.dlg,wx.ID_ANY,self.msg) 2002 mainSizer.Add(txt,1,wx.ALL|wx.EXPAND,10) 2003 txt.SetBackgroundColour(wx.WHITE) 2004 2005 btnsizer = wx.BoxSizer(wx.HORIZONTAL) 2006 btn = wx.Button(self.dlg, wx.ID_CLOSE) 2007 btn.Bind(wx.EVT_BUTTON,self._onClose) 2008 btnsizer.Add(btn) 2009 mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) 2010 self.dlg.SetSizer(mainSizer) 2011 mainSizer.Fit(self.dlg) 2012 self.dlg.ShowModal() 2013 self.dlg.Destroy() 1981 2014 ################################################################################ 1982 2015 class MyHtmlPanel(wx.Panel): … … 2496 2529 self.AtomCompute.ISOcalc = self.AtomCompute.Append( 2497 2530 id=wxID_ISODISP, kind=wx.ITEM_NORMAL, 2498 text='Compute ISODIS PLACEmode values',2499 help='Compute values of ISODIS PLACEmodes from atom parameters')2531 text='Compute ISODISTORT mode values', 2532 help='Compute values of ISODISTORT modes from atom parameters') 2500 2533 self.PostfillDataMenu() 2501 2534 -
trunk/GSASIImapvars.py
r1143 r1160 551 551 for varlist,mapvars,multarr,invmultarr in zip( 552 552 dependentParmList,indParmList,arrayList,invarrayList): 553 if multarr is None: 553 if multarr is None: # do only if an equivalence 554 554 zeromult = False 555 555 for mv in mapvars: … … 638 638 639 639 # now process each group and create the relations that are needed to form 640 # non-singular square matrix640 # a non-singular square matrix 641 641 # If all are varied and this is a constraint equation, then set VaryFree flag 642 642 # so that the newly created relationships will be varied … … 671 671 group = group[:] 672 672 # scan through all generated and input relationships, we need to add to the varied list 673 # all the new parameters where VaryFree has been set or where all the 674 # dependent parameters are varied. Check again for inconsistent variable use 675 # for new variables -- where varied and unvaried parameters get grouped 676 # together. I don't think this can happen when not flagged before, but 677 # it does not hurt to check again. 673 # all the new parameters where VaryFree has been set or where a New Var is varied. 674 # 675 # If a group does not contain any fixed values (constraint equations) 676 # and nothing in the group is varied, drop this group, so that the 677 # dependent parameters can be refined individually. 678 unused = True 678 679 for i in range(len(varlist)): 679 680 if len(group) > 0: # get the original equation reference … … 682 683 varyflag = constrDict[rel].get('_vary',False) 683 684 varname = constrDict[rel].get('_name','') 684 else: # relationship has been generated685 else: # this relationship has been generated 685 686 varyflag = False 686 687 varname = '' … … 692 693 mapvar.append(varname) 693 694 # vary the new relationship if it is a degree of freedom in 694 # a set of contraint equations or if a new variableis flagged to be varied.695 # a set of contraint equations or if a New Var is flagged to be varied. 695 696 if VaryFree or varyflag: 697 unused = False 696 698 varyList.append(varname) 697 699 # fix (prevent varying) of all the variables inside the constraint group 700 # (dependent vars) 698 701 for var in varsList: 699 702 if var in varyList: varyList.remove(var) 700 703 else: 704 unused = False 701 705 mapvar.append(fixedval) 706 if unused: continue # skip over constraints that do not have a fixed value or a refined variable 702 707 dependentParmList.append(varlist) 703 708 arrayList.append(constrArr) -
trunk/GSASIIphsGUI.py
r1150 r1160 1634 1634 '''Compute the ISODISTORT mode values from the current coordinates. 1635 1635 Called in response to the (Phase/Atoms tab) AtomCompute 1636 "Compute ISODIS PLACEmode values" menu item, which should be enabled1636 "Compute ISODISTORT mode values" menu item, which should be enabled 1637 1637 only when Phase['ISODISTORT'] is defined. 1638 1638 ''' … … 1665 1665 deltaList.append(cval-pval) 1666 1666 modeVals = np.inner(ISO['Var2ModeMatrix'],deltaList) 1667 dlg = wx.Dialog(G2frame,wx.ID_ANY,'ISODIS PLACEmode values',#size=(630,400),1667 dlg = wx.Dialog(G2frame,wx.ID_ANY,'ISODISTORT mode values',#size=(630,400), 1668 1668 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 1669 1669 mainSizer = wx.BoxSizer(wx.VERTICAL) -
trunk/GSASIIstrIO.py
r1145 r1160 68 68 and :func:`GSASIIstrMain.SeqRefine`. 69 69 ''' 70 constList = []71 70 fl = open(GPXfile,'rb') 72 71 while True: … … 77 76 datum = data[0] 78 77 if datum[0] == 'Constraints': 79 constDict = datum[1] 80 for item in constDict: 81 constList += constDict[item] 78 constList = [] 79 for item in datum[1]: 80 if item.startswith('_'): continue 81 constList += datum[1][item] 82 fl.close() 83 constDict,fixedList,ignored = ProcessConstraints(constList) 84 if ignored: 85 print ignored,'Constraints were rejected. Was a constrained phase, histogram or atom deleted?' 86 return constDict,fixedList 82 87 fl.close() 83 constDict,fixedList,ignored = ProcessConstraints(constList) 84 if ignored: 85 print ignored,'Constraints were rejected. Was a constrained phase, histogram or atom deleted?' 86 return constDict,fixedList 88 raise Exception,"No constraints in GPX file" 87 89 88 90 def ProcessConstraints(constList): … … 101 103 102 104 * constDict (list of dicts) contains the constraint relationships 103 * fixedList (list) contains the fixed values for type105 * fixedList (list) contains the fixed values for each type 104 106 of constraint. 105 107 * ignored (int) counts the number of invalid constraint items … … 130 132 if len(D) > 1: 131 133 # add extra dict terms for input variable name and vary flag 132 if varname is not None: 133 D['_name'] = varname 134 if varname is not None: 135 if varname.startswith('::'): 136 varname = varname[2:].replace(':',';') 137 else: 138 varname = varname.replace(':',';') 139 D['_name'] = '::' + varname 134 140 D['_vary'] = varyFlag == True # force to bool 135 141 constDict.append(D) -
trunk/imports/G2phase_ISO.py
r1147 r1160 22 22 def __init__(self): 23 23 super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__ 24 extensionlist=('.CIF','.cif' ),24 extensionlist=('.CIF','.cif','.txt'), 25 25 strictExtension=False, 26 26 formatName = 'ISODISTORT CIF', … … 199 199 self.Phase['General']['Name'] = name.strip()[:20] 200 200 #---------------------------------------------------------------------- 201 # now read in the ISODIS PLACEmodes201 # now read in the ISODISTORT modes 202 202 #---------------------------------------------------------------------- 203 203 modelist = [] … … 298 298 for j,(lbl,k) in enumerate(zip(coordVarLbl,row)): 299 299 if k == 0: continue 300 constraint.append( (k,G2varObj[j]))300 constraint.append([k,G2varObj[j]]) 301 301 constraint += [shortmodelist[i],False,'f'] 302 302 self.Constraints.append(constraint) … … 314 314 explaination = {} 315 315 for mode,shortmode in zip(modelist,shortmodelist): 316 explaination[shortmode] = "I soDisplacefull name "+str(mode)316 explaination[shortmode] = "ISODISTORT full name "+str(mode) 317 317 self.Constraints.append(explaination) 318 318 … … 328 328 # print 70*'=' 329 329 330 # # debug: Get the ISODIS PLACEoffset values330 # # debug: Get the ISODISTORT offset values 331 331 # coordVarDelta = {} 332 332 # for lbl,val in zip(
Note: See TracChangeset
for help on using the changeset viewer.