scientimate.findextremum#
xmin, ymin, xmax, ymax = scientimate.findextremum(x, y, winlen=3, dispout='no')
Description#
Find local extremum (minimum and maximum) in data
Inputs#
- x
x data
- y
y data
- winlen=3
- Window length, defines a number of points in sliding window used for defining maximum and minimumExample: winlen=5 means two points on each side of each data point is used in calculationUsing a larger value for winlen makes it less sensitivewinlen should be an odd number equal or larger than 3
- dispout=’no’
Define to display outputs or not (‘yes’: display, ‘no’: not display)
Outputs#
- xmin
x of minmum points
- ymin
y of minmum points
- xmax
x of maximum points
- ymax
y of maximum points
Examples#
import scientimate as sm
import numpy as np
x=np.linspace(0,30,1000)
y=2*np.exp(-0.1*2*np.pi/5*x)*np.sin(np.sqrt(1-0.1**2)*2*np.pi/5*x)
xmin,ymin,xmax,ymax=sm.findextremum(x,y,3,'yes')
x=np.linspace(0,50,1000)
y=np.sin(x)+0.1*np.random.rand(1000)
xmin,ymin,xmax,ymax=sm.findextremum(x,y,15,'yes')