I have to apply continuum removal on a graph and I have used scipy convexhull function to find convex hull, now i have to apply continuum removal.
here is the code-
import pandas as pd
import numpy as np
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
data=open('15C80D4_00002.txt')
d=pd.read_table(data, sep=r'\t',header=None, names=['Wvl', 'Reflectance'],skiprows=1,
engine='python')
x=d.iloc[:,:1]
a1=np.array(x)
y=d.iloc[:,1:]
b1=np.array(y)
points=np.concatenate((a1,b1), axis=1)
fig = plt.figure()
ax = fig.subplots()
hull = ConvexHull(points)
for simplex in hull.simplices:
ax.plot(points[simplex,0], points[simplex,1], 'k-')
on plotting the graph i get convex hull graph
- i dont want the bottom line, only upper part
- i want the graph to be something like this picture, the graph should come in same axis after continuum removal
how can this be done?
1条答案
按热度按时间qaxu7uf21#
Continuum removal equates to division of the spectrum by its convex hull. The basic idea in the implementation below is that we add two points, one at each end of the line, which have a lower y-value than any other point, and are thus guaranteed to form the "lower" part of the convex hull.
After the convex hull computation, we simply remove them again and are left with the "upper" part of the hull. From there you just have to interpolate the hull at the given x-coordinates to get a corresponding y' value, which you subtract from the original y-values.