Skip to content

Instantly share code, notes, and snippets.

@pv
Created October 25, 2015 11:06
Show Gist options
  • Select an option

  • Save pv/e64bc7bebb0087b5bb65 to your computer and use it in GitHub Desktop.

Select an option

Save pv/e64bc7bebb0087b5bb65 to your computer and use it in GitHub Desktop.
$ make clean html
rm -rf _build/*
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.3.1
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] index
/home/pauli/prj/scipy/numpydoc/env/local/lib/python2.7/site-packages/numpy/fft/fftpack.py:docstring of numpy.fft.fft:18: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/home/pauli/prj/scipy/numpydoc/env/local/lib/python2.7/site-packages/numpy/fft/fftpack.py:docstring of numpy.fft.ifft:27: WARNING: Explicit markup ends without a blank line; unexpected unindent.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 2 warnings.
Build finished. The HTML pages are in _build/html.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to asdfasd’s documentation! &mdash; asdfasd 1.2.3 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.2.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="asdfasd 1.2.3 documentation" href="#" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
</head>
<body role="document">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="welcome-to-asdfasd-s-documentation">
<h1>Welcome to asdfasd&#8217;s documentation!<a class="headerlink" href="#welcome-to-asdfasd-s-documentation" title="Permalink to this headline">¶</a></h1>
<p>Contents:</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
</tbody>
</table>
<p>Stuff:</p>
<dl class="function">
<dt id="numpy.fft.fft">
<code class="descclassname">numpy.fft.</code><code class="descname">fft</code><span class="sig-paren">(</span><em>a</em>, <em>n=None</em>, <em>axis=-1</em>, <em>norm=None</em><span class="sig-paren">)</span><a class="headerlink" href="#numpy.fft.fft" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the one-dimensional discrete Fourier Transform.</p>
<p>This function computes the one-dimensional <em>n</em>-point discrete Fourier
Transform (DFT) with the efficient Fast Fourier Transform (FFT)
algorithm [CT].</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>a</strong> (<em>array_like</em>) &#8211; Input array, can be complex.</li>
<li><strong>n</strong> (<em>int, optional</em>) &#8211; Length of the transformed axis of the output.
If <cite>n</cite> is smaller than the length of the input, the input is cropped.
If it is larger, the input is padded with zeros. If <cite>n</cite> is not given,
the length of the input along the axis specified by <cite>axis</cite> is used.</li>
<li><strong>axis</strong> (<em>int, optional</em>) &#8211; Axis over which to compute the FFT. If not given, the last axis is
used.</li>
<li><strong>norm</strong> (<em>{None, &#8220;ortho&#8221;}, optional</em>) &#8211; <div class="versionadded">
<p><span class="versionmodified">New in version 1.10.0.</span></p>
</div>
<p>Normalization mode (see <cite>numpy.fft</cite>). Default is None.</p>
</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>out</strong> &#8211;
The truncated or zero-padded input, transformed along the axis
indicated by <cite>axis</cite>, or the last one if <cite>axis</cite> is not specified.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">complex ndarray</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal"><span class="pre">IndexError</span></code> &#8211;
if <cite>axes</cite> is larger than the last axis of <cite>a</cite>.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><code class="xref py py-func docutils literal"><span class="pre">numpy.fft()</span></code></dt>
<dd>for definition of the DFT and conventions used.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">ifft()</span></code></dt>
<dd>The inverse of <cite>fft</cite>.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">fft2()</span></code></dt>
<dd>The two-dimensional FFT.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">fftn()</span></code></dt>
<dd>The <em>n</em>-dimensional FFT.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">rfftn()</span></code></dt>
<dd>The <em>n</em>-dimensional FFT of real input.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">fftfreq()</span></code></dt>
<dd>Frequency bins for given FFT parameters.</dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>FFT (Fast Fourier Transform) refers to a way the discrete Fourier
Transform (DFT) can be calculated efficiently, by using symmetries in the
calculated terms. The symmetry is highest when <cite>n</cite> is a power of 2, and
the transform is therefore most efficient for these sizes.</p>
<p>The DFT is defined, with the conventions used in this implementation, in
the documentation for the <cite>numpy.fft</cite> module.</p>
<p class="rubric">References</p>
<table class="docutils citation" frame="void" id="ct" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[CT]</td><td>Cooley, James W., and John W. Tukey, 1965, &#8220;An algorithm for the
machine calculation of complex Fourier series,&#8221; <em>Math. Comput.</em>
19: 297-301.</td></tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">fft</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="mi">2j</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span> <span class="o">/</span> <span class="mi">8</span><span class="p">))</span>
<span class="go">array([ -3.44505240e-16 +1.14383329e-17j,</span>
<span class="go"> 8.00000000e+00 -5.71092652e-15j,</span>
<span class="go"> 2.33482938e-16 +1.22460635e-16j,</span>
<span class="go"> 1.64863782e-15 +1.77635684e-15j,</span>
<span class="go"> 9.95839695e-17 +2.33482938e-16j,</span>
<span class="go"> 0.00000000e+00 +1.66837030e-15j,</span>
<span class="go"> 1.14383329e-17 +1.22460635e-16j,</span>
<span class="go"> -1.64863782e-15 +1.77635684e-15j])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">256</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">fft</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">t</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">freq</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">fftfreq</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">freq</span><span class="p">,</span> <span class="n">sp</span><span class="o">.</span><span class="n">real</span><span class="p">,</span> <span class="n">freq</span><span class="p">,</span> <span class="n">sp</span><span class="o">.</span><span class="n">imag</span><span class="p">)</span>
<span class="go">[&lt;matplotlib.lines.Line2D object at 0x...&gt;, &lt;matplotlib.lines.Line2D object at 0x...&gt;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>In this example, real input has an FFT which is Hermitian, i.e., symmetric
in the real part and anti-symmetric in the imaginary part, as described in
the <cite>numpy.fft</cite> documentation.</p>
</dd></dl>
<dl class="function">
<dt id="numpy.fft.ifft">
<code class="descclassname">numpy.fft.</code><code class="descname">ifft</code><span class="sig-paren">(</span><em>a</em>, <em>n=None</em>, <em>axis=-1</em>, <em>norm=None</em><span class="sig-paren">)</span><a class="headerlink" href="#numpy.fft.ifft" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the one-dimensional inverse discrete Fourier Transform.</p>
<p>This function computes the inverse of the one-dimensional <em>n</em>-point
discrete Fourier transform computed by <cite>fft</cite>. In other words,
<code class="docutils literal"><span class="pre">ifft(fft(a))</span> <span class="pre">==</span> <span class="pre">a</span></code> to within numerical accuracy.
For a general description of the algorithm and definitions,
see <cite>numpy.fft</cite>.</p>
<p>The input should be ordered in the same way as is returned by <cite>fft</cite>,
i.e., <code class="docutils literal"><span class="pre">a[0]</span></code> should contain the zero frequency term,
<code class="docutils literal"><span class="pre">a[1:n/2+1]</span></code> should contain the positive-frequency terms, and
<code class="docutils literal"><span class="pre">a[n/2+1:]</span></code> should contain the negative-frequency terms, in order of
decreasingly negative frequency. See <cite>numpy.fft</cite> for details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>a</strong> (<em>array_like</em>) &#8211; Input array, can be complex.</li>
<li><strong>n</strong> (<em>int, optional</em>) &#8211; Length of the transformed axis of the output.
If <cite>n</cite> is smaller than the length of the input, the input is cropped.
If it is larger, the input is padded with zeros. If <cite>n</cite> is not given,
the length of the input along the axis specified by <cite>axis</cite> is used.
See notes about padding issues.</li>
<li><strong>axis</strong> (<em>int, optional</em>) &#8211; Axis over which to compute the inverse DFT. If not given, the last
axis is used.</li>
<li><strong>norm</strong> (<em>{None, &#8220;ortho&#8221;}, optional</em>) &#8211; <div class="versionadded">
<p><span class="versionmodified">New in version 1.10.0.</span></p>
</div>
<p>Normalization mode (see <cite>numpy.fft</cite>). Default is None.</p>
</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>out</strong> &#8211;
The truncated or zero-padded input, transformed along the axis
indicated by <cite>axis</cite>, or the last one if <cite>axis</cite> is not specified.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">complex ndarray</p>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal"><span class="pre">IndexError</span></code> &#8211;
If <cite>axes</cite> is larger than the last axis of <cite>a</cite>.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><code class="xref py py-func docutils literal"><span class="pre">numpy.fft()</span></code></dt>
<dd>An introduction, with definitions and general explanations.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">fft()</span></code></dt>
<dd>The one-dimensional (forward) FFT, of which <cite>ifft</cite> is the inverse</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">ifft2()</span></code></dt>
<dd>The two-dimensional inverse FFT.</dd>
<dt><code class="xref py py-func docutils literal"><span class="pre">ifftn()</span></code></dt>
<dd>The n-dimensional inverse FFT.</dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>If the input parameter <cite>n</cite> is larger than the size of the input, the input
is padded by appending zeros at the end. Even though this is the common
approach, it might lead to surprising results. If a different padding is
desired, it must be performed before calling <cite>ifft</cite>.</p>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">ifft</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
<span class="go">array([ 1.+0.j, 0.+1.j, -1.+0.j, 0.-1.j])</span>
</pre></div>
</div>
<p>Create and plot a band-limited signal with random phases:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">n</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">400</span><span class="p">,),</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">complex</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">n</span><span class="p">[</span><span class="mi">40</span><span class="p">:</span><span class="mi">60</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="mi">1j</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="p">(</span><span class="mi">20</span><span class="p">,)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">ifft</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">real</span><span class="p">,</span> <span class="s">&#39;b-&#39;</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">imag</span><span class="p">,</span> <span class="s">&#39;r--&#39;</span><span class="p">)</span>
<span class="go">[&lt;matplotlib.lines.Line2D object at 0x...&gt;, &lt;matplotlib.lines.Line2D object at 0x...&gt;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">((</span><span class="s">&#39;real&#39;</span><span class="p">,</span> <span class="s">&#39;imaginary&#39;</span><span class="p">))</span>
<span class="go">&lt;matplotlib.legend.Legend object at 0x...&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper"><div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="#">Documentation overview</a><ul>
</ul></li>
</ul>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/index.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2015, asd.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.6</a>
|
<a href="_sources/index.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment