from scipy.special.basic import sinc, j0 from numpy.core import arange, pi, sum, sqrt import pylab a = -50.0 b = +50.0 w = 1.0/pi dt = 0.1; N = 10; t = arange(a, b, dt) t.shape = (-1,1) y = j0(t) s = arange(-N,N+1)/w s.shape = (1,-1) x = j0(s) z = sum(x*sinc(w*(t-s)), 1) golden_mean = (sqrt(5)-1.0)/2.0 pylab.rcParams.update( \ {'backend': 'ps', 'ps.usedistiller': 'xpdf', 'axes.labelsize': 8, 'text.fontsize': 8, 'xtick.labelsize': 8, 'ytick.labelsize': 8, 'figure.figsize': [ 6.0, golden_mean*6.0 ], }) pylab.figure() pylab.plot(t, y, color='blue', label='Original function') pylab.plot(t, z, color='green', label='Approximate reconstruction') pylab.plot(s, x, 'g.', label='_nolegend_') pylab.legend() pylab.savefig('bessel.eps') t.shape = (-1,1) s_under = s*2.0 s_over = s/2.0 x_under = j0(s_under) x_over = j0(s_over) z_under = sum(x_under*sinc((w/2.0)*(t-s_under)), 1) z_over = sum(x_over*sinc((w*2.0)*(t-s_over)), 1) pylab.figure() pylab.plot(t, y, color='blue', label='Original function') pylab.plot(t, z_under, color='red', label='Under-sampled') pylab.plot(t, z_over, color='green', label='Over-sampled') pylab.plot(s_under, x_under, 'rx', label='_nolegend_') pylab.plot(s_over, x_over, 'g.', label='_nolegend_') pylab.legend() pylab.savefig('bessel-extra.eps') t = arange(-5, 5, dt) pylab.figure() pylab.plot( t, sinc(w*t), \ t, 0.5*sinc(t - 1), t, 0.5*sinc(t + 1), t, 0.25*sinc(t - 2), t, 0.25*sinc(t + 2)) pylab.savefig('basis.eps') pylab.show()