First, import the things we need:

In [3]:
# Import the necessary libraries
from __future__ import division, print_function
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from mpl_toolkits.mplot3d import axes3d
import scipy.stats as stats

First example, the Mexican hat function, a radially symmetric sinc function: \[\phi(x,y) = \frac{\sin{(\sqrt{(x^2 + y^2)}}}{\sqrt{(x^2 + y^2)}}\]

In [4]:
# set up 3d plotting
fig = plt.figure()
ax = fig.gca(projection='3d')
#get example data (easy way to get X and Y range)
X, Y, Z = axes3d.get_test_data(0.05)
#Calculate radially symmetric sync fucntion("Mexican Hat")
Z = np.sinc(np.sqrt((X*X + Y*Y)/90))
# And plot it
foo = ax.plot_surface(X, Y, Z, rstride=3, cstride=3, linewidth=0.3,  cmap=plt.cm.coolwarm)

Second example, the 2-axis sinc function, which is the Fourier transform of a rectangle: \[\mathcal{F}(\mathrm{rect}(x,y)) = \mathrm{sinc}(x)\mathrm{sinc}(y)\] This is also the optical diffraction pattern from a rectangular aperture.

In [5]:
# set up 3d plotting
fig = plt.figure()
ax = fig.gca(projection='3d')
#get example data (easy way to get X and Y)
X, Y, Z = axes3d.get_test_data(0.05)

#Calculate 2D sinc function
Z = np.sinc(X/7)*np.sinc(Y/7)

# And plot it -- plot log to emphasize Z extent
foo = ax.plot_surface(X, Y, np.log(0.4+Z), rstride=3, cstride=3, linewidth=0.3,  cmap=plt.cm.coolwarm)
In [5]:
 
In []: