#SG平滑
import numpy as np
from scipy.signal import savgol_filter
from matplotlib import pyplot as plt
np.set_printoptions(precision=2) # For compact display.
x = np.array([2, 2, 5, 2, 1, 0, 1, 4, 9])
newx = savgol_filter(x, 5, 2)
print(newx)
plt.plot(x, label='x')
plt.plot(newx, label='newx')
plt.xlabel('Wavelangth')
plt.ylabel('Ref')
plt.title('this is a demo')
plt.show()
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html