Check the derivative for local maxima. If so, find the local maximum with the highest derivative using samples, gs, of df. The keyword variables kwargs are passed to scipy’s find_peaks.