I want to smoothen the oscillations from this data and let only the higher values stay in the curve. I have written a code for that and it seems to work. However, it feels like a fix rather than a solution. I was wondering if there is a more proper way to smoothen this curve and choose only the higher values in the oscillations stay?
here you can see the code and the results.
def smoothingfunction(xarr, yarr):
import numpy as np
#x0_42, y0_42
New_y = np.zeros(0)
New_x = np.zeros(0)
for i in np.arange(15, len(yarr[15:]), 1):
if yarr[i]>yarr[i-1] and yarr[i]>yarr[i-2] and yarr[i]>yarr[i-3] and yarr[i]>yarr[i-4] and yarr[i]>yarr[i-5] and yarr[i]>yarr[i-6]:
New_y = np.append(New_y, yarr[i])
New_x = np.append(New_x, xarr[i])
return np.concatenate((xarr[0:15], New_x)) , np.concatenate((yarr[0:15],New_y))
Sx0_4nous1, Sy0_4nous1 = smoothingfunction(x0_4nous1, y0_4nous1)