Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
# Rotate convex hull vertices until they start from the lowest one
v = np.roll(v, -v.argmin())
# Leave only the ascending part
v = v[:v.argmax()]
# Create baseline using linear interpolation between vertices
### 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
# Rotate convex hull vertices until they start from the lowest one
v = np.roll(v, -v.argmin())
# Leave only the ascending part
v = v[:v.argmax()]
# Create baseline using linear interpolation between vertices
baseline_fitted = np.interp(x, x[v], y[v])