Interpolate exits on failed peak

Issue #14 resolved
Cesare Jenkins created an issue

I discovered an issue when I moved some code that was running in an environment with peakutils 1.0 to a new environment with peakutils 1.03. I found that my interpolate calls were failing with various errors that I had never seen before. I will delineate the specific errors below, but the solution I found was to put the try: except: blocks around the fit call in the interpolate function of peak.py (line 181). This change was made in commit f431b1c, although I do not know why. What the try allows is that even if one of the peaks causes an error, the rest of the peaks will still be processed.

I would propose to return to the try method as it allows the interpolate function to operate even in poor environments.

Obviously there are some downsides to this, specifically values that haven't been fully optimized are still returned, and errors are never shown to the user, but perhaps there is a way to print the exception message or something.

In my case I learned quickly that the v1.0 code would return some spurious peaks, but I just clean them up myself.

Specific errors: If I pass in a peak, say 11, and a width of 12, the start index of the slice is -1 which results in an empty array when x[slice_] is called.

I also get a few max_feval errors from the optimize call. These come when there isn't a very good fit.

Comments (3)

  1. Lucas Hermann Negri repo owner

    Hi,

    Thanks for raising this issue. I agree the function should operate in less than ideal conditions, but also think that the errors can't be simply hidden. I'm currently leaning to using warnings and returns some error flag along it, but I'm open to suggestions.

  2. Log in to comment