From f02602c3f1554395d60a1f26522dca8b17e58deb Mon Sep 17 00:00:00 2001 From: gac-x04sa Date: Thu, 25 Jan 2018 11:17:12 +0100 Subject: [PATCH] Script execution --- script/scans/SampleSearch.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/script/scans/SampleSearch.py b/script/scans/SampleSearch.py index f2de904..c7e458c 100644 --- a/script/scans/SampleSearch.py +++ b/script/scans/SampleSearch.py @@ -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)