Running scipy curve_fit produces runtime error maxfev = 1000

9
August 10, 2018, at 2:00 PM

I am running a curve fit in python that encountered the error, RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 1000. Here is my code:

I01 = 6e10 #I00
a1 = 1.0 #afit0
b1 = 20.0
k1 = 1e10 #kfit0
x = ang_all
guess = np.array([I01, a1, b1, k1])
bfit1 = np.zeros((2160,2560))
for ypixel in range(0,2160):
    for xpixel in range(0,2560):
         popt, pcov = curve_fit(func, x, rd0_all[:,ypixel,xpixel], p0=guess)
         perr1 = np.sqrt(np.diag(pcov))
         Ifit1 = popt[0]
         afit1 = popt[1]
         bfit1[ypixel,xpixel] = popt[2]
         kfit1 = popt[3]

I am currently trying to run the fit for every pixel in an image. I ran it previously for only one and the fit works, but when I try with the for loops it encountered the error. I did attempt to paste only the section shown into conda instead of running the whole script again after I modified it, so maybe that has something to do with it.

READ ALSO
Rasterize Geometry Example not working

Rasterize Geometry Example not working

I am trying to recreate this rasterio example:

24
Assiging a rank to each group in pandas

Assiging a rank to each group in pandas

I have a dataframe and would like to assign a rank to each row in a groupFor example,

30
The correct way to shorten long for statement to a maximum of 79 columns

The correct way to shorten long for statement to a maximum of 79 columns

My question is what's the most conventional way of making the following line of code:

40