def FitPCA(self, hPCA_Proj):
'''
Determine the timing of the inflation event from the first component of the pca projection
fits A * arctan( (t - t0) / c ) + B to the first pca projection, in order to estimate
source amplitude parameters
@param hPCA_Proj: The sklearn PCA
@return ct: the t0, c, and B parameters from the fit
@return pA[0]: the fitted amplitude parameter
'''
fitfunc = lambda p,t: p[0]*np.arctan((t-p[1])/p[2])+p[3]
errfunc = lambda p,x,y: fitfunc(p,x) - y
dLen = len(hPCA_Proj[:,0])
pA, success = optimize.leastsq(errfunc,[1.,dLen/2.,1.,0.],args=(np.arange(dLen),hPCA_Proj[:,0]))
ct = pA[1:3]
return ct, pA[0]
评论列表
文章目录