Closedown
This commit is contained in:
+11
-12
@@ -28,24 +28,22 @@ def fit(ydata, xdata = None):
|
||||
max_y= max(ydata)
|
||||
index_max = ydata.index(max_y)
|
||||
max_x= xdata[index_max]
|
||||
print "Max indexs: " + str(index_max),
|
||||
print " Max x: " + str(max_x),
|
||||
print " Max y: " + str(max_y)
|
||||
print "Max index:" + str(index_max),
|
||||
print " x:" + str(max_x),
|
||||
print " y:" + str(max_y)
|
||||
|
||||
gaussians = fit_gaussians(ydata, xdata, [index_max,])
|
||||
(norm, mean, sigma) = gaussians[0]
|
||||
|
||||
|
||||
p = plot([ydata],["data"],[xdata], context="Fit" )[0]
|
||||
fitted_gaussian_function = Gaussian(norm, mean, sigma)
|
||||
|
||||
fitted_gaussian_function = Gaussian(norm, mean, sigma)
|
||||
scale_x = [float(min(xdata)), float(max(xdata)) ]
|
||||
resolution = (scale_x[1]-scale_x[0]) / 100
|
||||
print resolution
|
||||
points = max((len(xdata)+1), 100)
|
||||
resolution = (scale_x[1]-scale_x[0]) / points
|
||||
fit_y = []
|
||||
for x in frange(scale_x[0],scale_x[1],resolution, True):
|
||||
fit_y.append(fitted_gaussian_function.value(x))
|
||||
fit_x = frange(scale_x[0], scale_x[1]+resolution, resolution)
|
||||
#plots = plot([ydata, fit_y] ,["data", "fit"], xdata = [xdata,fit_x], context="Fit")
|
||||
fit_x = frange(scale_x[0],scale_x[1],resolution, True)
|
||||
for x in fit_x:
|
||||
fit_y.append(fitted_gaussian_function.value(x))
|
||||
p.addSeries(LinePlotSeries("fit"))
|
||||
p.getSeries(1).setData(fit_x, fit_y)
|
||||
|
||||
@@ -57,6 +55,7 @@ def fit(ydata, xdata = None):
|
||||
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])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user