Derived Result from Butter Filter and FFT doesn't change over time
<p>I am very new in Signal Processing, have met a situation that I am not sure if it is correct or not.  Please correct me then I will update more details.</p>

<p>My data is <a href="https://app.box.com/s/8ijccq76z65itv9jluid3nadfzp160qr" rel="nofollow">here</a> </p>

<p>I acquired an accelerometer signal taken from my cellphone (Samsung Galaxy Note 2, sampling rate $\approx 99 Hz$). I would like to analyze frequency from $0.3 Hz$ to $5.0 Hz$</p>

<p>My procedure is following steps:</p>

<ol>
<li>combination: let say a sensor yields 3 channels $x$, $y$, $z$. The combination is to produce a new channel $v = \sqrt{(x * x + y * y + z * z)}$</li>
<li>Perform a median filter: to make signal smoothly</li>
<li>Butter-worth filter: my cutoff is from $0.3 Hz$ to $5.0 Hz$</li>
<li><p>FFT</p>

<p>Below image is my demonstrate with segment of 120 time-points with 4 steps: (can explore more at my <a href="https://www.youtube.com/watch?v=v3gsYjdC9dY" rel="nofollow">video</a>)
<a href="http://i.stack.imgur.com/m1C5J.png" rel="nofollow"><img src="http://i.stack.imgur.com/m1C5J.png" alt="a segment of 120 time-points"></a></p></li>
</ol>

<p>I observed result of step 3 and 4 do not change while signal varies over time</p>

<p>My question is if there is anything I can make sure this result is correct or not? Thanks in advance</p>

<p>Below is my code was used for applying filters</p>

<pre><code>from __future__ import division
import numpy as np
from numpy.fft import rfft, rfftfreq
from numpy import absolute
import matplotlib.pyplot as plt
from scipy.signal import medfilt, hilbert
import pandas as pd

chunk = 120
LOW_CUT = 0.3
HIGH_CUT = 5.0
FS = 99
freqs = rfftfreq(chunk, 1 / FS)
_accel = pd.read_csv('data.csv')
for k, g in _accel.groupby(np.arange(len(_accel)) // chunk):
    _v = g['v'].values
    _v = medfilt(_v, 7)
    _v = butter_bandpass_filter(_v, LOW_CUT, HIGH_CUT, FS, order=4)
    v = 1 / chunk * absolute(rfft(_v))
    plt.stem(freqs, v)
</code></pre>

<p><strong>update 1</strong> another link to download data <a href="https://1drv.ms/u/s!At6qHz_a5mXhgp1KcAYpvsiJeTXsmg" rel="nofollow">https://1drv.ms/u/s!At6qHz_a5mXhgp1KcAYpvsiJeTXsmg</a></p>

<p><strong>update 2</strong> updated sampling rate in code <code>FS = 99</code></p>

<p><strong>update 3</strong> increased chunk size to 512, <a href="https://youtu.be/CALuLN1vYtc" rel="nofollow">plotted</a> data again. Made a video of result <a href="https://youtu.be/2jc21kS5VnA" rel="nofollow">without bandpass</a> </p>

<p>I give the problem a quick try, and below is my snippet</p>

<pre><code>data = _accel['v'].tolist()    
Fs = 99
# remove the DC part, to help the plotting later
data = data - np.mean(data)
# Perform FFT for real data, on the whole 6000 samples, 
# using 4096 discrete frequencies, which is dense enough to capture 
# the frequency information within 0.3-5 Hz.    
fdata = rfft(data,4096)

# the frequencies we are looking at in the FFT
freqs = map(lambda x: float(x)*Fs/4096, range(0,4097))

# Plot
plt.plot(freqs[0:2049],fdata)
plt.xlabel('Frequency')
plt.show()
</code></pre>

<p>The resulting plot does contain information in the band you are interested in.
<a href="http://i.stack.imgur.com/bAZzK.png" rel="nofollow">Plot of frequency magnitude</a></p>

<p>I guess your problem is in choosing chunk too small.
The resolution in the frequency domain is Fs/N, with N is the number of points to perform FFT (and usually the length of the signal vector in the time domain). So, if you want to capture information in the range of 0.3-5Hz, I assume you would need a resolution of about 0.2Hz, which means N should be at least 500. Your choice of 120 for window length is obviously not enough.</p>

python signals fft sensor