@@ -3141,6 +3141,8 @@ def OnMotion(event):
31413141 def OnKeyPress (event ):
31423142 if event .key == 'g' :
31433143 mpl .rcParams ['axes.grid' ] = not mpl .rcParams ['axes.grid' ]
3144+ elif event .key == 'e' :
3145+ G2frame .ErrorBars = not G2frame .ErrorBars
31443146 elif event .key == 's' :
31453147 # write the function values (not peaks) onto a file
31463148 dlg = wx .FileDialog (G2frame , 'Choose CSV file to write' , G2G .GetExportPath (G2frame ),
@@ -3163,7 +3165,7 @@ def OnKeyPress(event):
31633165 Write2csv (fp ,['Q' ,'Gauss-def' ,'Lorenz-def' ,'FWHM-def' ,'Gauss-fit' ,'Lorenz-fit' ,'FWHM-fit' ,],header = True )
31643166 for vals in zip (Q ,S ,G ,W ,Sf ,Gf ,Wf ): Write2csv (fp ,vals )
31653167 fp .close ()
3166- wx .CallAfter (PlotPeakWidths ,G2frame , PatternName )
3168+ wx .CallAfter (PlotPeakWidths ,G2frame )
31673169
31683170 if PatternName :
31693171 G2frame .PatternId = G2gd .GetGPXtreeItemId (G2frame , G2frame .root , PatternName )
@@ -3184,7 +3186,9 @@ def OnKeyPress(event):
31843186 else :
31853187 lam = G2mth .getWave (Parms )
31863188 try : # PATCH: deal with older peak lists, before changed to dict to implement TOF
3187- peaks = G2frame .GPXtree .GetItemPyData (G2gd .GetGPXtreeItemId (G2frame ,PatternId , 'Peak List' ))['peaks' ]
3189+ Pdata = G2frame .GPXtree .GetItemPyData (G2gd .GetGPXtreeItemId (G2frame ,PatternId , 'Peak List' ))
3190+ peaks = Pdata ['peaks' ]
3191+ peakEsds = Pdata .get ('sigDict' ,{})
31883192 except TypeError :
31893193 print ("Your peak list needs reformatting..." ,end = '' )
31903194 item = G2gd .GetGPXtreeItemId (G2frame ,PatternId , 'Peak List' )
@@ -3195,7 +3199,10 @@ def OnKeyPress(event):
31953199 return
31963200 xylim = []
31973201 new ,plotNum ,Page ,Plot ,lim = G2frame .G2plotNB .FindPlotTab ('Peak Widths' ,'mpl' )
3198- Page .Choice = (' key press' ,'g: toggle grid' ,'s: save as .csv file' )
3202+ if len (peakEsds ):
3203+ Page .Choice = (' key press' ,'e: toggle error bars' ,'g: toggle grid' ,'s: save as .csv file' )
3204+ else :
3205+ Page .Choice = (' key press' ,'g: toggle grid' ,'s: save as .csv file' )
31993206 Page .keyPress = OnKeyPress
32003207 if not new :
32013208 if not G2frame .G2plotNB .allowZoomReset : # save previous limits
@@ -3258,26 +3265,39 @@ def OnKeyPress(event):
32583265 Plot .plot (Q ,Gf ,color = 'm' ,label = 'Lorentzian fit' )
32593266 Plot .plot (Q ,Wf ,color = 'g' ,dashes = (5 ,5 ),label = 'FWHM fit (GL+ab)' )
32603267
3261- Tp = []
32623268 Ap = []
3269+ sAp = []
32633270 Bp = []
3271+ sBp = []
32643272 Sp = []
3273+ sSp = []
32653274 Gp = []
3275+ sGp = []
32663276 Wp = []
32673277 Qp = []
3268- for peak in peaks :
3269- Tp .append (peak [0 ])
3278+ for ip , peak in enumerate ( peaks ) :
3279+ Qp .append (2. * np . pi * difC / peak [0 ])
32703280 Ap .append (peak [4 ])
3281+ sAp .append (peakEsds .get ('alp%d' % ip ,0.0 ))
32713282 Bp .append (peak [6 ])
3272- Qp .append (2. * np .pi * difC / peak [0 ])
3273- Sp .append (1.17741 * np .sqrt (peak [8 ])/ peak [0 ])
3283+ sBp .append (peakEsds .get ('bet%d' % ip ,0.0 ))
3284+ sp = 1.17741 * np .sqrt (peak [8 ])/ peak [0 ]
3285+ Sp .append (sp ) #sqrt(8ln2)/2
3286+ sSp .append (0.5 * sp * peakEsds .get ('sig%d' % ip ,0.0 )/ peak [8 ])
32743287 Gp .append (peak [10 ]/ peak [0 ])
3288+ sGp .append (peakEsds .get ('gam%d' % ip ,0.0 ))
32753289
32763290 if Qp :
3277- Plot .plot (Qp ,Ap ,'+' ,color = 'r' ,label = 'Alpha peak' )
3278- Plot .plot (Qp ,Bp ,'+' ,color = 'orange' ,label = 'Beta peak' )
3279- Plot .plot (Qp ,Sp ,'+' ,color = 'b' ,label = 'Gaussian peak' )
3280- Plot .plot (Qp ,Gp ,'+' ,color = 'm' ,label = 'Lorentzian peak' )
3291+ if G2frame .ErrorBars :
3292+ Plot .errorbar (Qp ,Ap ,yerr = sAp ,fmt = 'r+' ,label = 'Alpha peak' )
3293+ Plot .errorbar (Qp ,Bp ,yerr = sBp ,fmt = '+' ,color = 'orange' ,label = 'Beta peak' )
3294+ Plot .errorbar (Qp ,Sp ,yerr = sSp ,fmt = 'b+' ,label = 'Gaussian peak' )
3295+ Plot .errorbar (Qp ,Gp ,yerr = sGp ,fmt = 'm+' ,label = 'Lorentzian peak' )
3296+ else :
3297+ Plot .plot (Qp ,Ap ,'+' ,color = 'r' ,label = 'Alpha peak' )
3298+ Plot .plot (Qp ,Bp ,'+' ,color = 'orange' ,label = 'Beta peak' )
3299+ Plot .plot (Qp ,Sp ,'+' ,color = 'b' ,label = 'Gaussian peak' )
3300+ Plot .plot (Qp ,Gp ,'+' ,color = 'm' ,label = 'Lorentzian peak' )
32813301 Plot .legend (loc = 'best' )
32823302 elif 'E' in Parms ['Type' ][0 ]:
32833303 Plot .set_ylabel (r'$\Delta Q/Q, \Delta d/d, \Delta E/E$' ,fontsize = 14 )
0 commit comments