derivate(data, winlen=7, method='lanczos_conv', skipna=False, **kwargs)¶
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.
numpy.ndarray) – multi-dimensional array, note that the derivation dimension must be the last dimension of the input array.
winlen (int) – Width of the derivation window .
method (str) – Defaults to ‘lanczos_conv’. Can take one of ‘lanczos_dot’, ‘lstsq’, ‘cov’, ‘cov_nan’, ‘matrix_inv’.
skipna (bool) – Defaults to False. If True, treat NaN results by applying method2.
- Keyword Arguments
numpy.ndarray) – array of derivates with the same shape as data