Script execution

This commit is contained in:
gac-x04sa
2018-01-25 11:17:12 +01:00
parent 73c3a474dc
commit f02602c3f1
+10 -7
View File
@@ -1,26 +1,29 @@
import mathutils
import plotutils
SIMULATION = True
X_MIN = scx.minValue / 2
X_MAX = scx.maxValue / 2
Y_MIN = scy.minValue / 2
Y_MAX = scy.maxValue / 2
SIMULATION = True
Y_STEP = 0.125
MAX_SAMPLE_SIZE = 0.4
MIN_SAMPLE_SIZE = 0.25
SCAN_RESOLUTION = 0.01
y_step = MIN_SAMPLE_SIZE * 0.5
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)
step=0
for y in frange(Y_MIN, Y_MAX, Y_STEP):
for y in frange(Y_MIN, Y_MAX, y_step):
scy.move(y)
scan_range = [X_MIN, X_MAX] if (step % 2==0) else [X_MAX, X_MIN]
r = cscan(scx, sensor, scan_range[0], scan_range[1], 0.01, latency = DIODE_SETTLING_TIME)
r = cscan(scx, sensor, scan_range[0], scan_range[1], SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
try:
xdata = enforce_monotonic(r.getPositions(0))
@@ -38,12 +41,12 @@ for y in frange(Y_MIN, Y_MAX, Y_STEP):
print "Found x center at ", mean_val
scx.move(mean_val)
break
except Exception as e:
print "Invalid x fit for y=", y, str(e)
except:
print "Invalid x fit for y=", y, ": ", sys.exc_info()[0]
step += 1
r = cscan(scy, sensor, Y_MIN, Y_MAX, 0.01, latency = DIODE_SETTLING_TIME)
r = cscan(scy, sensor, y-MAX_SAMPLE_SIZE/2, Y_MAX+MAX_SAMPLE_SIZE/2, SCAN_RESOLUTION, latency = DIODE_SETTLING_TIME)
xdata = enforce_monotonic(r.getPositions(0))
ydata = r.getReadable(0)
(offset, normalization, mean_val, sigma) = mathutils.fit_gaussian_offset(ydata, xdata)