Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require(hyperSpec)
- spc <- read.spe("paracetamol.SPE")
- baseline <- spc.rubberband(spc)
- corrected <- spc - baseline
- import numpy as np
- from scipy.spatial import ConvexHull
- def rubberband(x, y):
- # Find the convex hull
- v = ConvexHull(np.array(zip(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
- return np.interp(x, x[v], y[v])
- y = y - rubberband(x, y)
Add Comment
Please, Sign In to add comment