def linear_fit( x,y, xrange=None):
'''YG Octo 16,2017 copied from XPCS_SAXS
a linear fit
'''
if xrange is not None:
xmin, xmax = xrange
x1,x2 = find_index( x,xmin,tolerance= None),find_index( x,xmax,tolerance= None)
x_ = x[x1:x2]
y_ = y[x1:x2]
else:
x_=x
y_=y
D0 = np.polyfit(x_, y_, 1)
gmfit = np.poly1d(D0)
return D0, gmfit
评论列表
文章目录