Today in Office Hours I ran into an interesting problem when using the removeoutliers() function on a signal that also had gaps in the data. If you use the function directly on a signal of this type it will not detect the outlier point as you might expect. However there is a quick work around that I will detail below.
The signal looks like the one above where the outlier was right after a data gap. In order to work around this problem we chained together a couple of functions in formula.
$gaps = $signal.isValid()
$signal.validValues().removeOutliers().within($gaps)
Step 1 - create a condition $gaps that captures only the periods of time that contained valid data in the original signal
Step 2 - use the validValue() function to ignore the gaps in the original signal, next run the removeoutliers() function finally add back in the gaps by using the within function