Get mains out of my signal
Power-frequency interference gets picked up through insufficiently shielded instrumentation or electrically generated mechanical faults.
While correct installation, ground loop avoidance and elimination of other sources is the goal sometimes it is not possible.
Bellow is the timeseries and spectrum of an heterodyned output ultrasound sensor. It transfers the high frequency signals to the acoustic range.
As you see, 50 Hz is very prominent here resulting in a constant hum. You can also spot a lot of harmonics.
Queue the notch filter.
A notch filter is a type of band-stop filter, which is a filter that attenuates frequencies within a specific range while passing all other frequencies unaltered. For a notch filter, this range of frequencies is very narrow1. The range of frequencies that a band-stop filter attenuates is called the stopband.
Because we want to also catch the harmonica we can use a filter sampling frequency that is
a multiple of our power-frequency.
The ideal result in a the time domain will look as bellow2.
Doing that to our signal results in a much cleaner representation for the other phenomena.
Harmonics are still there but affect much less the signal. One could certainly phase them out but I used Audacity which does not feature sampling rate settings for notch filters so I went manual and I stopped. I will dig into that more in the future.