diff --git a/script/local.py b/script/local.py index b1800f0..dec4048 100644 --- a/script/local.py +++ b/script/local.py @@ -55,6 +55,6 @@ def fit(ydata, xdata = None): else: p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.Gray) print "Invalid gaussian fit: " + str(mean) - + return (None, None, None) #fit([1,2,3, 3,3,3,4,5,6,12,33,23,15,3,2,1, 1, 1, 1, 1]) diff --git a/script/rock.py b/script/rock.py index 4948790..3dc2fc0 100644 --- a/script/rock.py +++ b/script/rock.py @@ -28,8 +28,17 @@ def rock(axis = th1, ffail = False, tt = 0.2, seti0 = False, dx = None, noref = #MVR,axis,-dx #SCAN,axis,0,2*dx,20,/fit,/centre,SILENT = silent,FFAIL = ffail,time=tt,/deriv,$ #data=d + axis_pos = axis.read() lscan(axis, beam_ref, -dx, dx, 20, latency = 0.3, relative = True, context = None, before_read = None, after_read = None) - LSCAN() + (ydata, xdata) = (result.getReadable(0), result.getPositions(0)) + (norm, mean, sigma) = fit(ydata, xdata) + if (mean is not None) and (mean <= (axis_po + dx)) and (mean >= (axis_po - dx)): + caput(axis, mean) + else + print 'fit failed - centering on maximum' + max_x= xdata[ydata.index(max(ydata))] + caput(axis, max_x) + if seti0 and not ffail: time.sleep(2)