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][1].

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][2]][2]

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? [1]: http://www.harrisgeospatial.com/docs/ContinuumRemoval.html [2]: https://i.sstatic.net/C5qah.jpg

UPDATE: Thanks you all for your help- I found a more suitable module for my needs to perform the continuum removal algorithm: spectro in pysptools

$\endgroup$

1 Answer 1

1
$\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$
4
  • $\begingroup$ hi, thanks, I still did not get the result I was aiming for. I edited my question accordingly. $\endgroup$
    – user88484
    Commented Jan 23, 2018 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$ Commented Jan 24, 2018 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
    Commented Jan 25, 2018 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$ Commented Jan 25, 2018 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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