I am trying to properly perform FFT and calculate frequencies on my PICO using CircuitPython's (CP) ULAB library: ULAB FFT
With traditional Python using NUMPY and SCIPY, this is easily achievable, however it seems there is not a straightforward way to to calculate the frequencies of the FFT values in CP. There is no specific function for this under the ULAB FFT section; it also mentions ulab.extras.spectrum, but I cannot seem to find that function in the module attributes nor does it import. I figured maybe the magnitudes will be sufficient or of some better use.
Here is an example code
import ulab
import ulab.fft
spectrogram1 = ulab.fft.spectrogram(raw_adc_data_array)
spectrogram1 = ulab.vector.log(spectrogram1 + 1e-7)
spectrogram1 = spectrogram1[1:(samples_per_second//2)-1]
I have an ADC array of 1024 size that I read into the PICO from ADS1115 through i2c. I am able to convert the values to natural log and that is great, but I have to focus on a specific frequency range (less than 30hz) and I am unsure how to achieve this.
Questions:
- Is there an equivalent of SCIPY's fftpack.fftfreq() function?
- Are the FFT values and the index somehow related to the frequency or time? I am wondering if I am missing the obvious here.
- Will I have to manually calculate these somehow?
- Is the PICO and CP implementation limited as far as FFT functionality?