In [1]:
%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

plt.style.use('seaborn-white')

Fourier Pairs

$$ \cos(2\pi f_0 t) \Longleftrightarrow \frac{1}{2}\left[\delta(f - f_0) + \delta(f + f_0)\right] $$
$$ \sin(2\pi f_0 t) \Longleftrightarrow \frac{1}{2i}\left[\delta(f - f_0) - \delta(f + f_0)\right] $$
$$ \frac{1}{\sqrt{2\pi\sigma_t^2}}e^{-t^2 / (2\sigma_t^2)} \Longleftrightarrow e^{-f^2 / (2\sigma_f^2)};~~~~ \sigma_f = \frac{1}{2\pi\sigma_t} $$
$$ \Pi_T(t) \Longleftrightarrow {\rm sinc}(fT) $$
$$ \sum_{n=-\infty}^\infty \delta(t - nT) \Longleftrightarrow \frac{1}{T} \sum_{n=-\infty}^\infty \delta(f - n/T) $$

In [2]:
from matplotlib.font_manager import FontProperties

fig, ax = plt.subplots(4, 2, figsize=(10, 6))
fig.subplots_adjust(left=0.04, right=0.98, bottom=0.02, top=0.95,
                    hspace=0.3, wspace=0.2)

x = np.linspace(-5, 5, 1000)

for axi in ax.flat:
    axi.xaxis.set_major_formatter(plt.NullFormatter())
    axi.yaxis.set_major_formatter(plt.NullFormatter())
    
    # draw center line
    axi.axvline(0, linestyle='dotted', color='gray')
    axi.axhline(0, linestyle='dotted', color='gray')
    
style_re = dict(linestyle='solid', color='k', linewidth=2)
style_im = dict(linestyle='solid', color='gray', linewidth=2)
text_style = dict(size=14, color='gray')

    
# sine -> delta
ax[0, 0].plot(x, np.cos(x),**style_re)
ax[0, 0].set(xlim=(-5, 5), ylim=(-1.2, 1.2))
ax[0, 0].annotate('', (-np.pi, 0), (np.pi, 0),
                  arrowprops=dict(arrowstyle='|-|', color='gray'))
ax[0, 0].text(0, 0, '$1/f_0$', ha='center', va='bottom', **text_style)
ax[0, 0].set_title('Sinusoid')

ax[0, 1].plot([-5, 2, 2, 2, 5], [0, 0, 1, 0, 0], **style_re)
ax[0, 1].plot([-5, -2, -2, -2, 5], [0, 0, 1, 0, 0], **style_re)
ax[0, 1].set(xlim=(-5, 5), ylim=(-0.2, 1.2))
ax[0, 1].annotate('', (0, 0.4), (2, 0.4), arrowprops=dict(arrowstyle='<-', color='gray'))
ax[0, 1].annotate('', (0, 0.4), (-2, 0.4), arrowprops=dict(arrowstyle='<-', color='gray'))
ax[0, 1].text(1, 0.45, '$+f_0$', ha='center', va='bottom', **text_style)
ax[0, 1].text(-1, 0.45, '$-f_0$', ha='center', va='bottom', **text_style)
ax[0, 1].set_title('Delta Functions')

# gaussian -> gaussian
ax[1, 0].plot(x, np.exp(-(2 * x) ** 2), **style_re)
ax[1, 0].set(xlim=(-5, 5), ylim=(-0.2, 1.2))
ax[1, 0].annotate('', (0, 0.35), (0.6, 0.35), arrowprops=dict(arrowstyle='<-', color='gray'))
ax[1, 0].text(0, 0.4, '$\sigma$', ha='center', va='bottom', **text_style)
ax[1, 0].set_title('Gaussian')

ax[1, 1].plot(x, np.exp(-(x / 2) ** 2), **style_re)
ax[1, 1].set(xlim=(-5, 5), ylim=(-0.2, 1.2))
ax[1, 1].annotate('', (0, 0.35), (2, 0.35), arrowprops=dict(arrowstyle='<-', color='gray'))
ax[1, 1].text(0, 0.4, '$(2\pi\sigma)^{-1}$', ha='center', va='bottom', **text_style)
ax[1, 1].set_title('Gaussian')

# top hat -> sinc
ax[2, 0].plot([-2, -1, -1, 1, 1, 2], [0, 0, 1, 1, 0, 0], **style_re)
ax[2, 0].set(xlim=(-2, 2), ylim=(-0.3, 1.2))
ax[2, 0].annotate('', (-1, 0.5), (1, 0.5), arrowprops=dict(arrowstyle='<->', color='gray'))
ax[2, 0].text(0.0, 0.5, '$T$', ha='center', va='bottom', **text_style)
ax[2, 0].set_title('Top Hat')

ax[2, 1].plot(x, np.sinc(x), **style_re)
ax[2, 1].set(xlim=(-5, 5), ylim=(-0.3, 1.2))
ax[2, 1].annotate('', (-1, 0), (1, 0), arrowprops=dict(arrowstyle='<->', color='gray'))
ax[2, 1].text(0.0, 0.0, '$2/T$', ha='center', va='bottom', **text_style)
ax[2, 1].set_title('Sinc')

# comb -> comb
ax[3, 0].plot([-5.5] + sum((3 * [i] for i in range(-5, 6)), []) + [5.5],
              [0] + 11 * [0, 1, 0] + [0], **style_re)
ax[3, 0].set(xlim=(-5.5, 5.5), ylim=(-0.2, 1.2))
ax[3, 0].annotate('', (0, 0.5), (1, 0.5), arrowprops=dict(arrowstyle='<->', color='gray'))
ax[3, 0].text(0.5, 0.6, '$T$', ha='center', va='bottom', **text_style)
ax[3, 0].set_title('Dirac Comb')

ax[3, 1].plot([-5.5] + sum((3 * [i] for i in range(-5, 6)), []) + [5.5],
              [0] + 11 * [0, 1, 0] + [0], **style_re)
ax[3, 1].set(xlim=(-2.5, 2.5), ylim=(-0.2, 1.2));
ax[3, 1].annotate('', (0, 0.5), (1, 0.5), arrowprops=dict(arrowstyle='<->', color='gray'))
ax[3, 1].text(0.5, 0.6, '$1/T$', ha='center', va='bottom', **text_style)
ax[3, 1].set_title('Dirac Comb')

for i, letter in enumerate('abcd'):
    ax[i, 0].set_ylabel('({0})'.format(letter), rotation=0,
                        fontproperties=FontProperties(size=12, style='italic'))

# Draw arrows between pairs of axes
for i in range(4):
    left = ax[i, 0].bbox.inverse_transformed(fig.transFigure).bounds
    right = ax[i, 1].bbox.inverse_transformed(fig.transFigure).bounds
    x = 0.5 * (left[0] + left[2] + right[0])
    y = left[1] + 0.5 * left[3]
    fig.text(x, y, r'$\Longleftrightarrow$',
             ha='center', va='center', size=30)

fig.savefig('fig03_Fourier_pairs.pdf')