deriv_even

deriv_even(h, y, /, order=1, axis=0, accuracy=2, cyclic=False, keepedges=False)[source]

Return an estimate of the first, second, or third order derivative along an arbitrary axis using centered finite differencing.

Parameters
  • h (float or array-like) – The scalar step size or the coordinate array. If the latter and the coordinates are unevenly spaced, an error is raised.

  • 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 finite difference method. Options are 2, 4, and 6, corresponding to centered accuracies of \(h^2\), \(h^4\), and \(h^6\), respectively. See this wikipedia page for the table of coefficients associated with each accuracy.

Returns

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