Changeset 1287
- Timestamp:
- Apr 19, 2014 10:28:10 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASII.py ¶
r1283 r1287 3262 3262 self.G2plotNB.clear() 3263 3263 G2IO.ProjFileOpen(self) 3264 item, cookie = self.PatternTree.GetFirstChild(self.root) 3265 while item and not Id: 3266 name = self.PatternTree.GetItemText(item) 3267 if name[:4] in ['PWDR','HKLF']: 3268 Id = item 3269 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 3270 if Id: 3271 self.PatternTree.SelectItem(Id) 3264 # (BHT) what does this next section of code do? 3265 #item, cookie = self.PatternTree.GetFirstChild(self.root) 3266 #while item and not Id: 3267 # name = self.PatternTree.GetItemText(item) 3268 # if name[:4] in ['PWDR','HKLF']: 3269 # Id = item 3270 # item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 3271 #if Id: 3272 # self.PatternTree.SelectItem(Id) 3273 3274 # Open the sequential results tree entry 3275 Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results') 3276 self.PatternTree.SelectItem(Id) 3277 G2gd.MovePatternTreeToGrid(self,Id) 3278 3272 3279 finally: 3273 3280 dlg.Destroy() -
TabularUnified trunk/GSASIIgrid.py ¶
r1286 r1287 43 43 import GSASIIpy3 as G2py3 44 44 import GSASIIobj as G2obj 45 import GSASIIexprGUI as G2exG 45 46 46 47 # trig functions in degrees … … 134 135 135 136 [ wxID_SAVESEQSEL,wxID_SAVESEQSELCSV,wxID_PLOTSEQSEL, 136 ] = [wx.NewId() for item in range(3)] 137 wxADDSEQVAR,wxDELSEQVAR,wxEDITSEQVAR, 138 ] = [wx.NewId() for item in range(6)] 137 139 138 140 [ wxID_MODELCOPY,wxID_MODELFIT,wxID_MODELADD,wxID_ELEMENTADD,wxID_ELEMENTDELETE, … … 2461 2463 self.SequentialFile.Append(id=wxID_PLOTSEQSEL, kind=wx.ITEM_NORMAL,text='Plot selected', 2462 2464 help='Plot selected sequential refinement results') 2465 self.SequentialPvars = wx.Menu(title='') 2466 self.SequentialMenu.Append(menu=self.SequentialPvars, title='Pseudo Vars') 2467 self.SequentialPvars.Append( 2468 id=wxADDSEQVAR, kind=wx.ITEM_NORMAL,text='Add', 2469 help='Add a new pseudo-variable') 2470 self.SequentialPvars.Append( 2471 id=wxDELSEQVAR, kind=wx.ITEM_NORMAL,text='Delete', 2472 help='Delete an existing pseudo-variable') 2473 self.SequentialPvars.Append( 2474 id=wxEDITSEQVAR, kind=wx.ITEM_NORMAL,text='Edit', 2475 help='Edit an existing pseudo-variable') 2463 2476 self.PostfillDataMenu() 2464 2477 … … 2961 2974 2962 2975 def _init_ctrls(self, parent,name=None,size=None,pos=None): 2963 wx.Frame.__init__(self,parent=parent, 2964 style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX | wx.FRAME_FLOAT_ON_PARENT , 2976 wx.Frame.__init__( 2977 self,parent=parent, 2978 #style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX | wx.FRAME_FLOAT_ON_PARENT , 2979 style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX, 2965 2980 size=size,pos=pos,title='GSAS-II data display') 2966 2981 self._init_menus() … … 3487 3502 3488 3503 ################################################################################ 3489 ##### Sequential Results3504 ##### Display of Sequential Results 3490 3505 ################################################################################ 3491 3506 3492 def UpdateSeqResults(G2frame,data ):3507 def UpdateSeqResults(G2frame,data,prevSize=None): 3493 3508 """ 3494 3509 Called when the Sequential Results data tree entry is selected … … 3665 3680 ] 3666 3681 # cell labels 3667 cellUlbl = ('a','b','c',u'\u03B1',u'\u03B2',u'\u03 b3') # unicode a,b,c,alpha,beta,gamma3682 cellUlbl = ('a','b','c',u'\u03B1',u'\u03B2',u'\u03B3') # unicode a,b,c,alpha,beta,gamma 3668 3683 def striphist(var,insChar=''): 3669 3684 'strip a histogram number from a var name' … … 3676 3691 (u'\u03B1',r'$\alpha$'), 3677 3692 (u'\u03B2',r'$\beta$'), 3678 (u'\u03 b3',r'$\gamma$'),3693 (u'\u03B3',r'$\gamma$'), 3679 3694 (u'\u0394\u03C7',r'$\Delta\chi$'), 3680 3695 ]: … … 3699 3714 dlg.Destroy() 3700 3715 return col 3716 3717 def EnableSeqExpressionMenus(): 3718 'Enables or disables the PseudoVar menu items that require existing defs' 3719 if Controls['SeqPseudoVars']: 3720 val = True 3721 else: 3722 val = False 3723 G2frame.dataFrame.SequentialPvars.Enable(wxDELSEQVAR,val) 3724 G2frame.dataFrame.SequentialPvars.Enable(wxEDITSEQVAR,val) 3725 3726 def DelSeqExpression(event): 3727 'Ask the user to select expression to delete' 3728 choices = Controls['SeqPseudoVars'].keys() 3729 selected = ItemSelector( 3730 choices,G2frame.dataFrame, 3731 multiple=True, 3732 title='Select expressions to remove', 3733 header='Delete expression') 3734 for item in selected: 3735 del Controls['SeqPseudoVars'][choices[item]] 3736 if selected: 3737 UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize()) # redisplay variables 3738 3739 def EditSeqExpression(event): 3740 'Edit an existing expression' 3741 choices = Controls['SeqPseudoVars'].keys() 3742 selected = ItemSelector( 3743 choices,G2frame.dataFrame, 3744 multiple=False, 3745 title='Select an expression to edit', 3746 header='Edit expression') 3747 if selected is not None: 3748 dlg = G2exG.ExpressionDialog(G2frame.dataDisplay,parmDict, 3749 Controls['SeqPseudoVars'][choices[selected]], 3750 header='Edit this expression formula', 3751 fit=False) 3752 newobj = dlg.Show(True) 3753 if newobj: 3754 calcobj = G2obj.ExpressionCalcObj(newobj) 3755 del Controls['SeqPseudoVars'][choices[selected]] 3756 Controls['SeqPseudoVars'][calcobj.eObj.expression] = newobj 3757 UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize()) # redisplay variables 3758 3759 def AddNewSeqExpression(event): 3760 'Create a new expression' 3761 parmDict = dict(zip(colLabels,zip(*colList)[0])) 3762 dlg = G2exG.ExpressionDialog(G2frame.dataDisplay,parmDict, 3763 header='Enter an expression formula here', 3764 fit=False) 3765 obj = dlg.Show(True) 3766 dlg.Destroy() 3767 if obj: 3768 calcobj = G2obj.ExpressionCalcObj(obj) 3769 Controls['SeqPseudoVars'][calcobj.eObj.expression] = obj 3770 UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize()) # redisplay variables 3771 3701 3772 #====================================================================== 3702 3773 # start processing sequential results here … … 3704 3775 print 'No sequential refinement results' 3705 3776 return 3777 Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree() 3778 Controls = G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.root,'Controls')) 3779 if 'SeqPseudoVars' not in Controls: # create a place to store Pseudo Vars, if needed 3780 Controls['SeqPseudoVars'] = {} 3706 3781 histNames = data['histNames'] 3707 3782 if G2frame.dataDisplay: … … 3710 3785 Status = G2frame.dataFrame.CreateStatusBar() 3711 3786 Status.SetStatusText("Select column to export; Double click on column to plot data; on row for Covariance") 3787 sampleParms = GetSampleParms() 3712 3788 # make dict of varied atom coords keyed by absolute position 3713 3789 newAtomDict = data[histNames[0]]['newAtomDict'] # dict with atom positions; relative & absolute … … 3727 3803 3728 3804 # get unit cell & symmetry for all phases 3729 Phases = G2frame.GetPhaseData()3730 3805 Alist = {} 3731 3806 SGdata = {} … … 3747 3822 uniqCellParms[pId] = range(6) 3748 3823 3749 sampleParms = GetSampleParms()3750 3824 SetDataMenuBar(G2frame,G2frame.dataFrame.SequentialMenu) 3751 3825 G2frame.dataFrame.SetLabel('Sequential refinement results') … … 3754 3828 G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeqCSV, id=wxID_SAVESEQSELCSV) 3755 3829 G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlotSelSeq, id=wxID_PLOTSEQSEL) 3756 # build up the table one column at a time 3830 G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewSeqExpression, id=wxADDSEQVAR) 3831 G2frame.dataFrame.Bind(wx.EVT_MENU, DelSeqExpression, id=wxDELSEQVAR) 3832 G2frame.dataFrame.Bind(wx.EVT_MENU, EditSeqExpression, id=wxEDITSEQVAR) 3833 EnableSeqExpressionMenus() 3834 3835 # build up the data table one column at a time 3757 3836 colList = [] 3758 3837 colSigs = [] … … 3770 3849 colLabels += [u'\u0394\u03C7\u00B2 (%)'] 3771 3850 Types += [wg.GRID_VALUE_FLOAT,] 3851 deltaChiCol = len(colLabels)-1 3772 3852 3773 3853 # adds checkbox for converged (Bob wants to change color of previous instead) … … 3848 3928 for parm in atomList: 3849 3929 colList += [[data[name]['newAtomDict'][atomList[parm]][1] for name in histNames]] 3930 # add Pseudovars 3931 for exp in Controls['SeqPseudoVars']: 3932 obj = Controls['SeqPseudoVars'][exp] 3933 calcobj = G2obj.ExpressionCalcObj(obj) 3934 valList = [] 3935 for row in zip(*colList): 3936 parmDict = dict(zip(colLabels,row)) 3937 calcobj.SetupCalc(parmDict) 3938 valList.append(calcobj.EvalExpression()) 3939 colList += [valList] 3940 colSigs += [None] 3941 colLabels += [exp] 3942 Types += [wg.GRID_VALUE_FLOAT,] 3850 3943 3851 3944 rowList = [c for c in zip(*colList)] # convert from columns to rows … … 3865 3958 # G2frame.SeqTable = Table(seqList,colLabels=colLabels,rowLabels=histNames,types=Types 3866 3959 # ) 3960 3867 3961 G2frame.dataDisplay = GSGrid(parent=G2frame.dataFrame) 3962 # colSigs += [None] 3963 # colLabels += ['Cnvg'] 3964 # Types += [wg.GRID_VALUE_BOOL,] 3868 3965 G2frame.dataDisplay.SetTable(G2frame.SeqTable, True) 3869 3966 G2frame.dataDisplay.EnableEditing(False) … … 3872 3969 G2frame.dataDisplay.SetMargins(0,0) 3873 3970 G2frame.dataDisplay.AutoSizeColumns(True) 3874 G2frame.dataFrame.setSizePosLeft([700,350]) 3875 3971 if prevSize: 3972 G2frame.dataDisplay.SetSize(prevSize) 3973 else: 3974 G2frame.dataFrame.setSizePosLeft([700,350]) 3975 # highlight unconverged shifts 3976 for row,name in enumerate(histNames): 3977 if not data[name]['Rvals']['converged']: 3978 G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Color(255,255,0)) 3979 # colList += [[data[name]['Rvals']['converged'] for name in histNames]] 3980 3876 3981 ################################################################################ 3877 3982 ##### Main PWDR panel -
TabularUnified trunk/GSASIIobj.py ¶
r1282 r1287 1119 1119 ''' 1120 1120 1121 # special handling for parameter names without a colons 1122 # for now, assume self-defining 1123 if varname.find(':') == -1: 1124 return "Global",varname 1125 1121 1126 l = getVarDescr(varname) 1122 1127 if not l: 1123 return "invalid variable name ("+str(varname)+")!" 1128 #return ("invalid variable name ("+str(varname)+")!"),"" 1129 return "invalid variable name!","" 1124 1130 1125 1131 if not l[-1]: … … 1143 1149 hlbl = 'Hist='+hlbl 1144 1150 s = "Ph="+str(lbl)+" * "+str(hlbl) 1151 elif l[2] == 'Back': # background parameters are "special", alas 1152 s = 'Hist='+ShortHistNames.get(l[1],'? #'+str(l[1])) 1153 l[-1] += ' #'+str(l[3]) 1145 1154 elif l[4] is not None: # rigid body parameter 1146 1155 lbl = ShortPhaseNames.get(l[0],'phase?') … … 1222 1231 if reVarDesc: return # already done 1223 1232 for key,value in { 1233 # derived or other sequential vars 1234 '([abc])$' : 'Lattice parameter, \\1, from Ai and Djk', # N.B. '$' prevents match if any characters follow 1235 u'\u03B1' : u'Lattice parameter, \u03B1, from Ai and Djk', 1236 u'\u03B2' : u'Lattice parameter, \u03B2, from Ai and Djk', 1237 u'\u03B3' : u'Lattice parameter, \u03B3, from Ai and Djk', 1224 1238 # ambiguous, alas: 1225 1239 'Scale' : 'Phase or Histogram scale factor', … … 1233 1247 'Afrac': 'Atomic occupancy parameter', 1234 1248 # Hist & Phase (HAP) vars (p:h:<var>) 1249 'Back': 'Background term', 1250 'BkPkint;(.*)':'Background peak #\\1 intensity', 1251 'BkPkpos;(.*)':'Background peak #\\1 position', 1252 'BkPksig;(.*)':'Background peak #\\1 Gaussian width', 1253 'BkPkgam;(.*)':'Background peak #\\1 Cauchy width', 1235 1254 'Bab([AU])': 'Babinet solvent scattering coef. \\1', 1236 1255 'D([123][123])' : 'Anisotropic strain coef. \\1', … … 1258 1277 'RBR([TLS])([123AB][123AB])' : 'Residue rigid body group disp. param.', 1259 1278 # Global vars (::<var>) 1279 'constr([0-9]*)' : 'Parameter from constraint', 1260 1280 }.items(): 1261 1281 VarDesc[key] = value -
TabularUnified trunk/GSASIIstrIO.py ¶
r1253 r1287 516 516 if datum[0] == 'Sequential results': 517 517 data[0][1] = SeqResult 518 # reset the Copy Next flag, since it should not be needed twice in a row 519 if datum[0] == 'Controls': 520 data[0][1]['Copy2Next'] = False 518 521 try: 519 522 histogram = Histograms[datum[0]]
Note: See TracChangeset
for help on using the changeset viewer.