Fitting a 2D Gaussian function using scipy.optimize.curve_fit – ValueError and minpack.error
The output of twoD_Gaussian needs to be 1D. What you can do is add a .ravel() onto the end of the last line, like this: def twoD_Gaussian(xy, amplitude, xo, yo, sigma_x, sigma_y, theta, offset): x, y = xy xo = float(xo) yo = float(yo) a = (np.cos(theta)**2)/(2*sigma_x**2) + (np.sin(theta)**2)/(2*sigma_y**2) b = -(np.sin(2*theta))/(4*sigma_x**2) + (np.sin(2*theta))/(4*sigma_y**2) c … Read more