Skip to content

Commit

Permalink
distrib.findLocalMinima() fail gracefully on single peak ranges
Browse files Browse the repository at this point in the history
if it can't be fitted
  • Loading branch information
ibressler committed Jun 9, 2021
1 parent 1a14688 commit 45eb76b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion distrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def findLocalMinima(peakRanges, xarr, yarr, doPlot=False, verbose=False):
continue
if verbose: print((istart, iend))
x, y = xarr[istart:iend+1], yarr[istart:iend+1]
spline = scipy.interpolate.InterpolatedUnivariateSpline(x, y, k=4)
try:
spline = scipy.interpolate.InterpolatedUnivariateSpline(x, y, k=4)
except:
print(f"Warning: Could not findLocalMinima() within {(istart, iend)}!")
newRanges.append((istart, iend))
continue
#if verbose: print(spline(x))
deriv = spline.derivative()
#if verbose: print(deriv(x))
Expand Down

0 comments on commit 45eb76b

Please sign in to comment.