deriv_uneven¶
- deriv_uneven(x, y, /, order=1, axis=0, accuracy=2, cyclic=False, 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, i.e. the \(n\) in \(d^ny/dx^n\). Default is
1
.axis (int, optional) – Axis along which derivative is taken.
dim (str, optional) – For `xarray.DataArray` input only. Named dimension along which derivative is taken.
cyclic (bool, optional) – Whether to treat the axis cyclically. If
True
, the dimension size is not reduced. This is appropriate for derivatives across longitudes and cyclic idealized model domains.keepedges (bool, optional) – Whether to fill the edge positions with progressively lower-
accuracy
finite difference estimates to prevent reducing the dimension size.accuracy ({2, 4, 6, …}, optional) – Accuracy of the finite difference approximation. This determines the number of terms sandwiching each point that go into the [For88] algorithm. Using too many terms can result in overfitting.
- 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.
See also