deriv_uneven

deriv_uneven(x, y, /, order=1, axis=0, accuracy=2, keepedges=False)[source]

Return an arbitrary order centered finite difference approximation for arbitrarily spaced coordinates using the [For88] method.

Parameters
  • x (float or array-like) – The step size, a 1-d coordinate vector, or an array of coordinates matching the shape of y.

  • y (array-like) – The data.

  • order (int, optional) – The order of the derivative. Default is 1.

axisint, optional

Axis along which derivative is taken.

dimstr, optional

For `xarray.DataArray` input only. Named dimension along which the derivative is taken.

accuracy{2, 4, 6, …}, optional

Accuracy of the finite difference approximation. This determines the number of terms that go into the [For88] algorithm. Using too many terms can result in overfitting.

keepedgesbool, optional

Whether to fill left, right, or both edge positions with progressively lower-accuracy finite difference estimates to prevent reducing the dimension size along axis axis.

Returns

diff (array-like) – The “derivative”.

References

For88(1,2)

Bengt Fornberg. Generation of finite difference formulas on arbitrarily spaced grids. Mathematics of Computation, 51(184):699–706, 1988. doi:10.1090/S0025-5718-1988-0935077-0.