wradlib.util.UtilMethods#
- class wradlib.util.UtilMethods(obj)[source]#
Bases:
XarrayMethods
wradlib xarray SubAccessor methods for Util.
- despeckle(**kwargs)[source]#
Remove floating pixels in between NaNs in a multi-dimensional array.
- Parameters
obj (
xarray.DataArray
) – input array- Keyword Arguments
n (
int
) – (must be either 3 or 5, 3 by default), Width of the window in which we check for speckle- Returns
out (
xarray.DataArray
) – output array
- derivate(**kwargs)[source]#
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.
- Parameters
obj (
xarray.DataArray
) – input array- Keyword Arguments
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.method2 (
str
) – Defaults to ‘_nan’ methods.min_periods (
int
) – Minimum number of valid values in moving window for linear regression. Defaults to winlen // 2 + 1.pad_kwargs (
dict
) – Keyword arguments for padding, seenumpy.pad
- Returns
out (
xarray.DataArray
) – array of derivates
|
Calculates derivative of data using window of length winlen. |
|
Remove floating pixels in between NaNs in a multi-dimensional array. |
|
Return major dimension (azimuth/elevation) of xarray object. |