
Hampel filter a stack over its time axis.
hampel_smooth.RdThe classic despiking filter: for each time step, a centred window of
k steps either side supplies a median and a MAD (median absolute
deviation, scaled by 1.4826 to estimate a standard deviation); an
observation further than t0 MADs from the window median is replaced
by that median. Missing steps (NaN) are skipped by the window
statistics and stay missing in the output: this filter removes
spikes, it does not fill gaps (compose with fill_gaps() or
kalman_smooth() for that).
Details
The window is positional (k slices, not calendar days), and shrinks
at the series ends. t0 = 0 degenerates to a rolling median. With
t0 > 0, note the MAD of a window whose valid values are mostly
identical is 0, so any deviating centre is replaced; this is inherent
to the Hampel construction.
Like every garry verb it is lazy (nothing computes until
collect()), and it applies per band over a LazyDataset.