I have a digital on/off signal sampled at a regular interval. There was a problem with the sensor that produced the signal which has sometimes caused a regular on/off ticking when the sensor should be in the off state. I.e. sometimes when the readings should be zero, there is a square wave instead (but with an unequal mark:space).
How would I go about designing a filter to remove this square wave (i.e. output a zero if there is this regular ticking occurring, output the input value otherwise)?
The ticking has a frequency of around 16 minutes, the events that the sensor was observing might last anything from one minute to a few hours. I expect that this means that perfect recovery of the correct data is impossible, but I’d like to get as close as possible.
I would think some kind of notch filter is what I need, but everything I’ve found so far seems to be about filtering analogue signals.
(My memory of signal processing courses is a bit patchy, hopefully I’ve used the right terms here).
Thanks for your comments so far. I've attached an image illustrating what I am trying to achieve. Also I wrote the wrong frequency for the regular ticking - it's actually 16 minutes, not 8, but I doubt that affects the overall approach.
@Jan - yes, ideally I would just have a better sensor, but this is the data I have for now, I don't currently have the option of switching to a different sensor.
The data processing is happening offline, so non causal solutions are fine.