Changeset 3373
- Timestamp:
- May 6, 2018 2:13:25 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r3365 r3373 573 573 file = open(G2frame.GSASprojectfile,'rb') 574 574 if showProvenance: print ('loading from file: '+G2frame.GSASprojectfile) 575 G2frame.SetTitle("GSAS-II project: "+os.path.split(G2frame.GSASprojectfile)[1])576 G2frame.plotFrame.SetTitle("GSAS-II plots: "+os.path.split(G2frame.GSASprojectfile)[1])577 575 wx.BeginBusyCursor() 578 576 try: … … 648 646 wx.EndBusyCursor() 649 647 G2frame.Status.SetStatusText('Mouse RB drag/drop to reorder',0) 648 G2frame.SetTitleByGPX() 650 649 651 650 def ProjFileSave(G2frame): … … 1513 1512 1514 1513 Expands the parm & sig dicts to include values derived from constraints. 1514 1515 This could be made faster for sequential fits by reducing the histogram list to only 1516 the active histogram being exported. 1515 1517 ''' 1516 1518 self.parmDict = {} -
trunk/GSASIIconstrGUI.py
r3371 r3373 197 197 phaseAtTypes[item] = '' 198 198 199 # create a list of the hist*phase variables; include wildcards here 200 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,Histograms,Print=False) 201 hapList = [i for i in hapDict.keys() if i.split(':')[2] not in ('Type',)] 202 hapList.sort() 203 wildList = [] # list of variables with "*" for histogram number 204 for i in hapList: 205 s = i.split(':') 206 if s[1] == "": continue 207 s[1] = '*' 208 sj = ':'.join(s) 209 if sj not in wildList: wildList.append(sj) 210 #wildList.sort() # unneeded 211 hapList += wildList 212 histVary,histDict,controlDict = G2stIO.GetHistogramData(Histograms,Print=False) 199 # create a list of the hist*phase variables 200 seqList = G2frame.testSeqRefineMode() 201 if seqList: # for sequential refinement, only process 1st histgram in list 202 histDict = {seqList[0]:Histograms[seqList[0]]} 203 else: 204 histDict = Histograms 205 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,histDict,Print=False) 206 hapList = sorted([i for i in hapDict.keys() if i.split(':')[2] not in ('Type',)]) 207 if seqList: # convert histogram # to wildcard 208 wildList = [] # list of variables with "*" for histogram number 209 for i in hapList: 210 s = i.split(':') 211 if s[1] == "": continue 212 s[1] = '*' 213 sj = ':'.join(s) 214 if sj not in wildList: wildList.append(sj) 215 hapList = wildList 216 histVary,histDict,controlDict = G2stIO.GetHistogramData(histDict,Print=False) 213 217 histList = [] 214 218 for item in histDict: … … 220 224 histList.append(item) 221 225 histList.sort() 222 wildList = [] 223 # for i in histList: # any reason to have this for hist constraints? 224 # s = i.split(':') 225 # if s[1] == "": continue 226 # s[1] = '*' 227 # sj = ':'.join(s) 228 # if sj not in wildList: wildList.append(sj) 229 # histList += wildList 226 if seqList: # convert histogram # to wildcard 227 wildList = [] # list of variables with "*" for histogram number 228 for i in histList: 229 s = i.split(':') 230 if s[1] == "": continue 231 s[1] = '*' 232 sj = ':'.join(s) 233 if sj not in wildList: wildList.append(sj) 234 histList = wildList 230 235 Indx = {} 231 236 G2frame.Page = [0,'phs'] … … 1081 1086 G2frame.dataWindow.ConstraintEdit.Enable(G2G.wxID_EQUIVALANCEATOMS,False) 1082 1087 # G2frame.dataWindow.ConstraintEdit.Enable(G2G.wxID_ADDRIDING,False) 1083 enableEditCons = True1084 1088 if text == 'Histogram/Phase': 1089 enableEditCons = [False]+4*[True] 1085 1090 G2frame.Page = [page,'hap'] 1086 1091 UpdateConstraintPanel(HAPConstr,'HAP') 1087 1092 elif text == 'Histogram': 1093 enableEditCons = [False]+4*[True] 1088 1094 G2frame.Page = [page,'hst'] 1089 1095 UpdateConstraintPanel(HistConstr,'Hist') 1090 1096 elif text == 'Phase': 1097 enableEditCons = 5*[True] 1091 1098 G2frame.Page = [page,'phs'] 1092 1099 G2frame.dataWindow.ConstraintEdit.Enable(G2G.wxID_EQUIVALANCEATOMS,True) … … 1098 1105 UpdateConstraintPanel(PhaseConstr,'Phase') 1099 1106 elif text == 'Global': 1107 enableEditCons = [False]+4*[True] 1100 1108 G2frame.Page = [page,'glb'] 1101 1109 UpdateConstraintPanel(GlobalConstr,'Global') 1102 1110 else: 1103 enableEditCons = False1111 enableEditCons = 5*[False] 1104 1112 G2frame.Page = [page,'sym'] 1105 1113 UpdateConstraintPanel(SymConstr,'Sym-Generated') 1106 1114 # remove menu items when not allowed 1107 for i in G2frame.dataWindow.ConstraintEdit.GetMenuItems():1108 i.Enable(enableEditCons)1115 for obj,flag in zip(G2frame.dataWindow.ConstraintEdit.GetMenuItems(),enableEditCons): 1116 obj.Enable(flag) 1109 1117 G2frame.dataWindow.SetDataSize() 1110 1118 -
trunk/GSASIIdataGUI.py
r3371 r3373 523 523 self.Refine.append(item) 524 524 self.Bind(wx.EVT_MENU, self.OnRefine, id=item.GetId()) 525 525 526 #=============================================================================== 527 # TODO: remove this, also EnableSeqRefineMenu and self.SeqRefine 528 # do when tutorials are updated so that references to menu item are gone 526 529 item = parent.Append(wx.ID_ANY,'Sequential refine','') 527 530 self.Bind(wx.EVT_MENU, self.OnSeqRefine, id=item.GetId()) … … 532 535 item.Enable(state) 533 536 self.SeqRefine.append(item) # save menu obj for use in self.EnableSeqRefineMenu 537 #================================================================================ 534 538 # if GSASIIpath.GetConfigValue('debug'): # allow exceptions for debugging 535 539 # item = parent.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, … … 551 555 self.ImportMenuId = {} 552 556 557 def testSeqRefineMode(self): 558 '''Returns the list of histograms included in a sequential refinement or 559 an empty list if a standard (non-sequential) refinement. 560 ''' 561 controls = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self,self.root, 'Controls')) 562 return controls.get('Seq Data',[]) 563 553 564 def EnableSeqRefineMenu(self): 554 565 '''Enable or disable the sequential refinement menu items based on the 555 566 contents of the Controls 'Seq Data' item (if present) 556 567 ''' 557 controls = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self,self.root, 'Controls')) 558 if controls.get('Seq Data'): 568 if self.testSeqRefineMode(): 559 569 for i in self.SeqRefine: i.Enable(True) 560 570 else: … … 3717 3727 else: 3718 3728 self.OnFileSaveas(event) 3729 3730 def SetTitleByGPX(self): 3731 '''Set the title for the two window frames 3732 ''' 3733 if self.testSeqRefineMode(): 3734 s = u' (sequential refinement)' 3735 else: 3736 s = u'' 3737 self.SetTitle("GSAS-II project: "+os.path.split(self.GSASprojectfile)[1]+s) 3738 self.plotFrame.SetTitle("GSAS-II plots: "+os.path.split(self.GSASprojectfile)[1]) 3719 3739 3720 3740 def OnFileSaveas(self, event): … … 3736 3756 self.GSASprojectfile = G2IO.FileDlgFixExt(dlg,self.GSASprojectfile) 3737 3757 self.GPXtree.SetItemText(self.root,'Project: '+self.GSASprojectfile) 3738 self.SetTitle("GSAS-II project: "+os.path.split(self.GSASprojectfile)[1])3739 self.plotFrame.SetTitle("GSAS-II plots: "+os.path.split(self.GSASprojectfile)[1])3740 3758 self.CheckNotebook() 3741 3759 G2IO.ProjFileSave(self) 3760 self.SetTitleByGPX() 3742 3761 os.chdir(dlg.GetDirectory()) # to get Mac/Linux to change directory! 3743 3762 finally: … … 4192 4211 return Histograms,Phases 4193 4212 4194 def MakeLSParmDict(self ):4213 def MakeLSParmDict(self,seqHist=None): 4195 4214 '''Load all parameters used for computation from the tree into a 4196 4215 dict of paired values [value, refine flag]. Note that this is … … 4202 4221 :func:`GSASIIstrMain.Refine` and :func:`GSASIIstrMain.SeqRefine` (from 4203 4222 a GPX file). 4223 4224 :param dict seqHist: defines a specific histogram to be loaded for a sequential 4225 refinement, if None (default) all are loaded. 4226 Note: at present this parameter is not used anywhere. 4204 4227 4205 4228 :returns: (parmDict,varyList) where: … … 4211 4234 parmDict = {} 4212 4235 Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree() 4236 if seqHist: 4237 histDict = {seqHist:Histograms[seqHist]} 4238 else: 4239 histDict = Histograms 4213 4240 for phase in Phases: 4214 4241 if 'pId' not in Phases[phase]: … … 4220 4247 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 4221 4248 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable,MFtable,maxSSwave = G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) 4222 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases, Histograms,Print=False)4223 histVary,histDict,controlDict = G2stIO.GetHistogramData( Histograms,Print=False)4249 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,histDict,Print=False) 4250 histVary,histDict,controlDict = G2stIO.GetHistogramData(histDict,Print=False) 4224 4251 varyList = rbVary+phaseVary+hapVary+histVary 4225 4252 parmDict.update(rbDict) … … 4246 4273 '''Displays a window showing all parameters in the refinement. 4247 4274 Called from the Calculate/View LS Parms menu. 4275 4276 This could potentially be sped up by loading only the histogram that is needed 4277 for a sequential fit. 4248 4278 ''' 4249 4279 try: … … 4279 4309 4280 4310 def OnRefine(self,event): 4281 '''Perform a refinement .4311 '''Perform a refinement or a sequential refinement (depending on controls setting) 4282 4312 Called from the Calculate/Refine menu. 4283 4313 ''' 4284 Id = GetGPXtreeItemId(self,self.root,'Sequential results') 4285 if Id: 4286 dlg = wx.MessageDialog( 4287 self, 4288 'Your last refinement was sequential. Continue with "Refine", removing previous sequential results?', 4289 'Remove sequential results?',wx.OK|wx.CANCEL) 4290 if dlg.ShowModal() == wx.ID_OK: 4291 self.GPXtree.Delete(Id) 4292 dlg.Destroy() 4293 else: 4294 dlg.Destroy() 4295 return 4314 if self.testSeqRefineMode(): 4315 self.OnSeqRefine(event) 4316 return 4317 # Id = GetGPXtreeItemId(self,self.root,'Sequential results') 4318 # if Id: 4319 # dlg = wx.MessageDialog( 4320 # self, 4321 # 'Your last refinement was sequential. Continue with "Refine", removing previous sequential results?', 4322 # 'Remove sequential results?',wx.OK|wx.CANCEL) 4323 # if dlg.ShowModal() == wx.ID_OK: 4324 # self.GPXtree.Delete(Id) 4325 # dlg.Destroy() 4326 # else: 4327 # dlg.Destroy() 4328 # return 4296 4329 self.OnFileSave(event) 4297 4330 # check that constraints are OK here … … 4399 4432 def OnSeqRefine(self,event): 4400 4433 '''Perform a sequential refinement. 4401 Called from the Calculate/Sequential refine menu. 4434 Called from self.OnRefine (Called from the Calculate/Refine menu) 4435 4436 temporarily called from the Calculate/Sequential refine menu (to be removed) 4402 4437 ''' 4438 seqList = self.testSeqRefineMode() 4439 if not seqList: 4440 self.OnRefine(event) 4441 return 4403 4442 Id = GetGPXtreeItemId(self,self.root,'Sequential results') 4404 4443 if not Id: … … 4407 4446 self.G2plotNB.Delete('Sequential refinement') #clear away probably invalid plot 4408 4447 Controls = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self,self.root, 'Controls')) 4409 if not Controls.get('Seq Data'):4410 print('Error: a sequential refinement has not been set up')4411 return4412 4448 Controls['ShowCell'] = True 4413 4449 self.OnFileSave(event) 4414 4450 # check that constraints are OK here 4415 4451 errmsg, warnmsg = G2stIO.ReadCheckConstraints(self.GSASprojectfile) 4452 #errmsg, warnmsg = G2stIO.ReadCheckConstraints(self.GSASprojectfile,seqList[0]) # this would be faster, but at present it might not catch all errors 4416 4453 if errmsg: 4417 4454 self.ErrorDialog('Refinement error',errmsg) … … 5489 5526 G2frame.EnableSeqRefineMenu() 5490 5527 dlg.Destroy() 5528 G2frame.SetTitleByGPX() 5491 5529 wx.CallAfter(UpdateControls,G2frame,data) 5492 5530 … … 7532 7570 # if G2frame.dataDisplay: 7533 7571 # oldPage = G2frame.dataDisplay.GetSelection() 7534 G2frame.SetTitle("GSAS-II project: "+os.path.split(G2frame.GSASprojectfile)[1])7535 G2frame.plotFrame.SetTitle("GSAS-II plots: "+os.path.split(G2frame.GSASprojectfile)[1])7536 7572 7537 7573 SetDataMenuBar(G2frame) 7574 G2frame.SetTitleByGPX() 7538 7575 G2frame.PickId = item 7539 7576 G2frame.PickIdText = None -
trunk/GSASIIstrIO.py
r3340 r3373 182 182 return constDict,fixedList,ignored 183 183 184 def ReadCheckConstraints(GPXfile): 185 '''Load constraints and related info and return any error or warning messages''' 184 def ReadCheckConstraints(GPXfile, seqHist=None): 185 '''Load constraints and related info and return any error or warning messages 186 This is done from the GPX file rather than the tree. 187 This this is called before a refinement is launched (OnRefine and OnSeqRefine), where the 188 tree could be used. 189 190 :param dict seqHist: defines a specific histogram to be loaded for a sequential 191 refinement, if None (default) all are loaded. 192 ''' 186 193 # init constraints 187 194 G2mv.InitVars() … … 193 200 return 'Error: no diffraction data','' 194 201 constrDict,fixedList = GetConstraints(GPXfile) # load user constraints before internally generated ones 202 if seqHist: Histograms = {seqHist:Histograms[seqHist]} # sequential fit: only need one histogram 195 203 rigidbodyDict = GetRigidBodies(GPXfile) 196 204 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
Note: See TracChangeset
for help on using the changeset viewer.