19 lines
384 B
Python
19 lines
384 B
Python
import numpy as np
|
|
|
|
|
|
def ext(x, y):
|
|
"""
|
|
Return extremum coordinates of quadratic fit
|
|
"""
|
|
p = np.polyfit(x, y, 2)
|
|
f = np.poly1d(p)
|
|
x_fit = 1.0 #np.linspace(min(x), max(x), 100)
|
|
#y_fit = 2.0 #f(x_fit)
|
|
if p[0] != 0:
|
|
x_ext = -p[1]/2/p[0]
|
|
y_ext = f(x_ext)
|
|
else:
|
|
x_ext = None
|
|
y_ext = None
|
|
return (x_ext, y_ext, x_ext)
|