Calculates derivative of data using window of length winlen.
In normal operation the method (‘lanczos_conv’) uses convolution to estimate the derivative using Low-noise Lanczos differentiators. The equivalent method (‘lanczos_dot’) uses dot-vector sum product.
For further reading please see Differentiation by integration using orthogonal polynomials, a survey and Low-noise Lanczos differentiators.
The results are very similar to the moving window linear regression methods (cov, matrix_inv and lstsq), which are slower than the former (in order of appearance).
All methods will return NaNs in case at least one value in the moving window is NaN.
If skipna=True the locations of NaN results are treated by using local linear regression by method2 (default to cov_nan) where enough valid neighbouring data is available.
Before applying the actual derivation calculation the data is padded with mode=’reflect’ by default along the derivation dimension. Padding can be parametrized using kwargs.
xarray.DataArray) – input array
- Keyword Arguments
int) – Width of the derivation window .
str) – Defaults to ‘lanczos_conv’. Can take one of ‘lanczos_dot’, ‘lstsq’, ‘cov’, ‘cov_nan’, ‘matrix_inv’.
bool) – Defaults to False. If True, treat NaN results by applying method2.
str) – Defaults to ‘_nan’ methods.
int) – Minimum number of valid values in moving window for linear regression. Defaults to winlen // 2 + 1.
xarray.DataArray) – array of derivates