0

I am trying to reproduce the following figure using scipy:

enter image description here

Specifically I'm using:

from scipy.io import wavfile

This module has a load_wav function that decomposes an input signal (in .wav file format) into its frequency/amplitude representation using FFT. So clearly, the Y axis in the figure above is fairly straight forward. I would take the absolute value of my FFT output. The X axis is what I'm not so sure about, I'm not sure how I'm supposed to recover the frequency. For example, when I plot my signal upon being rendered by scipy's FFT, I seem to be only getting the temporal domain (y axis = amplitude, x axis = time). for concreteness:

input: load_wav(44100, 'input_audio.wav')

output: [vector of amplitude - temporal paired arrays] (I believe in numpy format)

Can someone explain how I can plot the 'Frequency Domain' as pictured above with scipy? Do I need to call a separate function for this? Or does my current output have the necessary data, and I just didn't access it properly?

On a side note:

Scipy's documentation had over 10 different FFT procedures, and none of them seemed to have the same axes as the graph I want to plot. So there was no clear cut way to determine if any of their graph name's were synonymous, or how similar the procedures were that those plots were depicting. Actually, most of the documentation's graphs were not labeled. For industry experts, a lot of that can be inferred I suppose, but I think for the sake of clarity, labels would help the rest of us.

Arash Howaida
  • 2,575
  • 2
  • 19
  • 50
  • 1
    *"Specifically I'm using: `from scipy import audio`"* That could not work, so please check your code. `scipy` doesn't have an `audio` module. – Warren Weckesser Nov 09 '16 at 04:28
  • The x axis is almost certainly incorrect in the plot you've posted. This is a double-sided FFT, and the zero frequency point should be at the center. – Chris Mueller Nov 09 '16 at 04:43
  • Yes, sorry about that, that's a huge typo. It should be `from scipy.io import wavfile` – Arash Howaida Nov 09 '16 at 04:50
  • Are you sure the plot is incorrect? I clipped it from a respectable publication. In any event, by double sided, you mean both axes are derived from the FFT? or? – Arash Howaida Nov 09 '16 at 04:51
  • Is one of the graphs pictured here: http://stackoverflow.com/questions/9456037/scipy-numpy-fft-frequency-analysis?rq=1 comparable to the graph I'm going for? I think the second one is similar, and it has 0 centered on the X axis. I'm assuming that's Hz? But the Y axis isn't the same, it has negative numbers in it. The graph I'm trying for has absolute value, so only positive numbers for the domain of Y. – Arash Howaida Nov 09 '16 at 07:12
  • The plot above is suspiciously symmetric around the center, and if it's experimental data, unlikely to happen by accident. If zero frequency is at the center, it would explain the symmetry. – pv. Nov 10 '16 at 19:49

0 Answers0