Guest User

Untitled

a guest
Mar 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. require(hyperSpec)
  2. spc <- read.spe("paracetamol.SPE")
  3. baseline <- spc.rubberband(spc)
  4.  
  5. corrected <- spc - baseline
  6.  
  7. import numpy as np
  8. from scipy.spatial import ConvexHull
  9.  
  10. def rubberband(x, y):
  11. # Find the convex hull
  12. v = ConvexHull(np.array(zip(x, y))).vertices
  13.  
  14. # Rotate convex hull vertices until they start from the lowest one
  15. v = np.roll(v, -v.argmin())
  16. # Leave only the ascending part
  17. v = v[:v.argmax()]
  18.  
  19. # Create baseline using linear interpolation between vertices
  20. return np.interp(x, x[v], y[v])
  21.  
  22. y = y - rubberband(x, y)
Add Comment
Please, Sign In to add comment