Search code examples
pythonpandasfftaccelerometervibration

How to check peak in the acceleration column?


I have a data frame with the columns 'AccelerationG' for a timestamp. I want to see the vibration/acceleration of the device and check if it crosses a peak value?

AccelerationG
0.95
0.93
1.12
1.12
0.95
0.93
1.12
0.95
1.12
1.12
0.93
0.93
1.12
1.12
0.95
5.42
10.66
14.39



How can I approach this?

Solution

  • dat=[0.95,0.93,1.12,1.12,0.95,0.93,1.12,0.95,1.12,1.12,
    0.93,0.93,1.12,1.12,0.95,5.42,10.66,14.39]
    
    import numpy as np
    import matplotlib.pyplot as p
    %matplotlib inline
    
    p.figure(figsize=(10,10))
    p.subplot(221)
    p.plot(dat, '.-')
    p.title('all data')
    
    p.subplot(222)
    p.plot(dat[:-3],'.-')
    p.title('data truncated')
    
    p.subplot(223)
    mn=np.mean(dat[:-3])       # DC 
    p.plot(dat[:-3]- mn,'.-')  # subtract DC
    p.title('DC removed')
    
    p.subplot(224)
    p.psd(dat[:-3]-mn,12,1/0.01);  
    p.title('power spectral density')
    

    If the data were taken at 100 Hz, over 140 ms, then there would be a frequency peak at 35 Hz.

    enter image description here