Changeset 408
- Timestamp:
- Nov 7, 2011 3:13:29 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIgrid.py
r407 r408 58 58 ] = [wx.NewId() for _init_coll_Back_Items in range(1)] 59 59 60 [ wxID_LIMITCOPY, 61 ] = [wx.NewId() for _init_coll_Limit_Items in range(1)] 62 60 63 [ wxID_SAMPLECOPY, 61 64 ] = [wx.NewId() for _init_coll_Sample_Items in range(1)] 62 65 63 [ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD, 64 ] = [wx.NewId() for _init_coll_Constraint_Items in range( 3)]66 [ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD, 67 ] = [wx.NewId() for _init_coll_Constraint_Items in range(4)] 65 68 66 69 [ wxID_RESTRAINTADD, … … 109 112 def _init_coll_BackMenu(self,parent): 110 113 parent.Append(menu=self.BackEdit, title='File') 114 115 def _init_coll_LimitMenu(self,parent): 116 parent.Append(menu=self.LimitEdit, title='File') 111 117 112 118 def _init_coll_InstMenu(self,parent): … … 155 161 156 162 def _init_coll_Constraint_Items(self,parent): 163 parent.Append(id=wxID_HOLDADD, kind=wx.ITEM_NORMAL,text='Add hold', 164 help='Add hold on a parameter value') 165 parent.Append(id=wxID_EQUIVADD, kind=wx.ITEM_NORMAL,text='Add equivalence', 166 help='Add equivalence between parameter values') 157 167 parent.Append(id=wxID_CONSTRAINTADD, kind=wx.ITEM_NORMAL,text='Add constraint', 158 168 help='Add constraint on parameter values') 159 parent.Append(id=wxID_EQUIVADD, kind=wx.ITEM_NORMAL,text='Add equivalence', 160 help='Add equivalence between parameter values') 161 parent.Append(id=wxID_HOLDADD, kind=wx.ITEM_NORMAL,text='Add hold', 162 help='Add hold on a parameter value') 169 parent.Append(id=wxID_FUNCTADD, kind=wx.ITEM_NORMAL,text='Add function', 170 help='Add function of parameter values') 163 171 164 172 def _init_coll_Restraint_Items(self,parent): … … 173 181 parent.Append(id=wxID_BACKCOPY, kind=wx.ITEM_NORMAL,text='Copy', 174 182 help='Copy background parameters to other histograms') 183 184 def _init_coll_Limit_Items(self,parent): 185 parent.Append(id=wxID_LIMITCOPY, kind=wx.ITEM_NORMAL,text='Copy', 186 help='Copy limits to other histograms') 175 187 176 188 def _init_coll_Data_Items(self,parent): … … 243 255 parent.Append(help='Load image controls from file', 244 256 id=wxID_IMLOADCONTROLS, kind=wx.ITEM_NORMAL,text='Load Controls') 245 246 257 247 258 def _init_coll_Mask_Items(self,parent): … … 313 324 self.MaskMenu = wx.MenuBar() 314 325 self.BackMenu = wx.MenuBar() 326 self.LimitMenu = wx.MenuBar() 315 327 self.InstMenu = wx.MenuBar() 316 328 self.SampleMenu = wx.MenuBar() … … 330 342 self.MaskEdit = wx.Menu(title='') 331 343 self.BackEdit = wx.Menu(title='') 344 self.LimitEdit = wx.Menu(title='') 332 345 self.InstEdit = wx.Menu(title='') 333 346 self.SampleEdit = wx.Menu(title='') … … 357 370 self._init_coll_BackMenu(self.BackMenu) 358 371 self._init_coll_Back_Items(self.BackEdit) 372 self._init_coll_LimitMenu(self.LimitMenu) 373 self._init_coll_Limit_Items(self.LimitEdit) 359 374 self._init_coll_InstMenu(self.InstMenu) 360 375 self._init_coll_Inst_Items(self.InstEdit) … … 767 782 data.update({'Hist':[],'HAP':[],'Phase':[]}) #empty dict - fill it 768 783 Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree() 784 AtomDict = dict([Phases[phase]['pId'],Phases[phase]['Atoms']] for phase in Phases) 769 785 Natoms,phaseVary,phaseDict,pawleyLookup,FFtable = G2str.GetPhaseData(Phases,Print=False) 770 786 phaseList = [] … … 773 789 phaseList.append(item) 774 790 phaseList.sort() 791 phaseAtNames = {} 792 for item in phaseList: 793 Split = item.split(':') 794 if Split[2][:2] in ['AU','Af','dA']: 795 phaseAtNames[item] = AtomDict[int(Split[0])][int(Split[3])][0] 796 else: 797 phaseAtNames[item] = '' 798 775 799 hapVary,hapDict,controlDict = G2str.GetHistogramPhaseData(Phases,Histograms,Print=False) 776 800 hapList = hapDict.keys() … … 811 835 return outList 812 836 813 def SelectVarbs( FrstVarb,varList,legend,constType):837 def SelectVarbs(page,FrstVarb,varList,legend,constType): 814 838 #future - add 'all:all:name', '0:all:name', etc. to the varList 815 dlg = wx.MultiChoiceDialog(self,'Select more variables:'+legend,FrstVarb+' and:',varList) 839 if page[1] == 'phs': 840 atchoice = [item+' for '+phaseAtNames[item] for item in varList] 841 dlg = wx.MultiChoiceDialog(self,'Select more variables:'+legend,FrstVarb+' and:',atchoice) 842 else: 843 dlg = wx.MultiChoiceDialog(self,'Select more variables:'+legend,FrstVarb+' and:',varList) 816 844 varbs = [FrstVarb,] 817 845 if dlg.ShowModal() == wx.ID_OK: … … 821 849 dlg.Destroy() 822 850 if len(varbs) > 1: 823 if 'equivalen ts' in constType:851 if 'equivalence' in constType: 824 852 constr = [] 825 853 for item in varbs[1:]: 826 # constr += [[{FrstVarb:1.0},{item:-1.0}, 0.0,False],]854 # constr += [[{FrstVarb:1.0},{item:-1.0},None,None],] 827 855 constr += [[[1.0,FrstVarb],[-1.0,item],None,None],] 828 return constr 829 else: 856 return constr #multiple constraints 857 elif 'function' in constType: 858 # constr = map(dict,zip(varbs,[1.0 for i in range(len(varbs))])) 859 constr = map(list,zip([1.0 for i in range(len(varbs))],varbs)) 860 return [constr+[0.0,False]] #just one constraint 861 else: #'constraint' 830 862 constr = map(list,zip([1.0 for i in range(len(varbs))],varbs)) 831 863 # constr = map(dict,zip(varbs,[1.0 for i in range(len(varbs))])) 832 return [constr+[0.0, False]]864 return [constr+[0.0,None]] #just one constraint 833 865 return [] 834 866 835 def OnAddEquivalence(event):836 constr = []837 page = self.Page838 choice = scope[page[1]]839 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2])840 if dlg.ShowModal() == wx.ID_OK:841 sel = dlg.GetSelection()842 FrstVarb = choice[2][sel]843 moreVarb = FindEquivVarb(FrstVarb,choice[2])844 constr = SelectVarbs(FrstVarb,moreVarb,choice[1],'equivalents')845 if len(constr) > 0:846 data[choice[3]] += constr847 dlg.Destroy()848 choice[4]()849 850 867 def OnAddHold(event): 851 868 for phase in Phases: … … 855 872 page = self.Page 856 873 choice = scope[page[1]] 857 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2]) 874 if page[1] == 'phs': 875 atchoice = [item+' for '+phaseAtNames[item] for item in choice[2]] 876 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],atchoice) 877 else: 878 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2]) 858 879 if dlg.ShowModal() == wx.ID_OK: 859 880 sel = dlg.GetSelection() 860 881 FrstVarb = choice[2][sel] 861 data[choice[3]] += [[[0.0,FrstVarb], 0.0,False],]882 data[choice[3]] += [[[0.0,FrstVarb],None,None],] 862 883 dlg.Destroy() 863 884 choice[4]() 864 885 886 def OnAddEquivalence(event): 887 constr = [] 888 page = self.Page 889 choice = scope[page[1]] 890 if page[1] == 'phs': 891 atchoice = [item+' for '+phaseAtNames[item] for item in choice[2]] 892 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],atchoice) 893 else: 894 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2]) 895 if dlg.ShowModal() == wx.ID_OK: 896 sel = dlg.GetSelection() 897 FrstVarb = choice[2][sel] 898 moreVarb = FindEquivVarb(FrstVarb,choice[2]) 899 constr = SelectVarbs(page,FrstVarb,moreVarb,choice[1],'equivalence') 900 if len(constr) > 0: 901 data[choice[3]] += constr 902 dlg.Destroy() 903 choice[4]() 904 905 def OnAddFunction(event): 906 constr = [] 907 page = self.Page 908 choice = scope[page[1]] 909 if page[1] == 'phs': 910 atchoice = [item+' for '+phaseAtNames[item] for item in choice[2]] 911 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],atchoice) 912 else: 913 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2]) 914 if dlg.ShowModal() == wx.ID_OK: 915 sel = dlg.GetSelection() 916 FrstVarb = choice[2][sel] 917 moreVarb = FindEquivVarb(FrstVarb,choice[2]) 918 constr = SelectVarbs(page,FrstVarb,moreVarb,choice[1],'function') 919 if len(constr) > 0: 920 data[choice[3]] += constr 921 dlg.Destroy() 922 choice[4]() 923 865 924 def OnAddConstraint(event): 866 925 constr = [] 867 926 page = self.Page 868 927 choice = scope[page[1]] 869 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2]) 928 if page[1] == 'phs': 929 atchoice = [item+' for '+phaseAtNames[item] for item in choice[2]] 930 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],atchoice) 931 else: 932 dlg = wx.SingleChoiceDialog(self,'Select 1st variable:'+choice[1],choice[0],choice[2]) 870 933 if dlg.ShowModal() == wx.ID_OK: 871 934 sel = dlg.GetSelection() 872 935 FrstVarb = choice[2][sel] 873 936 moreVarb = FindEquivVarb(FrstVarb,choice[2]) 874 constr = SelectVarbs( FrstVarb,moreVarb,choice[1],'')937 constr = SelectVarbs(page,FrstVarb,moreVarb,choice[1],'constraint') 875 938 if len(constr) > 0: 876 939 data[choice[3]] += constr … … 888 951 constSizer.Add(constDel) 889 952 eqString = ' FIXED '+item[0][1]+' ' 890 constSizer.Add((5,0),0) 953 constSizer.Add((5,0),0) 891 954 else: 892 955 constEdit = wx.Button(pageDisplay,-1,'Edit',style=wx.BU_EXACTFIT) … … 901 964 Indx[constRef.GetId()] = item 902 965 constSizer.Add(constRef,0,wx.ALIGN_CENTER_VERTICAL) 966 eqString = ' FUNCT ' 967 elif isinstance(item[-2],float): 968 constSizer.Add((5,5),0) 903 969 eqString = ' CONSTR ' 904 970 else: … … 927 993 Obj = event.GetEventObject() 928 994 Id,name = Indx[Obj.GetId()] 929 const = data[name][Id][-2] 930 if isinstance(data[name][Id][-2],float): 931 items = data[name][Id][:-2]+[[const,'= constant'],[]] 995 const = data[name][Id][-2] 996 if isinstance(data[name][Id][-1],bool): 997 items = data[name][Id][:-2]+[[],] 998 constType = 'Function' 999 extra = '; sum = new variable' 1000 elif isinstance(data[name][Id][-2],float): 1001 items = data[name][Id][:-2]+[[const,'= fixed value'],[]] 1002 constType = 'Constraint' 1003 extra = ' sum = constant' 932 1004 else: 933 1005 items = data[name][Id][:-2]+[[],] 934 dlg = self.SumDialog(self,'Constraint','Enter value for each term in constraint','',items) 1006 constType = 'Equivalence' 1007 extra = '; sum = 0' 1008 dlg = self.SumDialog(self,constType,'Enter value for each term in constraint'+extra,'',items) 935 1009 try: 936 1010 if dlg.ShowModal() == wx.ID_OK: … … 951 1025 HAPSizer.Add((5,5),0) 952 1026 HAPSizer.Add(ConstSizer('HAP',HAPDisplay)) 953 HAPSizer.Layout() 954 HAPDisplay.SetSizer(HAPSizer) 955 Size = HAPSizer.Fit(self.dataFrame) 956 Size[0] = max(450,Size[0]) 957 Size[1] += 26 #compensate for status bar 1027 HAPDisplay.SetSizer(HAPSizer,True) 1028 Size = HAPSizer.GetMinSize() 1029 Size[0] += 40 1030 Size[1] = max(Size[1],250) + 20 958 1031 HAPDisplay.SetSize(Size) 1032 HAPConstr.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1) 1033 Size[1] = min(Size[1],250) 959 1034 self.dataFrame.setSizePosLeft(Size) 960 1035 … … 965 1040 HistSizer.Add((5,5),0) 966 1041 HistSizer.Add(ConstSizer('Hist',HistDisplay)) 967 HistSizer.Layout() 968 HistDisplay.SetSizer(HistSizer) 969 Size = HistSizer.Fit(self.dataFrame) 970 Size[0] = max(450,Size[0]) 971 Size[1] += 26 #compensate for status bar 1042 HistDisplay.SetSizer(HistSizer,True) 1043 Size = HistSizer.GetMinSize() 1044 Size[0] += 40 1045 Size[1] = max(Size[1],250) + 20 972 1046 HistDisplay.SetSize(Size) 1047 HistConstr.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1) 1048 Size[1] = min(Size[1],250) 973 1049 self.dataFrame.setSizePosLeft(Size) 974 1050 … … 979 1055 PhaseSizer.Add((5,5),0) 980 1056 PhaseSizer.Add(ConstSizer('Phase',PhaseDisplay)) 981 PhaseSizer.Layout() 982 PhaseDisplay.SetSizer(PhaseSizer) 983 Size = PhaseSizer.Fit(self.dataFrame) 984 Size[1] += 26 #compensate for status bar 985 Size[0] = max(450,Size[0]) 1057 PhaseDisplay.SetSizer(PhaseSizer,True) 1058 Size = PhaseSizer.GetMinSize() 1059 Size[0] += 40 1060 Size[1] = max(Size[1],250) + 20 986 1061 PhaseDisplay.SetSize(Size) 1062 PhaseConstr.SetScrollbars(10,10,Size[0]/10-4,Size[1]/10-1) 1063 Size[1] = min(Size[1],250) 987 1064 self.dataFrame.setSizePosLeft(Size) 988 1065 … … 1017 1094 if not self.dataFrame.GetStatusBar(): 1018 1095 Status = self.dataFrame.CreateStatusBar() 1019 SetStatusLine(' NB: Set parameters to be varied first')1096 SetStatusLine('') 1020 1097 1021 1098 self.dataFrame.SetMenuBar(self.dataFrame.ConstraintMenu) 1022 1099 self.dataFrame.Bind(wx.EVT_MENU, OnAddConstraint, id=wxID_CONSTRAINTADD) 1100 self.dataFrame.Bind(wx.EVT_MENU, OnAddFunction, id=wxID_FUNCTADD) 1023 1101 self.dataFrame.Bind(wx.EVT_MENU, OnAddEquivalence, id=wxID_EQUIVADD) 1024 1102 self.dataFrame.Bind(wx.EVT_MENU, OnAddHold, id=wxID_HOLDADD) -
trunk/GSASIIpwdGUI.py
r406 r408 366 366 G2plt.PlotPatterns(self) 367 367 368 def OnLimitCopy(event): 369 histList = ['All',]+G2gd.GetPatternTreeDataNames(self,['PWDR',]) 370 copyList = [] 371 dlg = wx.MultiChoiceDialog(self, 372 'Copy limits to which histograms?', 'Copy limits', 373 histList, wx.CHOICEDLG_STYLE) 374 try: 375 if dlg.ShowModal() == wx.ID_OK: 376 result = dlg.GetSelections() 377 for i in result: 378 copyList.append(histList[i]) 379 if 'All' in copyList: 380 copyList = histList[1:] 381 for item in copyList: 382 Id = G2gd.GetPatternTreeItemId(self,self.root,item) 383 self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,Id,'Limits'), 384 copy.copy(data)) 385 finally: 386 dlg.Destroy() 387 368 388 self.LimitsTable = [] 369 389 colLabels = ['Tmin','Tmax'] … … 372 392 self.LimitsTable = G2gd.Table(data,rowLabels=rowLabels,colLabels=colLabels,types=Types) 373 393 self.dataFrame.SetLabel('Limits') 374 self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu) 394 self.dataFrame.SetMenuBar(self.dataFrame.LimitMenu) 395 if not self.dataFrame.GetStatusBar(): 396 Status = self.dataFrame.CreateStatusBar() 397 self.Bind(wx.EVT_MENU,OnLimitCopy,id=G2gd.wxID_LIMITCOPY) 375 398 self.dataDisplay = G2gd.GSGrid(parent=self.dataFrame) 376 399 self.dataDisplay.SetTable(self.LimitsTable, True) … … 378 401 self.dataDisplay.SetMargins(0,0) 379 402 self.dataDisplay.AutoSizeColumns(False) 380 self.dataFrame.setSizePosLeft([230,1 20])403 self.dataFrame.setSizePosLeft([230,160]) 381 404 382 405 def UpdateInstrumentGrid(self,data): -
trunk/GSASIIstruct.py
r407 r408 791 791 Atoms = Phase['Atoms'] 792 792 cell = General['Cell'] 793 textureData = General['SH Texture']794 793 pId = Phase['pId'] 795 794 pfx = str(pId)+'::' … … 866 865 atomsSig[str(i)+':'+str(ind)] = sigDict[names[ind]] 867 866 PrintAtomsAndSig(General,Atoms,atomsSig) 868 869 if textureData['Order']: 870 SHtextureSig = {} 871 for name in ['omega','chi','phi']: 872 aname = pfx+'SH '+name 873 textureData['Sample '+name][1] = parmDict[aname] 874 if aname in sigDict: 875 SHtextureSig['Sample '+name] = sigDict[aname] 876 for name in textureData['SH Coeff'][1]: 877 aname = pfx+name 878 textureData['SH Coeff'][1][name] = parmDict[aname] 879 if aname in sigDict: 880 SHtextureSig[name] = sigDict[aname] 881 PrintSHtextureAndSig(textureData,SHtextureSig) 867 868 if 'SH Texture' in General: 869 textureData = General['SH Texture'] 870 if textureData['Order']: 871 SHtextureSig = {} 872 for name in ['omega','chi','phi']: 873 aname = pfx+'SH '+name 874 textureData['Sample '+name][1] = parmDict[aname] 875 if aname in sigDict: 876 SHtextureSig['Sample '+name] = sigDict[aname] 877 for name in textureData['SH Coeff'][1]: 878 aname = pfx+name 879 textureData['SH Coeff'][1][name] = parmDict[aname] 880 if aname in sigDict: 881 SHtextureSig[name] = sigDict[aname] 882 PrintSHtextureAndSig(textureData,SHtextureSig) 882 883 883 884 def GetHistogramPhaseData(Phases,Histograms,Print=True):
Note: See TracChangeset
for help on using the changeset viewer.