Changeset 4339 for trunk/G2compare.py
- Timestamp:
- Mar 3, 2020 3:01:43 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/G2compare.py
- Property svn:keywords set to Date Author Revision URL Id
r4335 r4339 3 3 #GSAS-II Data/Model Comparison 4 4 ########### SVN repository information ################### 5 # $Date :$6 # $Author : toby$7 # $Revision :$8 # $URL :$9 # $Id :$5 # $Date$ 6 # $Author$ 7 # $Revision$ 8 # $URL$ 9 # $Id$ 10 10 ########### SVN repository information ################### 11 11 ''' … … 14 14 ''' 15 15 16 #TODO: in OnDataTreeSelChanged want to plot patterns 17 # Make PWDR unique (use histlist) 18 # add graphics 19 # implement project 16 #TODO: 17 # Prince-test next 18 # Make PWDR unique? (use histlist) 19 # more graphics 20 # display more in datawindow 20 21 21 22 import sys … … 41 42 42 43 import GSASIIpath 43 GSASIIpath.SetVersionNumber("$Revision : 4154$")44 GSASIIpath.SetVersionNumber("$Revision$") 44 45 import GSASIIfiles as G2fil 45 46 import GSASIIplot as G2plt … … 132 133 wx.Frame.__init__(self, name='dComp', parent=parent, 133 134 size=size,style=wx.DEFAULT_FRAME_STYLE, title='GSAS-II data/model comparison') 135 # misc vars 136 self.VcovColor = 'RdYlGn' 134 137 # plot window 138 try: 139 size = GSASIIpath.GetConfigValue('Plot_Size') 140 if type(size) is tuple: 141 pass 142 elif type(size) is str: 143 size = eval(size) 144 else: 145 raise Exception 146 except: 147 size = wx.Size(700,600) 135 148 self.plotFrame = wx.Frame(None,-1,'dComp Plots',size=size, 136 149 style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX) … … 208 221 209 222 self.PWDRfilter = None 223 for win,var in ((self.plotFrame,'Plot_Pos'),): 224 #for win,var in ((self,'Main_Pos'),(self.plotFrame,'Plot_Pos')): 225 try: 226 pos = GSASIIpath.GetConfigValue(var) 227 if type(pos) is str: pos = eval(pos) 228 win.SetPosition(pos) 229 if GetDisplay(pos) is None: win.Center() 230 except: 231 if GSASIIpath.GetConfigValue(var): 232 print('Value for config {} {} is invalid'.format(var,GSASIIpath.GetConfigValue(var))) 233 win.Center() 210 234 self.SetModeMenu() 211 235 … … 467 491 wx.EndBusyCursor() 468 492 self.GPXtree.Expand(self.root) 469 493 470 494 def OnDataTreeSelChanged(self,event): 495 def ClearData(self): 496 '''Initializes the contents of the dataWindow panel 497 ''' 498 self.Unbind(wx.EVT_SIZE) 499 self.SetBackgroundColour(wx.Colour(240,240,240)) 500 Sizer = self.GetSizer() 501 if Sizer: 502 try: 503 Sizer.Clear(True) 504 except: 505 pass 506 G2frame = self 471 507 item = event.GetItem() 472 print('selected',item) 508 #print('selected',item) 509 if self.getMode() == "Project": 510 ClearData(G2frame.dataWindow) 511 data = G2frame.GPXtree.GetItemPyData(item) 512 if data is None: 513 self.plotFrame.Show(False) 514 return 515 text = '' 516 if 'Rvals' in data: 517 Nvars = len(data['varyList']) 518 Rvals = data['Rvals'] 519 text = ('Residuals after last refinement:\n'+ 520 '\twR = {:.3f}\n\tchi**2 = {:.1f}\n\tGOF = {:.2f}').format( 521 Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']) 522 text += '\n\tNobs = {}\n\tNvals = {}\n\tSVD zeros = {}'.format( 523 Rvals['Nobs'],Nvars,Rvals.get('SVD0',0.)) 524 text += '\n\tmax shift/esd = {:.3f}'.format(Rvals.get('Max shft/sig',0.0)) 525 if 'lamMax' in Rvals: 526 text += '\n\tlog10 MaxLambda = {:.1f}'.format(np.log10(Rvals['lamMax'])) 527 G2frame.dataWindow.GetSizer().Add( 528 wx.StaticText(G2frame.dataWindow,wx.ID_ANY,text) 529 ) 530 self.plotFrame.Show(True) 531 G2plt.PlotCovariance(G2frame,data) 532 else: 533 self.plotFrame.Show(False) 534 ClearData(G2frame.dataWindow) 473 535 474 536 #print(self.GPXtree._getTreeItemsList(item)) … … 557 619 G2G.G2MessageBox(self,'F-test requires same number of observations in each refinement','F-test not valid') 558 620 return 621 missingVars = [] 622 for var in baseDict['varyList']: 623 if var not in relxDict['varyList']: 624 missingVars.append(var) 625 txt = '' 626 postmsg = '' 627 if missingVars: 628 txt = ('*** Possible invalid use of F-test: '+ 629 'The F-test requires that the constrained model be a subset '+ 630 'of the relaxed model. Review the parameters shown below to '+ 631 'confirm missing var(s) have new names in the relaxed model. '+ 632 '***\n\n') 633 postmsg = ('\n\nThese parameters are in the constrained '+ 634 'fit and are not in the relaxed fit:\n* ') 635 for i,var in enumerate(missingVars): 636 if i > 0: postmsg += ', ' 637 postmsg += var 638 postmsg += ('\nThese parameters are in the relaxed fit and not'+ 639 ' in the constrained fit:\n* ') 640 i = 0 641 for var in relxDict['varyList']: 642 if var not in baseDict['varyList']: 643 if i > 0: postmsg += ', ' 644 i += 1 645 postmsg += var 646 #GSASIIpath.IPyBreak_base() 559 647 prob = RwFtest(baseDict['Rvals']['Nobs'], 560 648 baseDict['Rvals']['GOF'],len(baseDict['varyList']), 561 649 relxDict['Rvals']['GOF'],len(relxDict['varyList'])) 562 650 fmt = "{} model is \n* {}\n* {} variables and Reduced Chi**2 = {:.3f}" 563 msg = fmt.format('Constrained',self.GPXtree.GetItemText(s0)[:-11], 651 msg = txt 652 msg += fmt.format('Constrained',self.GPXtree.GetItemText(s0)[:-11], 564 653 len(baseDict['varyList']), 565 654 baseDict['Rvals']['GOF']**2) … … 575 664 else: 576 665 msg += "The constrained model is statistically preferred to the relaxed model." 666 msg += postmsg 577 667 G2G.G2MessageBox(self,msg,'F-test result') 578 #GSASIIpath.IPyBreak_base()579 668 580 669 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.