34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
import mathutils
|
|
import plotutils
|
|
|
|
|
|
#A area scan (2d) on x & y
|
|
ascan([scx, scy], [scd,], [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.1, 0.1], latency = 0.0, relative = False, zigzag = True)
|
|
|
|
|
|
|
|
# A line scn (1d) on Y
|
|
scy.move(0.0)
|
|
#r = lscan(scx, scd, scx.minValue, scx.maxValue, 0.1, latency = 0.0)
|
|
xdata = r.getPositions(0)
|
|
ydata = r.getReadable(0)
|
|
maxy=max(ydata)
|
|
maxx=ydata.indexOf(maxy)
|
|
print "maxx =" , maxx
|
|
print "maxy =" , maxy
|
|
|
|
|
|
#Fitting a gaussian on the 1d scan
|
|
(normalization, mean_val, sigma) = mathutils.fit_gaussian(ydata, xdata)
|
|
print "fit mean = ", mean_val
|
|
#Plotting the gaussian
|
|
gaussian = mathutils.Gaussian(normalization, mean_val, sigma)
|
|
plotutils.plot_function(get_plots(None)[0], gaussian, "Fit", frange(scx.minValue, scx.maxValue, 0.01))
|
|
|
|
|
|
#Binary search for maximum
|
|
r = bsearch([scx, scy], scd, [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.01, 0.01], maximum=True, strategy = "FullNeighborhood", latency = 0.01, title = "Binary Search")
|
|
|
|
#Hill-climbing search for maximum
|
|
r = hsearch([scx, scy], scd, [scx.minValue,scy.minValue], [scx.maxValue,scy.maxValue], [0.2, 0.2], [0.01, 0.01], noise_filtering_steps = 3, relative = False, maximum=True, latency = 0.01, title = "Hill Climbing")
|