I try to get a Poplynom from Polyfit for a specific region without any Peaks.
nan_indices = np.where(np.isnan(x))[0]
x = np.delete(np.array(x_start), nan_indices)
y = np.delete(np.array(y_start), nan_indices)
z = np.polyfit(np.log(x), y, 1)
#print(z)
p = z[0] * np.log(x) + z[1]
#p = np.poly1d(z)
alpha = z[0]
offset = z[1]
#add trendline to plot
plt.plot(x, p, color='navy',linestyle='--' )
local_max_indices, _ = find_peaks(x_start.to_numpy(), distance = 1)
It kind of looks like in the given image and i marked the area which i want to use for the polynom (linear). I am quiet new at python so maybe my solution by deleting the max indices is not the best idea.
So in the first step i detect Peaks with the find_peaks function from Scipy and save the indices I just want to delet this indices before i run the polyfit function. It sounds simple but the polynom does not really show a difference to the polynom including the peak.
LuLuK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.