# converting an accelerometer oscillogram to a velocity oscillogram using python

I have some signals in csv taken from an accelerometer. These come from vibration data of gearboxes.

With scipy I can easily get its frequency (in terms of acceleration) by applying the RFFT to the oscillogram (I am also using a Hanning Window)

And by dividing each magnitude point by it corresponding omega (Hz*2Pi) I can get its frequency in terms of velocity (also multiplying by 1000 to get mm/s).

I understand that I can't apply this same procedure to get an oscillogram in terms of velocity instead of acceleration.

Does anybody knows how to do this in python?

(Edited question, and thanks for the input)

• Please edit your question with clarifications on the following points: "I can easily get its frequency" -- do you mean you can get its amplitude at a given frequency, either by filtering or using the FFT? "I need to calculate the velocity..." do you mean that you need to calculate the velocity in the time domain? The question title certainly implies this -- please confirm. Jul 17, 2022 at 20:27

In theory you could just integrate the acceleration to get velocity. Numerically this would just be $$v(n) = \sum_{k=1}^n T_s a(n) + v(0)\ \forall\ n\ge 1 \tag 1,$$ where $$T_s$$ is the sampling interval ($$T_s = 1/F_s$$).
Unless you do need to know the velocity down to 0Hz, you need to use a "leaky integrator". I.e., run the difference equation $$v(n) = v(n - 1) + T_s a(n) - b v(n - 1). \tag 2$$
Here, $$0 \le b \ll 1$$ is a forgetting factor chosen to give you the best estimate of the velocity for your purposes. This will work well either if you don't care about the baseline velocity, or if you have a system that exhibits bounded motion (i.e., something is vibrating).
Note that you can get a similar effect by taking the FFT of the acceleration, multiplying each point by $$j \omega$$, windowing the FFT with some profile that's zero at $$\omega = 0$$, and then taking the IFFT. Choose the right window, and you'll get exactly the same answer, possibly with less computation, possibly with more.