import dascore
from dascore.units import m, s
= dascore.get_example_patch()
pa # 1. Apply median filter only over time dimension with 0.10 sec window
= pa.median_filter(time=0.1)
filtered_pa_1 # 2. Apply median filter over both time and distance
# using a 0.1 second time window and 2 m distance window
= pa.median_filter(time=0.1 * s, distance=2 * m)
filtered_pa_2 # 3. Apply median filter with 3 time samples and 4 distance samples
= pa.median_filter(
filtered_pa =3, distance=4, samples=True,
time )
median_filter
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 |
If True, the values in kwargs and step represent samples along a dimension. Must be integers. Otherwise, values are assumed to have same units as the specified dimension, or have units attached. |
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
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.