1
$\begingroup$

I'm trying to design the highpass filter in Python for my accelerometer data in order to integrate them. I need to preserve low frequencies. For example, data with a sampling frequency of 2 kHz need to have a highpass filter with a cutoff frequency of 1 Hz, maybe even 0.5 Hz. Unfortunately, scipy signal filters (I tried all of them) cannot design the highpass filter so low. In the image below you can see that under 10 Hz nothing changes even with different order.Filter designs - Butterworth I tried web filter designs (e.g. https://fiiir.com/ ) and have the same result - not possible to go lower. On the other hand, when using the same filter in LabVIEW, the filter works great even for lower frequencies. Where's the mistake? And how can I solve it? Here's the code in case it's not a theoretical issue:

data=TDMS_reader(folder,file,ch_lst=ch_lst)
fs=1/(data[1,0]-data[0,0]) #sampling frequency


cutoff=[0.5,1,10] #freq in Hz
order=[2,4]

for i in range(len(cutoff)):
    for j in range(len(order)):
        sosv=signal.butter(order[j], cutoff[i], 'highpass',fs=fs,output="sos")
        w, h = signal.sosfreqz(sosv, fs=fs)

Thanks for all your help.

$\endgroup$

1 Answer 1

1
$\begingroup$

That's just a plotting resolution artifact.

Increase your plot resolution the following way:

w, h = signal.sosfreqz(sosv, worN=4*fs, fs=fs)
$\endgroup$
2
  • $\begingroup$ Thanks, this helps! $\endgroup$
    – Martin E.
    Jul 4 at 5:45
  • $\begingroup$ @MartinE. no problem, don’t forget to mark the answer accepted if you’re satisfied so the question doesn’t keep coming back up and others can benefit ;) $\endgroup$
    – Jdip
    Jul 4 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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