Commit 350241bc authored by Markus Gaug's avatar Markus Gaug
Browse files

added calculation chi2 from fit

parent caad58fb
Pipeline #6013 passed with stages
in 3 minutes and 8 seconds
......@@ -107,7 +107,7 @@ def fitgaussian(data):
errorfunction = lambda p: np.ravel(gaussian(*p)(*np.indices(data.shape)) -
data)
p, success = leastsq(errorfunction, params)
return p
return p, errorfunction
def run_script(file,rangey1,rangey2,rangex1,rangex2):
......@@ -151,11 +151,16 @@ def run_script(file,rangey1,rangey2,rangex1,rangex2):
axarr[0, 0].imshow(scidata_sl, origin='lower', cmap='gnuplot')
axarr[0, 0].set_title(titles[0], color=colors[0], fontsize=10)
params = fitgaussian(scidata_sl)
print(' height, x, y, width_x, width_y, theta, offset')
print('Fitted parameters: ', [ "{:f} ".format(x) for x in params] )
params, errf = fitgaussian(scidata_sl)
fit = gaussian(*params)
arr = fit(*np.indices(scidata_sl.shape))
print(arr.shape, scidata_sl.shape)
chi2 = np.sum(np.power(arr-scidata_sl,2))/(scidata_sl.size-params.size)
print(' height, x, y, width_x, width_y, theta, offset, chi2')
print('Fitted parameters: ', [ "{:f} ".format(x) for x in params], chi2 )
axarr[0, 0].contour(fit(*np.indices(scidata_sl.shape))) #, cmap=plt.cm.copper)
(height, x, y, width_x, width_y, theta, offset) = params
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment