Frequency of a time series data
-
hi all,
I have a time-series data that I want to find the frequency of. It is the supply temperature of an air con unit. Any suggestion on how I can achieve this?
BR,
Ricardo -
ricardo,
You probably want to perform a Fourier Transform on your data, this will provide you with the frequency components of your data. In order to do this you will need to write a DFT Algorithm. Depending on your level of coding ability you could write this in the Scripting Data Source, Meta Data Source or roll your own module. There are additional complexities you will need to consider such as the noise in your data, your sample rate and how you will choose the true frequency of the signal you are trying to extract from your data. I am interested in helping you out with this but I don't have any time this week, perhaps next week I can take some time and put something together for you.
-
hi terry,
Thank you for your kind offer. Let me know what additional information you will need.
BR,
Ricardo -
A Quick discussion on what you are going to do with the results might be useful.
For the following example: your temperature data will be the signal and the DFT is the transform.
The output from the transform will be a list of frequencies and their amplitudes. When using real world data there will generally be several frequencies embedded within the signal, making it hard to determine exactly what the true frequency of the signal is. I would suggest for now that we keep it simple and just select the frequency with the largest amplitude, this should work fine if the signal is fairly clean.
Depending on what you are going to do with the signal, it might be good to know the signal to noise ratio or at least the mean noise floor level. This will give you an idea of how accurate the detected frequency is. If the noise and the signal are close to the same size then you can assume that the reported frequency isn't going to be accurate.
So my two questions are:
-
Do you know how clean your signal is?
-
How important is the accuracy of frequency detection?
No problem helping out, I have some background in signal processing and enjoy getting a chance to use it.
-
-
Alright. Here is a module that is only partially finished but does have a way to plot the Frequency Spectrum for a given point. Only Numerical points are allowed, and Mango Core Version 2.1 or higher is required.
To use it just go to the control toolbox icon and navigate to the Signal Processing Tab. Then select your point and select the number of previous samples to use for the DFT. Press Generate and you should see 2 graphs. The top chart is just the signal plotted against time, the lower chart is the DFT and the peaks are in Hz.
The DFT will calculate your sample rate based on the data, so if you have changed poll periods recently then you should wait because the sample period won't be stable and the results will be skewed. Also note that all DSP Theory applies here so you have to sample at least 2x as fast as the highest frequency you want to detect. So if you are looking for a 2Hz signal you will need to sample at 4Hz (250ms poll Period). Realistically you will need to sample much faster to get quality results. Remember that Frequency = 1/Sample Period in seconds.
Another note on sample numbers, you will need at least enough samples to reproduce one full cycle of the signal you are searching for. So low frequency signals will take more sample time to detect as higher frequency signals will take less. For example a 2Hz signal has a period of 500ms, so as above you will need to sample at at least 250ms for a duration of 500ms. But for quality results you would sample for longer faster.
I am successfully detecting a pure 10Hz signal by sampling at 5ms as you can see in the attached image.
Mango's fastest sample rate is 1ms so you won't be able to detect signals faster than 500Hz reliably, unless modifications are made the Core code.
The code for the module is here:
https://github.com/terrypacker/mango-modules
Attachment: download link