-1
$\begingroup$

I want to use high pass filter to filter frequency less than 100Hz. I use this code in python.

def butter_highpass(lowcut, fs, order=9):
nyq = 0.5 * fs
low = lowcut / nyq
b, a = butter(order, low, btype='high', analog = False)
return b, a

def butter_highpass_filter(data, lowcut,  fs, order=9):
b, a = butter_highpass(lowcut, fs, order=order)
y = lfilter(b, a, data)
return y

My signal before filter (use plt.magnitude_spectrum function): enter image description here

and my signal after filter:

enter image description here

It show that some new frequency appear(from 200Hz -> 2000Hz). and I don't know why?. Can anyone explain why? Thank you

$\endgroup$
1
$\begingroup$

If there was nothing wrong with your filtering, the “new” frequencies were always there, but too small to see on the scale of your first plot.

If you had plotted the logarithm of magnitude instead of linear magnitude, the spectral components would have been more obvious.

To summarize, the “new” frequencies probably aren’t new, just too small to see given the scale of the first plot.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.