atompy.integral_polyfit#

atompy.integral_polyfit(x, y, lower=-inf, upper=inf, fit_degree=5, showfit=False)[source]#

Get the integral of the data. The integral is determined with by integrating a polynomial fit.

Parameters:
x, yarray_like

x, y data

lower/upperfloat, default -/+ numpy.inf

if specified, only calculate integral within the given range

fit_degreeint, default 5

Degree of the polynomial used for the fit

showfitbool, default False

Show a fit for each set of ydata (to check if fit is any good)

Returns:
integralfloat

The value of the integral

Examples

::
>>> import numpy as np
>>> import atompy as ap
>>> x, y = np.linspace(0, 2, 5), np.linspace(0, 4, 5)**2
>>> x, y
([0.  0.5 1.  1.5 2. ], [ 0.  1.  4.  9. 16.])
>>> ap.integral_polyfit(x, y, fit_degree=2)
10.66