xdas.signal.medfilt#
- xdas.signal.medfilt(da, kernel_dim)[source]#
Perform a median filter along given dimensions.
Apply a median filter to the input using a local window-size given by kernel_size. The array will automatically be zero-padded.
- Parameters:
da (DataArray) – A dataarray to filter.
kernel_dim (dict) – A dictionary which keys are the dimensions over which to apply a median filtering and which values are the related kernel size in that direction. All values must be odd. If not all dims are provided, missing dimensions are associated to 1, i.e. no median filtering along that direction. At least one dimension must be passed.
- Returns:
The median filtered data.
- Return type:
Examples
A median filter is applied to some synthetic dataarray with a median window size of 7 along the time dimension and 5 along the space dimension.
>>> import xdas.signal as xs >>> from xdas.synthetics import wavelet_wavefronts
>>> da = wavelet_wavefronts() >>> xs.medfilt(da, {"time": 7, "distance": 5}) <xdas.DataArray (time: 300, distance: 401)> [[ 0. 0. 0. ... 0. 0. 0. ] [ 0. 0. 0. ... 0. 0. 0. ] [ 0. 0. 0. ... 0. 0. 0. ] ... [ 0. 0. 0. ... -0.000402 0. 0. ] [ 0. 0. 0. ... 0. 0. 0. ] [ 0. 0. 0. ... 0. 0. 0. ]] Coordinates: * time (time): 2023-01-01T00:00:00.000 to 2023-01-01T00:00:05.980 * distance (distance): 0.000 to 10000.000