Commit 6af19899 authored by Markus Gaug's avatar Markus Gaug
Browse files

added calculation chi2 from fit

parent 350241bc
Pipeline #6014 passed with stages
in 3 minutes and 38 seconds
......@@ -47,6 +47,8 @@ import sys
# conversion from points to mm (please use GIMP and the reference grid on the picture!
#conv = 0.844921 # 1./8.31 # conversion from points to mm
OUT_OF_RANGE_VALUE = 99999999
def gaussian(height, center_x, center_y, width_x, width_y, theta, offset):
"""Returns a gaussian function with the given parameters"""
width_x = float(width_x)
......@@ -55,30 +57,23 @@ def gaussian(height, center_x, center_y, width_x, width_y, theta, offset):
b = -(np.sin(2 * theta)) / (2 * width_x ** 2) + (np.sin(2 * theta)) / (2 * width_y ** 2)
c = (np.sin(theta) ** 2) / ( width_x ** 2) + (np.cos(theta) ** 2) / ( width_y ** 2)
# print (height, center_x, center_y, width_x, width_y, theta, offset)
OUT_OF_RANGE = lambda x, y: OUT_OF_RANGE_VALUE
# print (height, center_x, center_y, width_x, width_y, theta, offset)
if (height<0):
return lambda x, y: 99999999.
# raise ValueError("height = %f must be positive!" % height)
return OUT_OF_RANGE
if (center_x < 0.):
return lambda x, y: 99999999.
# raise ValueError("center_x = %f must be positive!" % center_x)
return OUT_OF_RANGE
if (center_y < 0.):
return lambda x, y: 99999999.
# raise ValueError("center_y = %f must be positive!" % center_y)
return OUT_OF_RANGE
if (width_x < 0.):
return lambda x, y: 99999999.
# raise ValueError("width_x = %f must be positive!" % width_x)
return OUT_OF_RANGE
if (width_y < 0.):
return lambda x, y: 99999999.
# raise ValueError("width_y = %f must be positive!" % width_y)
return OUT_OF_RANGE
if (offset < 0.):
return lambda x, y: 99999999.
# raise ValueError("offset = %f must be positive!" % offset)
return OUT_OF_RANGE
if (theta > 3.*np.pi):
return lambda x, y: 99999999.
# raise ValueError("theta = %f must be smaller than 3pi!" % theta)
return OUT_OF_RANGE
return lambda x, y: offset + height * np.exp( - (a* (center_x - x) ** 2 + c * (center_y - y) ** 2 + 2*b * (center_x - x)*(center_y-y)) / 2.)
#-(((center_x - x) / width_x) ** 2 + ((center_y - y) / width_y) ** 2) / 2)
def moments(data):
......
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