0
$\begingroup$

I want to run a clustering algorithm (svm, knn) on the ferquency spectrum data of a temperature sensor that published at irregular times. Here is the temperature data to take the FFT:

enter image description here I got the mean frequency for this temperature data as well as every temp sensor in the dataframe the average is every 18mins, longest distance between 2 points is 3hrs:

# group by short id
groups = df.groupby('id')
time_diff = groups.apply(lambda df: df.published_at.diff().mean())

Isolated the graphed temp data in a series:

signal = df.loc[df['_id'] == 'A1']['temperature']

Stored size of signal and mean sampling frequency as variables:

# sampling frequency: 
Fs = time_diff[:1]
Fs
Out[217]: 00:18:54.085526

# size 
S = signal.size
Then took the fft and calculated dBs

X = np.fft.fft(signal)
X_db = 20*np.log10(2*np.abs(X)/S)
And plotted the results:

plt.plot(X)
plt.show()

enter image description here

plt.plot(X_db)
plt.show()

enter image description here

These graphs intuitively do not look like they correspond to the original data. The objective with the fft is to then classify the data using SVM, however, I am not sure which variant fft is appropriate, nor if using the mean time frequency is either.

$\endgroup$
  • $\begingroup$ Just an idea. $\endgroup$ – jojek Jan 25 '18 at 21:28
1
$\begingroup$

You might want to look at the non uniform DFT

https://en.wikipedia.org/wiki/Non-uniform_discrete_Fourier_transform

Google (nonuniform fft) and many useful references will be returned

and also

https://scicomp.stackexchange.com/questions/593/how-do-i-take-the-fft-of-unevenly-spaced-data

$\endgroup$
0
$\begingroup$

One option, in addition to the Non-uniform DFT that has been mentioned, is simply interpolating the data on a regularly-spaced grid by using a timestep approximately the same size as the smallest timestep, and then taking the DFT on the interpolated data.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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