RSKdespike.m

Arguments

Input

 -Required-

  • RSK 
  • channel : longName.

-Optional-

  • profile : [ ] (all profiles default).
  • direction : up, down (default) or both.
  • threshold : 2 (default).
  • windowLength : 3 (default).
  • action : NaN (default), replace, or interp.
  • visualize: show plot with original, processed and flagged data on specified profile(s)

Output

  • RSK
  • spike : spike indices


This function removes or replaces spikes in the data from the channel specified.  The algorithm used here is to discard points that lie outside of a threshold.  The data are smoothed by a median filter of length windowLength to produce a "reference" time series. Residuals are formed by subtracting the reference time series from the original time series.  Residuals that fall outside of a threshold, specified as the number of standard deviations, where the standard deviation is computed from the residuals, are flagged for removal or replacement.

The default behaviour is to replace the flagged values with NaNs. Flagged values can also be replaced with reference values, or replaced with values linearly interpolated from neighbouring "good" values.

Example:

[rsk, spike] = RSKdespike(rsk,'channel','Temperature','profile',3:5,'direction','down','threshold',4,'windowLength',11,'action','nan');



The red circles indicate the samples in the blue time series that are spikes.
The green lines are the limits determined by the threshold parameter.
The black time series is, as referred to above, the reference series. It is the filtered original time series.