pwtools.num.PolyFit1D¶
- class pwtools.num.PolyFit1D(*args, **kwds)[source]¶
-
1D special case version of
PolyFit
which handles 1d and scalar points Alsoget_min()
uses the root of the poly’s 1st derivative instead offmin()
.__init__: points (npoints,1) or (npoints,)__call__: points (npoints,1) or (npoints,) or scalarExamples
>>> x=np.linspace(-5,5,10); y=(x-1)**2+1 >>> f=num.PolyFit1D(x,y,2) >>> f(0) 2.0000000000000009 >>> f.get_min() 1.0 >>> xx = linspace(x[0],x[-1],50) >>> plot(x,y,'o', label='data') >>> plot(xx, f(xx), label='poly') >>> plot(xx, f(xx,der=1), label='d(poly)/dx') >>> legend()
- __call__(points, **kwds)¶
Call self as a function.
Methods
get_max
([x0, xab])Convenience method.
get_min
([x0, xab])Return x where y(x) = min(y) by calculating the root of the fit's 1st derivative (by calling
self(x, der=1)
).get_root
([x0, xab])Return x where y(x) = 0 by calculating the root of the fit function.
is_mono
()Return True if the curve described by the fit function f(x) is monotonic.