Closedown
This commit is contained in:
@@ -21,7 +21,6 @@ sensor = scd_sim if SIMULATION else scd
|
||||
|
||||
X_MIN, X_MAX, Y_MIN, Y_MAX = float(X_MIN), float(X_MAX), float(Y_MIN), float(Y_MAX)
|
||||
|
||||
|
||||
def plot_fit(normalization, mean_val, sigma, xdata):
|
||||
gaussian = mathutils.Gaussian(normalization, mean_val, sigma)
|
||||
plotutils.plot_function(get_plots(None)[0], gaussian, "Fit", xdata)
|
||||
@@ -39,8 +38,11 @@ for y in frange(Y_MIN, Y_MAX, y_step):
|
||||
try:
|
||||
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
|
||||
(offset, normalization, mean_val_x, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
|
||||
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
|
||||
raise Exception("Invalid x fit")
|
||||
print "Fit: " + str ((offset, normalization, mean_val_x, sigma))
|
||||
peak_height = normalization+offset
|
||||
print "peak_height=" + str(peak_height)
|
||||
if (peak_height < (offset * 1.20)) or (sigma < y_step ):
|
||||
raise Exception("Invalid x fit ")
|
||||
plot_fit(normalization, mean_val_x, sigma, xdata)
|
||||
print "Found x center at ", mean_val_x
|
||||
scx.move(mean_val_x)
|
||||
@@ -50,13 +52,16 @@ for y in frange(Y_MIN, Y_MAX, y_step):
|
||||
|
||||
step += 1
|
||||
|
||||
r = cscan(scy, sensor, max(y-MAX_SAMPLE_SIZE/2, scy.minValue), min(Y_MAX+MAX_SAMPLE_SIZE/2, scy.maxValue), SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
|
||||
#r = cscan(scy, sensor, max(y-MAX_SAMPLE_SIZE/2, scy.minValue), min(Y_MAX+MAX_SAMPLE_SIZE/2, scy.maxValue), SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
|
||||
r = cscan(scy, sensor, Y_MIN, Y_MAX, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
|
||||
xdata,ydata = enforce_monotonic(r.getPositions(0)), r.getReadable(0)
|
||||
try:
|
||||
(offset, normalization, mean_val_y, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
|
||||
except:
|
||||
raise Exception ("Invalid y fit: ", sys.exc_info()[0])
|
||||
if (normalization < offset * 1.20) or (sigma > 0.5):
|
||||
peak_height = normalization+offset
|
||||
print "peak_height=" + str(peak_height)
|
||||
if (peak_height < (offset * 1.20)) or (sigma < y_step ):
|
||||
raise Exception("Invalid y fit")
|
||||
plot_fit(normalization, mean_val_y, sigma, xdata)
|
||||
print "Found y center at ", mean_val_y
|
||||
@@ -72,8 +77,10 @@ try:
|
||||
try:
|
||||
(offset, normalization, mean_minus_15, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
|
||||
except:
|
||||
raise Exception ("Invalid x fit on z search -15deg: ", sys.exc_info()[0])
|
||||
if ((normalization) < offset * 1.20) or (sigma > 0.5):
|
||||
raise Exception ("Invalid x fit on z search -15deg: ", sys.exc_info()[0])
|
||||
peak_height = normalization+offset
|
||||
print "peak_height=" + str(peak_height)
|
||||
if (peak_height < (offset * 1.20)) or (sigma < y_step ):
|
||||
raise Exception("Invalid x fit on z search -15deg")
|
||||
plot_fit(normalization, mean_minus_15, sigma, xdata)
|
||||
print "Found x center at -15deg at ", mean_minus_15
|
||||
@@ -86,7 +93,9 @@ try:
|
||||
(offset, normalization, mean_plus_15, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)
|
||||
except:
|
||||
raise Exception ("Invalid x fit on z search +15deg: ", sys.exc_info()[0])
|
||||
if ((normalization-offset) < offset * 1.20) or (sigma > 0.5):
|
||||
peak_height = normalization+offset
|
||||
print "peak_height=" + str(peak_height)
|
||||
if (peak_height < (offset * 1.20)) or (sigma < y_step ):
|
||||
raise Exception("Invalid x fit on z search +15deg")
|
||||
plot_fit(normalization, mean_minus_15, sigma, xdata)
|
||||
print "Found x center at +15deg at ", mean_plus_15
|
||||
|
||||
Reference in New Issue
Block a user