1
$\begingroup$

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:

enter image description here

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?

$\endgroup$
0
$\begingroup$

You will need to fit a convex hull to the data (e.g., reflectance as a function of the wavelength). The SciPy packages has the tool you need, see https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html.

After that you will need to subtract the convex hull value from the actual value after interpolation along the convex hull, see https://docs.scipy.org/doc/scipy/reference/interpolate.html.

$\endgroup$
  • $\begingroup$ hi, thanks, I still did not get the result I was aiming for. I edited my question accordingly. $\endgroup$ – user88484 Jan 23 '18 at 6:39
  • $\begingroup$ 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. $\endgroup$ – Biswajit Banerjee Jan 24 '18 at 1:40
  • $\begingroup$ I understand what I'm suppose to do in order to get what I want, I use CR algorithm in ENVI software, but can you assist me in how to do it? I mean script-wise, how do I choose the appropriate pairs of data and interpolate? and, can I change a parameter so the ConvexHull will capture the local max in 550? $\endgroup$ – user88484 Jan 25 '18 at 5:30
  • $\begingroup$ To get the local max. at 550 nm you will need to break the data up and create two hulls. The convex hull (in your problem) is the convex polygon that surrounds all points. For an interpolation example, see docs.scipy.org/doc/numpy-1.13.0/reference/generated/… . To locate the end points of the upper hull just write a loop and check. It's straightforward to do that. $\endgroup$ – Biswajit Banerjee Jan 25 '18 at 22:02
-2
$\begingroup$

@Biswajit Banerjee - thanks for the help but I found a more suitable module for my needs to perform the continuum removal algorithm: spectro in pysptools

$\endgroup$
  • 1
    $\begingroup$ This answer should be added to the question instead as a separate answer. $\endgroup$ – nicoguaro Jan 30 '18 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.