# Continuum removal algorithm in python

I'm using python 2.7 (on jupyter notebook, win10 64 bit) to perform my analysis. I need to perform continuum removal (CR) on a reflectance spectrum data. I need it to be as described here.

EDITED:

I used the following code to perform CR on a reflectance spectrum:

from scipy.spatial import ConvexHull
import numpy as np
import matplotlib.pyplot as plt

i = Xdata.iloc[15,:] #get the data from a pandas df
ii = i.tolist()
mat = np.column_stack((wavelenght_list,ii))
hull = ConvexHull(mat)
plt.plot(mat[:,0], mat[:,1], 'o')
for simplex in hull.simplices:
plt.plot(mat[simplex, 0], mat[simplex, 1], 'k-')

The result I get is:

I have 3 questions about it:

1) Why it did not capture the local maxima at 550?

2) How can I remove the baseline of the convelHull (the black curve)?

3) How can I divide my spectrum by the "upper" conveHull in order to get CR spectrum?

• At this point you will have to select the points on the convex hull that are above your blue line and find the values of reflectance on that hull (say, $R_h$) corresponding to the wavelengths of the original data (suing interpolation). If the original reflectance was $R$, then the quantity you want is $R/R_h$. You can split the hull into two parts (upper and lower), based on the end points. – Biswajit Banerjee Jan 24 '18 at 1:40