Changeset 4857
- Timestamp:
- Mar 19, 2021 12:56:44 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r4852 r4857 7367 7367 Also Called in GSASIIphsGUI.UpdatePhaseData by OnTransform callback. 7368 7368 ''' 7369 def OnShowShift(event): 7370 if 'Lastshft' not in data: 7371 return 7372 if data['Lastshft'] is None: 7373 return 7374 shftesd = data['Lastshft']/data['sig'] 7375 7376 G2plt.PlotNamedFloatHBarGraph(G2frame,shftesd,data['varyList'],Xlabel='Last shift/esd', 7377 Ylabel='Variables',Title='Last shift/esd',PlotName='Shift/esd') 7378 7369 7379 if G2frame.PickIdText == G2frame.GetTreeItemsList(item): # don't redo the current data tree item 7370 7380 if GSASIIpath.GetConfigValue('debug'): print('Skipping SelectDataTreeItem as G2frame.PickIdText unchanged') … … 7447 7457 if G2frame.dataWindow: 7448 7458 G2frame.dataWindow.ClearData() 7449 # G2frame.dataWindow.ClearData()7450 7459 # process first-level entries in tree 7451 7460 if G2frame.GPXtree.GetItemParent(item) == G2frame.root: … … 7491 7500 text += '\n\tReduced Ï**2 = {:.2f}'.format(Rvals['GOF']**2) 7492 7501 subSizer.Add(wx.StaticText(G2frame.dataWindow,wx.ID_ANY,text)) 7502 if 'Lastshft' in data and not data['Lastshft'] is None: 7503 showShift = wx.Button(G2frame.dataWindow,label='Show shift/esd plot') 7504 showShift.Bind(wx.EVT_BUTTON,OnShowShift) 7505 subSizer.Add(showShift) 7493 7506 mainSizer.Add(subSizer) 7494 7507 mainSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex='Covariance')) 7495 #mainSizer.Add((-1,-1),1,wx.EXPAND)7496 7508 G2frame.dataWindow.GetSizer().Add(mainSizer) 7497 # G2frame.dataWindow.GetSizer().Add((-1,-1),1,wx.EXPAND,1)7498 7509 G2plt.PlotCovariance(G2frame,data) 7499 7510 elif G2frame.GPXtree.GetItemText(item) == 'Constraints': -
trunk/GSASIIplot.py
r4850 r4857 5705 5705 ##### PlotBarGraph ################################################################################ 5706 5706 def PlotBarGraph(G2frame,Xarray,Xname='',Yname='Number',Title='',PlotName=None,ifBinned=False,maxBins=None): 5707 'Needs a description' 5707 ''' does a vertical bar graph 5708 ''' 5708 5709 5709 5710 def OnPageChanged(event): … … 5746 5747 Page.canvas.draw() 5747 5748 5749 ##### PlotNamedFloatBarGraph ################################################################################ 5750 def PlotNamedFloatHBarGraph(G2frame,Xvals,Ynames,Xlabel='Value',Ylabel='',Title='',PlotName=None): 5751 ''' does a horizintal bar graph 5752 ''' 5753 5754 def OnPageChanged(event): 5755 PlotText = G2frame.G2plotNB.nb.GetPageText(G2frame.G2plotNB.nb.GetSelection()) 5756 if PlotText == PlotName: 5757 PlotNamedFloatHBarGraph(G2frame,Xvals,Ynames,Xlabel,Ylabel,Title,PlotText) 5758 5759 def OnMotion(event): 5760 if event.ydata is None: 5761 return 5762 ypos = int(event.ydata+.5) 5763 if ypos and ypos < len(Ynames): #avoid out of frame mouse position 5764 SetCursor(Page) 5765 try: 5766 G2frame.G2plotNB.status.SetStatusText('X =%s %s = %9.3g'%(Ynames[ypos],Xlabel,Xvals[ypos]),1) 5767 except TypeError: 5768 G2frame.G2plotNB.status.SetStatusText('Select %s first'%PlotName,1) 5769 5770 if PlotName is None or not len(Ynames): 5771 return 5772 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(PlotName,'mpl') 5773 if new: 5774 G2frame.G2plotNB.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,OnPageChanged) 5775 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 5776 Yvals = np.arange(len(Ynames)) 5777 colors = ['blue' if x >= 0. else 'red' for x in Xvals] 5778 Page.Choice = None 5779 Plot.set_title(Title) 5780 Plot.set_xlabel(Xlabel,fontsize=14) 5781 Plot.set_ylabel(Ylabel,fontsize=14) 5782 Plot.barh(Yvals,Xvals,height=0.8,align='center',color=colors,edgecolor='black',tick_label=Ynames) 5783 Page.canvas.draw() 5784 5748 5785 ##### PlotSASDSizeDist ################################################################################ 5749 5786 def PlotSASDSizeDist(G2frame): … … 6775 6812 imgAx = Img.axes 6776 6813 ytics = imgAx.get_yticks() 6814 imgAx.set_yticks(ytics[:-1]) 6777 6815 ylabs = [Page.varyList[int(i)] for i in ytics[:-1]] 6778 6816 imgAx.set_yticklabels(ylabs) -
trunk/GSASIIstrMain.py
r4850 r4857 82 82 msg += ', {}'.format(varyList[val]) 83 83 if m: G2fil.G2Print(m, mode='warn') 84 SVD0 = result[2].get('SVD0' )84 SVD0 = result[2].get('SVD0',0) 85 85 if SVD0 == 1: 86 86 msg += 'Warning: Soft (SVD) singularity in the Hessian' … … 253 253 covMatrix = result[1]*Rvals['GOF']**2 254 254 sig = np.sqrt(np.diag(covMatrix)) 255 Lastshft = result[2].get('Xvec',None) 256 if Lastshft is None: 257 Rvals['Max shft/sig'] = None 258 else: 259 Rvals['Max shft/sig'] = np.max(np.nan_to_num(Lastshft/sig)) 255 Lastshft = result[0]-values 256 Rvals['Max shft/sig'] = np.max(np.nan_to_num(Lastshft/sig)) 260 257 if np.any(np.isnan(sig)) or not sig.shape: 261 258 G2fil.G2Print ('*** Least squares aborted - some invalid esds possible ***',mode='error') 262 # table = dict(zip(varyList,zip(values,result[0],(result[0]-values)/sig)))263 # for item in table: print item,table[item] #useful debug - are things shifting?264 259 # report on refinement issues. Result in Rvals['msg'] 265 260 ReportProblems(result,Rvals,varyList) … … 304 299 if chisq0 is not None: 305 300 Rvals['GOF0'] = np.sqrt(chisq0/(Histograms['Nobs']-len(varyList))) 306 return IfOK,Rvals,result,covMatrix,sig 301 return IfOK,Rvals,result,covMatrix,sig,Lastshft 307 302 308 303 def Refine(GPXfile,dlg=None,makeBack=True,refPlotUpdate=None): … … 398 393 try: 399 394 covData = {} 400 IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histograms,Phases,restraintDict,395 IfOK,Rvals,result,covMatrix,sig,Lastshft = RefineCore(Controls,Histograms,Phases,restraintDict, 401 396 rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg, 402 397 refPlotUpdate=refPlotUpdate) … … 406 401 newAtomDict = G2stMth.ApplyXYZshifts(parmDict,varyList) 407 402 covData = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals, 408 'varyListStart':varyListStart, 403 'varyListStart':varyListStart,'Lastshft':Lastshft, 409 404 'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict, 410 405 'newCellDict':newCellDict,'freshCOV':True} … … 818 813 .format(s)) 819 814 try: 820 IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histo,Phases,restraintDict,815 IfOK,Rvals,result,covMatrix,sig,Lastshft = RefineCore(Controls,Histo,Phases,restraintDict, 821 816 rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg, 822 817 refPlotUpdate=refPlotUpdate) … … 860 855 histRefData = { 861 856 'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals, 862 'varyListStart':varyListStart, 857 'varyListStart':varyListStart,'Lastshft':Lastshft, 863 858 'covMatrix':covMatrix,'title':histogram,'newAtomDict':newAtomDict, 864 859 'newCellDict':newCellDict,'depParmDict':depParmDict,
Note: See TracChangeset
for help on using the changeset viewer.