{{ message }}

Instantly share code, notes, and snippets.

# jedludlow/ipython_fft_example.ipynb

Created Oct 19, 2012
IPython Notebook FFT Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 { "metadata": { "name": "", "signature": "sha256:1c8a707035342477c2cad874c9553bf896070c3c12617eb0eb4e9f6d312accc1" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Working with Numpy FFT Results: Scaling and Folding" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imports\n", "-------" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a Test Signal\n", "--------------------\n", "$f_s$ is the sampling frequency, while $f$ is a base frequency for the signal content. We create a signal that contains components at a couple of multiples of this base frequency. Note the amplitudes here since we will be trying to extract those correctly from the FFT later." ] }, { "cell_type": "code", "collapsed": false, "input": [ "f_s = 50.0 # Hz\n", "f = 1.0 # Hz\n", "time = np.arange(0.0, 3.0, 1/f_s)\n", "x = 5 * np.sin(2 * np.pi * f * time) + 2 * np.sin(10 * 2 * np.pi * f * time)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot(time, x)\n", "plt.xlabel(\"Time (sec)\")\n", "plt.ylabel(\"x\")" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 3, "text": [ "" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEPCAYAAABCyrPIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXmYnWV99z9nlkzWmWQySSYkmQ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LP5+KbGUyEfggkh6ynLNptu95hLH7XilK1YjD9teKEgU5JBIYQfayaUC2Dwbx1ruR\nbZCXAP+Vf78R2dfISRfwmO31M8D3kN01rR02LwfeCnws/7ol//8uBf4F2XMHig/jeSVfjg3hbk1R\nSkMNglLPnMg/jiKn2WF73YSkmp5DDlDxw77n/JXASsQAfBLZhAwkLfWiz/91vj/q8pmiVBwdQ1Dq\nlSDHJm4EZlDYAbMZ84laWymMLWQQz78XSSW1IQe0/JziQ96tw84fQnambMy/tqeMZue/W1FqghoE\npR7I2R5Nz2HsKVI5JGr4Y+DzFLZQfq3h+x+jcDBJE3AXkjZaC3wFObzk7xGD8gySolqTv/7fgG35\n99cBf5p/vxk5zOT5wHepKIqiRI417XRcBb/zcsSYKIqiKAnjL4H3VPD77kYGlBVFURRFURRFURRF\nURRFURRFURRFURRFURRFURRFURRFUeLE/wdcSEaGo9iOUgAAAABJRU5ErkJggg==\n", "text": [ "" ] } ], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute the FFT\n", "---------------\n", "The FFT and a matching vector of frequencies" ] }, { "cell_type": "code", "collapsed": false, "input": [ "fft_x = np.fft.fft(x)\n", "n = len(fft_x)\n", "freq = np.fft.fftfreq(n, 1/f_s)\n", "print n\n", "print freq" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "150\n", "[ 0. 0.33333333 0.66666667 1. 1.33333333\n", " 1.66666667 2. 2.33333333 2.66666667 3. 3.33333333\n", " 3.66666667 4. 4.33333333 4.66666667 5. 5.33333333\n", " 5.66666667 6. 6.33333333 6.66666667 7. 7.33333333\n", " 7.66666667 8. 8.33333333 8.66666667 9. 9.33333333\n", " 9.66666667 10. 10.33333333 10.66666667 11. 11.33333333\n", " 11.66666667 12. 12.33333333 12.66666667 13. 13.33333333\n", " 13.66666667 14. 14.33333333 14.66666667 15. 15.33333333\n", " 15.66666667 16. 16.33333333 16.66666667 17. 17.33333333\n", " 17.66666667 18. 18.33333333 18.66666667 19. 19.33333333\n", " 19.66666667 20. 20.33333333 20.66666667 21. 21.33333333\n", " 21.66666667 22. 22.33333333 22.66666667 23. 23.33333333\n", " 23.66666667 24. 24.33333333 24.66666667 -25. -24.66666667\n", " -24.33333333 -24. -23.66666667 -23.33333333 -23. -22.66666667\n", " -22.33333333 -22. -21.66666667 -21.33333333 -21. -20.66666667\n", " -20.33333333 -20. -19.66666667 -19.33333333 -19. -18.66666667\n", " -18.33333333 -18. -17.66666667 -17.33333333 -17. -16.66666667\n", " -16.33333333 -16. -15.66666667 -15.33333333 -15. -14.66666667\n", " -14.33333333 -14. -13.66666667 -13.33333333 -13. -12.66666667\n", " -12.33333333 -12. -11.66666667 -11.33333333 -11. -10.66666667\n", " -10.33333333 -10. -9.66666667 -9.33333333 -9. -8.66666667\n", " -8.33333333 -8. -7.66666667 -7.33333333 -7. -6.66666667\n", " -6.33333333 -6. -5.66666667 -5.33333333 -5. -4.66666667\n", " -4.33333333 -4. -3.66666667 -3.33333333 -3. -2.66666667\n", " -2.33333333 -2. -1.66666667 -1.33333333 -1. -0.66666667\n", " -0.33333333]\n" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot(np.abs(fft_x))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 5, "text": [ "[]" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGnVJREFUeJzt3W2MXFd9x/HvPtgYYsA1QX5WbYVY4ApIgLrhoeSmCq6D\nQhwkFCct1BQLRTKElFaATaVmF4STUAV4UcyLkoBJwMWFNnJEgTiRpyVCJCW1g5NlYzuJW9bFa9IE\nSIiyu96dvjjn7l6PZ3Zmrnd3zv+c30cazZ2783A8vvM7/znn3F0QERERERERERERERERERERERER\nEZEZ1gMcBO7x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S3El47c43+n2s/Vyv9vk76IPBu4M8L\n+0Jp5wW4Dv4R3GdpJfAw7ptSKG3MDeGOS3CfpwngfMJr51lCPeGqC/gGboik6PNMjYttp/MTikWX\nMjVmH2I7/wNY67f7cG0MrZ1vxK1weCnuGNgNfIRw2rmasydo67Urn6ybjxtCe4LZOTu+kdWc2c6N\nuBVO59fcr5PtXE3jeYV6E7ShvJfXA/1+ey1uyBE6386WhHjC1TtwPeYh3BDJQdwBuxg3GRrSUsHc\npUytxgmxnW/EVSLF5XchtvOTTC293I37hhdCO/fg5hFGcfNcf9mkXZ/GfaYGgT/tYDs/hFsO+N9M\nfZZ2dbideRtHmHovi57kzKWXnX4vi+2ch/v2fhj37SMLoJ0iIiIiIiIiIiIiIiIiIiIiIiIiIiIi\nIiIiIuH7f+nz76hXMY8kAAAAAElFTkSuQmCC\n", "text": [ "" ] } ], "prompt_number": 5 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Swap Half Spaces\n", "----------------\n", "Note that frequencies in the FFT and the freq vector go from zero to some larger positive number then from a large negative number back toward zero. We can swap that so that the DC component is in the center of the vector while maintaining a two-sided spectrum." ] }, { "cell_type": "code", "collapsed": false, "input": [ "fft_x_shifted = np.fft.fftshift(fft_x)\n", "freq_shifted = np.fft.fftshift(freq)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot(freq_shifted, np.abs(fft_x_shifted))\n", "plt.xlabel(\"Frequency (Hz)\")" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 7, "text": [ "" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEPCAYAAABIut/fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGlpJREFUeJzt3X2wXHV9x/H3Jvfe8BBKJsbePJZkgFTj2IKVlCLKMoU0\nOEri1BLoOMaC1TYtZmhH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ffLwIvAY37+r/z1N4BP4l5ZXA7cPs5jneLXLSsBX2Ns3bKzap2P4Sqr\nmxPzfoL7b/L0FPsmcgwFvLSj/6u6fQPwb1XzNjL2WyuT0yNU6sfjqtb7a9z33iflgV8nbo/i/m1M\n1I+/4v/GWtxv1VaPwvHrVn+r5mTfsnkB8MfAO8ZZ58gk64lMSB28tLt7caPkE/3tRcDrcV+fupZK\nRfOuxDoHgLf66fcm5t8LbKAysFlO5Xcvq5VwffiCxN86CVfRgPs94S/gRv6/HGf95xn74ymThfsp\nwL8ClzD2iQb/+M9Psq7IhDSCl1ab6OySsu24Dvq//e2XgffhKpuv494sPYzrwcsh+mncKYYfwv1Q\nQvnv3YKrO37olz2M+xrkic5mKQLrcGfCHI8buV+Ie4XxQ1ywj1fP4Lfrt6v2abzHyAHrcV8DW/7B\nioO4J6xO3A+oZP03RUVE6nINlbNopsNC3Ah/Ml8Gfr+Ox1gF/FMd64txqmgkJtN1vvz7cadMXj3F\ncp8G/qKOx/kgx/5akYiIiIiIiIiIiIiIiIiIiIiIiIiIiHX/D29PHqk1HaaHAAAAAElFTkSuQmCC\n", "text": [ "" ] } ], "prompt_number": 7 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fold Negative Frequencies and Scale\n", "------------------------------\n", "It's actually more common to look at just the first half of the unshifted FFT and frequency vectors and fold all the amplitude information into the positive frequencies. Furthermore, to get ampltude right, we must normalize by the length of the original FFT. Note the factor of $2/n$ in the following which accomplishes both the folding and scaling." ] }, { "cell_type": "code", "collapsed": false, "input": [ "half_n = np.ceil(n/2.0)\n", "fft_x_half = (2.0 / n) * fft_x[:half_n]\n", "freq_half = freq[:half_n]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot(freq_half, np.abs(fft_x_half))\n", "plt.xlabel(\"Frequency (Hz)\")\n", "plt.ylabel(\"Amplitude\")" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 9, "text": [ "" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEPCAYAAACjjWTcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFMJJREFUeJzt3X2QJHV9x/H3sMfdwR0KxIccgtxxPgTzoAgqIpoxZS6o\noCZBUcsHwIfEJEppSi+asli0KsbEJyApEkWUiE94KOVDStCEUYwoctwpykP05IwKAsYHdoPnLbuT\nP349zOzczGx3T/f0dPf7VdU1M70zPb9rms/+9tu/XzdIkiRJkiRJkiRJkiRJkiQppsYEvmM3cDew\nCCwAj5/Ad0qSJuxW4NCiGyFJdbbfhL5nEn9BSJKGmETYt4EvAtcBr5jA90mSCrAhenwgsBN4coFt\nkaRaWjWB77g9erwL+BThBO3VAJs3b27v2rVrAk2QpErZBTwsyQfyLuMcCBwUPV8HbAFu6Pxw165d\ntNvtRMtpp7U599xknynDcvbZZxfehmlZ3BfuC/fF6AXYnDSM8+7ZP5jQm+9814eBK8fZ4MJCWCRJ\n8eUd9rcCj8lyg4a9JCU3qaGXmalq2DebzaKbMDXcF13uiy73xXiKHv/ejupPsT3taXDCCfCWt+TU\nIkmaco1GAxLmtz17SaoBw16SasCwl6QaKF3Y790bFklSfKULe3v2kpScYS9JNWDYS1INGPaSVAOG\nvSTVgGEvSTVg2EtSDZQu7B1nL0nJlSrs22179pKURqnCfnExPBr2kpRMqcK+E/KGvSQlY9hLUg0Y\n9pJUA4a9JNWAYS9JNVC6sD/gAMNekpIqVdjv3QsHHuikKklKqlRhv7AQwt6evSQlY9hLUg0Y9pJU\nA6UL+7VrYWkpLJKkeEoX9vvvHxZ795IUn2EvSTVQurBfvToshr0kxVeqsN+7t9uzd6y9JMVXqrC3\njCNJ6Rj2klQDhr0k1YBhL0k1YNhLUg1MIuxngB3AZ8bdkGEvSelMIuzPAm4E2uNuqDPO3rCXpGTy\nDvvDgWcAFwKNcTfWGWe/erXj7CUpib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OLYSJhlfTFhKvgRhNC8ljBrcLbnvX8bvfdq4CPAX0frW3R7zA8g3DsAwj0V/rFn\nW6+M1jejz3yCcCnZS3q+43HAfxFmMn6NcGGqLwGP7nnPVwi9+F5rgOOBb6zw720Ap9D9y+YW4Ps9\n/45nrPB5SSqFe+kG3WXAkYTSTucCT1uAf42e7wd8hnCF0GMJ08bXEq4z9F26N3W4Cnhs9Lw37F9J\n+AUBIYy/Qfjl0gR+ARxGCN+vAicQruG0i+4vjvWEXxgvAd4drXsEgwP9+KitHacTLmLVW7Ka62ln\nx8eBV/W8/hL1vsmPxmAZR9PkVywv42wEfkD3Vo1bomVH9Hod4YJ6BwGfBPZES5yL6m0h9MBPjV7f\nD3gY4WY61xKuUQOhF7+JEMa3A9uj9fPR4zbgzYS/OM4EPjDgu46ke2VTCOWaj7G8JHNV32feQChr\nXdCz7jbCPrlphX+btA/DXtPu//pevw14b9+6s1h+x57e5/fSLVeu7fvcXxHuZ9qrCfy65/Ui4f+T\nYfX0e6JtPAd4Lvv2zok+239HoVF3GHoa8KfAUwZ8ZmnE56ShrNmrTK4g9J7XRa8fAjwQ+DIhbDtl\nnJN7PrMbOC56fmrP+iuAv6Db4XkE4XLTg7QJ9fMNPds6iFDGgXAt8fMIfxH8csDnf0D3GuwwOuiP\nBP4ZeB7Lf+kQff8PRnxWGsqevabJsFEqHV8g1KyviV7PAS8ilHU+TjjReiehbt4J1HcQhi2+Evhc\nz/YuJJREro/eeyfhmuDDRsUsEO67cD5wAKFH/4eEvzyuJ4T8oBIOUbse2fdvGvQdDcI12g+le532\nHxN+ee0PHA7cPOQ7JKl2zqY7GmcSDiP0/Ef5IPCEMb5jC3DuGJ9XzVnGUVVNajz+SwjDMN+0wvve\nAfz5GN/zcrqjfiRJkiRJkiRJkiRJkiRJkiTl5/8BMsJlYseca44AAAAASUVORK5CYII=\n", "text": [ "" ] } ], "prompt_number": 9 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now the spectrum contains spikes at the correct amplitudes at only positive frequencies, which are the only ones with physicality." ] } ], "metadata": {} } ] }

### tarokiritani commented Oct 19, 2016

I assume the DC amplitude appears only once in fft_x, and therefore should not be multiplied by 2? Am I mistaken?

### jedludlow commented Nov 16, 2016 • edited

@tarokiritani Yes, that is correct. More precisely, the FFT returns energy across the spectrum of positive, negative, and zero frequencies. The folding process takes all the energy from the negative frequencies and places it at the matching positive frequencies. There is a single entry in fft_x for zero frequency, so there is no folding required there.

### raproth commented Aug 16, 2018

is the lowest plot equivalent to the PSD?

### misterjoa commented Mar 7, 2019

This notebook is gold ! Thank you very much !

### impvd commented Oct 30, 2020

@jedludlow I know you create this gist 8 years ago. Just curious if maybe we could make it do the ifft operation? We have already know that the signal was the combination with 5 * np.sin(2 * np.pi * f * time) and 2 * np.sin(10 * 2 * np.pi * f * time) , what if we don't know the formula before, and we only get the value of x, which is like:

array([ 0.00000000e+00,  2.52877920e+00,  2.41901994e+00,  6.65052259e-01,
5.06655338e-01,  2.93892626e+00,  5.32484856e+00,  5.02813672e+00,
3.04606912e+00,  2.62202223e+00,  4.75528258e+00,  6.81354929e+00,
6.16570415e+00,  3.81456314e+00,  3.00932322e+00,  4.75528258e+00,
6.42624829e+00,  5.39721013e+00,  2.67699571e+00,  1.52062250e+00,
2.93892626e+00,  4.31088140e+00,  3.01619327e+00,  6.78789312e-02,
-1.27544686e+00, -1.83697020e-15,  1.27544686e+00, -6.78789312e-02,
-3.01619327e+00, -4.31088140e+00, -2.93892626e+00, -1.52062250e+00,
-2.67699571e+00, -5.39721013e+00, -6.42624829e+00, -4.75528258e+00,
-3.00932322e+00, -3.81456314e+00, -6.16570415e+00, -6.81354929e+00,
-4.75528258e+00, -2.62202223e+00, -3.04606912e+00, -5.02813672e+00,
-5.32484856e+00, -2.93892626e+00, -5.06655338e-01, -6.65052259e-01,
-2.41901994e+00, -2.52877920e+00, -6.12323400e-15,  2.52877920e+00,
2.41901994e+00,  6.65052259e-01,  5.06655338e-01,  2.93892626e+00,
5.32484856e+00,  5.02813672e+00,  3.04606912e+00,  2.62202223e+00,
4.75528258e+00,  6.81354929e+00,  6.16570415e+00,  3.81456314e+00,
3.00932322e+00,  4.75528258e+00,  6.42624829e+00,  5.39721013e+00,
2.67699571e+00,  1.52062250e+00,  2.93892626e+00,  4.31088140e+00,
3.01619327e+00,  6.78789312e-02, -1.27544686e+00, -1.97217653e-14,
1.27544686e+00, -6.78789312e-02, -3.01619327e+00, -4.31088140e+00,
-2.93892626e+00, -1.52062250e+00, -2.67699571e+00, -5.39721013e+00,
-6.42624829e+00, -4.75528258e+00, -3.00932322e+00, -3.81456314e+00,
-6.16570415e+00, -6.81354929e+00, -4.75528258e+00, -2.62202223e+00,
-3.04606912e+00, -5.02813672e+00, -5.32484856e+00, -2.93892626e+00,
-5.06655338e-01, -6.65052259e-01, -2.41901994e+00, -2.52877920e+00,
-1.22464680e-14,  2.52877920e+00,  2.41901994e+00,  6.65052259e-01,
5.06655338e-01,  2.93892626e+00,  5.32484856e+00,  5.02813672e+00,
3.04606912e+00,  2.62202223e+00,  4.75528258e+00,  6.81354929e+00,
6.16570415e+00,  3.81456314e+00,  3.00932322e+00,  4.75528258e+00,
6.42624829e+00,  5.39721013e+00,  2.67699571e+00,  1.52062250e+00,
2.93892626e+00,  4.31088140e+00,  3.01619327e+00,  6.78789312e-02,
-1.27544686e+00,  5.02600372e-15,  1.27544686e+00, -6.78789312e-02,
-3.01619327e+00, -4.31088140e+00, -2.93892626e+00, -1.52062250e+00,
-2.67699571e+00, -5.39721013e+00, -6.42624829e+00, -4.75528258e+00,
-3.00932322e+00, -3.81456314e+00, -6.16570415e+00, -6.81354929e+00,
-4.75528258e+00, -2.62202223e+00, -3.04606912e+00, -5.02813672e+00,
-5.32484856e+00, -2.93892626e+00, -5.06655338e-01, -6.65052259e-01,
-2.41901994e+00, -2.52877920e+00])

And we need to separate it to x1 and x2, I mean x1 and x2 would be the signal with the same basic frequency.

Awesome thanks again for your share.

### jedludlow commented Oct 30, 2020 • edited

@pivdets, I'm not sure I fully understand your question, but I'll make an attempt at an answer to the ifft part.
I don't have time right now to extend the notebook to include the ifft case, but I can describe how you can figure it out on your own. You can take the Fourier spectrum results that are plotted in cell 9 at the end of the notebook and try to work backwards through the problem, using the ifft instead of fft in cell 4. If your code reproduces the signal plotted in cell 3 then you know you've got it working correctly. Maybe you can submit a pull request if you get it working. Once you have proven your method you can apply it to other Fourier spectra to recover the underlying signal.