median_filter

function of dascore.proc.filter source

median_filter(
    patch: Patch ,
    samples = False,
    mode = reflect,
    cval = 0.0,
    **kwargs ,
)-> ‘PatchType’

Apply 2-D median filter.

Parameters

Parameter Description
patch The patch to filter
samples {sample_explination}
mode The mode for handling edges.
cval The constant value for when mode == constant.
**kwargs Used to specify the shape of the median filter in each dimension.
See examples for more info.

Examples

import dascore
from dascore.units import m, s
pa = dascore.get_example_patch()
 # 1. Apply median filter only over time dimension with 0.10 sec window
filtered_pa_1 = pa.median_filter(time=0.1)
 # 2. Apply median filter over both time and distance
 # using a 0.1 second time window and 2 m distance window
filtered_pa_2 = pa.median_filter(time=0.1 * s, distance=2 * m)
 # 3. Apply median filter with 3 time samples and 4 distance samples
filtered_pa = pa.median_filter(
    time=3, distance=4, samples=True,
)
Note

See scipy.ndimage.median_filter for more info on implementation and arguments.

Values specified with kwargs should be small, for example < 10 samples otherwise this can take a long time and use lots of memory.