Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
### Baseline is of the type y = a*exp(-log(2)*((x-b)/c)**2)
# optional parameters
p0_gauss = kwargs.get('p0_gaussian',[1.,1.,1.])
## fit of the baseline
coeffs, pcov = curve_fit(rampy.gaussian,yafit[:,0],yafit[:,1],p0 = p0_gauss)
baseline_fitted = rampy.gaussian(x,coeffs[0],coeffs[1],coeffs[2])
elif method == 'exp':
### Baseline is of the type y = a*exp(b*(x-xo))
# optional parameters
p0_exp = kwargs.get('p0_exp',[1.,1.,1.])
## fit of the baseline
coeffs, pcov = curve_fit(rampy.funexp,yafit[:,0],yafit[:,1],p0 = p0_exp)
baseline_fitted = rampy.funexp(x,coeffs[0],coeffs[1],coeffs[2])
elif method == 'log':
### Baseline is of the type y = a*exp(b*(x-xo))
# optional parameters
p0_log = kwargs.get('p0_log',[1.,1.,1.,1.])
## fit of the baseline
coeffs, pcov = curve_fit(rampy.funlog,yafit[:,0],yafit[:,1],p0 = p0_log)
baseline_fitted = rampy.funlog(x,coeffs[0],coeffs[1],coeffs[2],coeffs[3])
elif method == 'rubberband':
# code from this stack-exchange forum
#https://dsp.stackexchange.com/questions/2725/how-to-perform-a-rubberband-correction-on-spectroscopic-data
# Find the convex hull
v = ConvexHull(np.array([x, y])).vertices
elif method == 'gaussian':
### Baseline is of the type y = a*exp(-log(2)*((x-b)/c)**2)
# optional parameters
p0_gauss = kwargs.get('p0_gaussian',[1.,1.,1.])
## fit of the baseline
coeffs, pcov = curve_fit(rampy.gaussian,yafit[:,0],yafit[:,1],p0 = p0_gauss)
baseline_fitted = rampy.gaussian(x,coeffs[0],coeffs[1],coeffs[2])
elif method == 'exp':
### Baseline is of the type y = a*exp(b*(x-xo))
# optional parameters
p0_exp = kwargs.get('p0_exp',[1.,1.,1.])
## fit of the baseline
coeffs, pcov = curve_fit(rampy.funexp,yafit[:,0],yafit[:,1],p0 = p0_exp)
baseline_fitted = rampy.funexp(x,coeffs[0],coeffs[1],coeffs[2])
elif method == 'log':
### Baseline is of the type y = a*exp(b*(x-xo))
# optional parameters
p0_log = kwargs.get('p0_log',[1.,1.,1.,1.])
## fit of the baseline
coeffs, pcov = curve_fit(rampy.funlog,yafit[:,0],yafit[:,1],p0 = p0_log)
baseline_fitted = rampy.funlog(x,coeffs[0],coeffs[1],coeffs[2],coeffs[3])
elif method == 'rubberband':
# code from this stack-exchange forum
#https://dsp.stackexchange.com/questions/2725/how-to-perform-a-rubberband-correction-on-spectroscopic-data