Skip to content

Commit

Permalink
error checking for PCA plots
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Jul 9, 2024
1 parent 9977868 commit 0583148
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions larch/wxlib/xafsplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,10 @@ def plot_prepeaks_baseline(dgroup, subtract_baseline=False, show_fitrange=True,
#endif
ppeak = dgroup.prepeaks

px0, px1, py0, py1 = extend_plotrange(dgroup.xplot, dgroup.yplot,
yplot = getattr(dgroup, 'yplot', getattr(dgroup, 'ydat', None))
xplot = getattr(dgroup, 'xplot', getattr(dgroup, 'x', None))

px0, px1, py0, py1 = extend_plotrange(xplot, yplot,
xmin=ppeak.emin, xmax=ppeak.emax)

title = "pre_edge baseline\n %s" % dgroup.filename
Expand All @@ -993,8 +996,6 @@ def plot_prepeaks_baseline(dgroup, subtract_baseline=False, show_fitrange=True,
marker='None', markersize=4, win=win, _larch=_larch)
popts.update(kws)

yplot = dgroup.yplot
xplot = dgroup.xplot
if subtract_baseline:
xplot = ppeak.energy
yplot = ppeak.baseline
Expand Down Expand Up @@ -1223,7 +1224,11 @@ def plot_pca_fit(dgroup, win=1, with_components=False, _larch=None, **kws):
linewidth=3, new=True, marker='None', markersize=4,
stacked=True, win=win, _larch=_larch)
popts.update(kws)
_fitplot(result.x, result.yplot, result.yfit,
yplot = getattr(result, 'yplot', getattr(result, 'ydat', None))
if yplot is None:
raise ValueError('cannot find y data for PCA plot')

_fitplot(result.x, yplot, result.yfit,
label='data', label2='PCA fit', **popts)

disp = get_display(win=win, stacked=True, _larch=_larch)
Expand Down

0 comments on commit 0583148

Please sign in to comment.