I am only mechanic engineering and I need to filter my acceleration from MEMS mobile phone which has a noise and drifts. Here is my data. Acceleration vs time from an app mobile phone ACCELERATION_VS_TIME.csv. Here is my working program BUTTER_FILTRATION.py. My results (displacement) are on the bottom (the last one curve, drawing).
Meanwhile I took a working example (the Butterworth bandpass filter 1 curve, drawing from the top) and some example data from the Internet referring to this example (2 from the top) which filtering 600 Hz. It works well. Then I load my acceleration vs time (3 from the top). I should make base line correction but I don't know how (4 from the top). In my program there is some trial of base line correction but it not helps. Then I use the Butterworth bandpass filter (5 from the top) which should filtering everything apart from 1.8 Hz. It is enough to pass everything between 1 and 2 Hz. It is my mass spring system which is moving up and down.
I tried many option and one of them is the best but not enough and I don't understand how to set up my filter especially fs - sampling frequency. I put 300 Hz because it gives the best results. My signal lasts 60 s and is sampled every 0.02 s what gives 500 Hz but the results after that I even worst. The 6 from the top is filtered acceleration, 7 from the top is first integration of the acceleration which gives velocity and the last one is the second integration of the velocity which gives displacement but still wrong and drifting - I don't know why.
I tried many filters and many options - nothing gave good results. I tried to set up the same like when I used SeismoSignal - commercial program which filtered my (the same data) very well!
SeismoSignal gaves me velocity and displacement which no drifts...I can't repeat the same in Python. It seems that using filters is not hard thing ....but there must be something I do in wrong way and I don't know what it can be. I am only mechanic engineering. I am not signals specialist. I try to use available resources for my own purposes like ordinary calculator...but it seems that I don't understand some things that for a signals specialist can be obvious and it makes that I have wrong results.
Can I ask for any help?
P.S I want to say thank you many of you because the talks started and you are trying to help me. Because of my English (I am not a native English speaker) it is hard to explain my problem clearly. That I am going to comment it more.
Please don't lock at the 1 i 2 drawings.....
I put it only to SHOW !!! that Butterworth filter WORKS for specific example and to prove that I can use it inside the Python and programming filters is not big deal. The problem is to understand how to set up ones data and proper use the Butterworth bandpass filter.
That example problem (blue curve signal) is filtered 600 Hz to obtain green one. And that is all !!! The example is available in the Internet
My problem starts from 3. Here is acceleration from MEMS from mobile phone with "g". The (5) should be done base line correction like in SeiSmoSignal. I tried but without success that why I put the same acceleration vs time without changes. The I projected my FILTER. It looks like in SeiSmoSignal but is very sensitive for fs. I put 300 Hz in other cases results are not to accept at all. (6) it is acceleration after filtration. It is peaty quite well but not so accurate like in SeiSmoSignal. (7) first integration of the acceleration which gives velocity and then next integration of velocity giving displacement but still DRIFTING...like included still some noise. Proper result shouls be sinusoidal displacement with max amplitude at the beginning about +/- 3.5 cm. At all! Problem is that I can't repeat it in Python what I obtained in SeiSmoSignal.
I hope it will more clear.
...filter has range between 0 to 1 because of course how we know the signal has to be normalised before it is being filtered...
I corrected it. My fault to fast.....I showed yy not yyy (filtered one) but first - in SeismoSignal it gives max. ~ +/- 3.5 - in my case the value is to low....and it doesn't change the displacement drifting. It is like some noise is still present in my filtered signal and then drifting is still active. I think that very important can be "base line correction" which I have in my program but it seems not to change anything or give even worst result (I put the last one picture with "my base line correction") and I think it is not quite good procedure. (You can try yourself uncoment yy = yy - rubberband(xx, yy)). Then second could be some other setting the filter like fs=300 Hz. This is the problem that I don't understand to much .... something works but it is not the same like in SeismoSignal.
...and SeismoSignal doesn't behave like that. Without "base line correction" result are bad. It must have "base line correction. Here in my program without "base line correction" acceleration is reaching +/- 2.5 when in SeismoSignal not. SeismoSignal needs "baseline correction then filter gives +/- 3.5. Here with or without "base line correction" filter gives +/- 2.5 and "base line correction" only makes displacement worse.