Sampling and reconstruction

This notebook will illustrate some effects of sampling and reconstruction

The sampling theorem

Shannon's sampling theorem says that a continuous-time signal with Fourier transform that is zero outside the interval $(-\omega_0, \omega_0)$ can be completely reconstructed from equidistant samples of the signal, as long as the sampling frequency is at least $2\omega_0$.


In [1]:
using PyPlot


INFO: Recompiling stale cache file /home/kjartan/.julia/lib/v0.6/PyCall.ji for module PyCall.
INFO: Recompiling stale cache file /home/kjartan/.julia/lib/v0.6/PyPlot.ji for module PyPlot.

Bad key "patch.force_edgecolor" on line 33 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.spines.right" on line 225 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "lines.dashed_pattern" on line 18 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.linewidth" on line 357 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "contour.corner_mask" on line 339 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.markeredgecolor" on line 369 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.second" on line 235 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.vertical" on line 379 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.color" on line 363 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.bootstrap" on line 348 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.minor.visible" on line 262 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.major.right" on line 271 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.month" on line 231 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "scatter.marker" on line 345 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.minor.right" on line 273 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.capprops.linestyle" on line 353 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.grid.axis" on line 182 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.patchartist" on line 374 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.py:1039: UserWarning: Bad val "None" on line #298
	"legend.framealpha    : None    # opacity of legend frame
"
	in file "/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle"
	Key legend.framealpha: Could not convert "None" to float
  (val, error_details, msg))

Bad key "boxplot.meanline" on line 362 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.color" on line 355 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.spines.left" on line 224 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.whiskerprops.linestyle" on line 381 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.showcaps" on line 376 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.capprops.color" on line 352 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.major.left" on line 270 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.left" on line 258 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.medianprops.linestyle" on line 371 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.markeredgecolor" on line 359 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.minor.bottom" on line 256 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.linestyle" on line 356 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.autolimit_mode" on line 220 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.spines.top" on line 226 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "hatch.color" on line 37 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "legend.edgecolor" on line 301 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.spines.bottom" on line 223 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.marker" on line 367 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.prop_cycle" on line 215 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.minute" on line 234 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.major.top" on line 253 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.whiskerprops.linewidth" on line 382 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.day" on line 232 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.medianprops.linewidth" on line 372 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.right" on line 259 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.bottom" on line 242 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "legend.facecolor" on line 300 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.microsecond" on line 236 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.showmeans" on line 378 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.linestyle" on line 364 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "hist.bins" on line 40 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "lines.scale_dashes" on line 21 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.capprops.linewidth" on line 354 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.titlepad" on line 184 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.boxprops.linewidth" on line 351 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "animation.html" on line 524 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "_internal.classic_mode" on line 526 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.linewidth" on line 365 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.hour" on line 233 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.markerfacecolor" on line 368 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "figure.titlesize" on line 307 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.minor.visible" on line 245 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.boxprops.color" on line 349 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "date.autoformatter.year" on line 230 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.markerfacecolor" on line 360 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.notch" on line 373 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.boxprops.linestyle" on line 350 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "figure.titleweight" on line 308 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "markers.fillstyle" on line 24 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.labelpad" on line 187 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.marker" on line 358 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.medianprops.color" on line 366 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "lines.dotted_pattern" on line 20 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.showfliers" on line 377 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.formatter.offset_threshold" on line 207 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.minor.top" on line 255 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "ytick.minor.left" on line 272 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "lines.dashdot_pattern" on line 19 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.flierprops.markersize" on line 361 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.whiskerprops.color" on line 380 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.whiskers" on line 383 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.major.bottom" on line 254 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.meanprops.markersize" on line 370 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "hatch.linewidth" on line 38 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "errorbar.capsize" on line 342 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "xtick.top" on line 241 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "image.composite_image" on line 335 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "boxplot.showbox" on line 375 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

Bad key "axes.prop_cycle" on line 11 in
/home/kjartan/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/stylelib/seaborn.mplstyle.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution

In [3]:
ω0 = 2;
x(t) = 2*sin.(ω0*t + pi/3);
t = linspace(0, 3, 700);
figure(figsize=(14,4));
pc = plot(t, x(t), linewidth=2);
xlabel("Seconds")

ωs = 20; # > 2ω0
h = 2*pi/ωs;
td = 0:h:3;
pd = plot(td, x(td), "o");
stem(td, x(td), linefmt="r--", markerfmt="ro", basefmt = "r-");
title("Continuous-time and sampled signal")


Out[3]:
PyObject <matplotlib.text.Text object at 0x7f5987230610>

Reconstruction

Consider the continuous-time signal $x(t)$, which is sampled with sampling period $h$ and thus sampling frequency $$\omega_s = \frac{2\pi}{h}$$ to give the sampled signal $x[k] = x(kh)$. We assume that the signal $x(t)$ is bandlimited with frequency content zero above the frequency $\omega_0 < \omega_s/2$.

The signal can be reconstructed by the interpolation $$ \DeclareMathOperator{\sinc}{sinc} x(t) = \sum_{k=-\infty}^{\infty} x(kh) \sinc \frac{\omega_s(t-kh)}{2} = \sum_{k=-\infty}^{\infty} x(kh) \frac{ \sin \big(\omega_s(t-kh)/2\big)}{\omega_s(t-kh)/2} $$

The sinc function

The Fourier transform of the $\sinc$ function is the rectangular function, illustrated below.


In [9]:
# The sinc function and its Fourier transform
N = 300;
Nhalf = div(300,2)
ts = linspace(-3,3,N);
dt = (3+3)/N;
ωfft = 2π/dt;

figure(figsize=(14,3))
ps = plot(ts, sinc.(ωs*ts/2/π), linewidth=2); 
# Note that the sinc function in julia is defined as sin(πx)/(πx)

xlabel("seconds")

S = fft(sinc.(ωs*ts/2/π)); 
w = linspace(0, ωfft/2, Nhalf)
figure(figsize=(14,3))
pS = plot(w[1:Nhalf], abs.(S[1:Nhalf]), linewidth=2)
annotate(L"$\frac{\omega_s}{2}=10$ rad/s",
xy=[ωs/2;0],# Arrow tip
    xytext=[ωs/2+10;3], # Text offset from tip
size=16,
    xycoords="data", # Coordinates in in "data" units
arrowprops=Dict("facecolor"=>"black")) 
# Julia dictionary objects are automatically converted to Python object when they pass into a PyPlot function
#arrowprops=Dict("arrowstyle"=>"->", "facecolor"=>"black")) 

xticks([0, ωs/2, ωfft/2], ("0", L"$\omega_s/2$", "160"), fontsize="large");
xlabel("Frequency [rad/s]");


Exercise

Why is the Fourier transform plotted above not a perfect rectangular function?


In [19]:
?fft


search: fft fft! FFTW fftshift rfft ifft bfft ifft! bfft! ifftshift irfft brfft

Out[19]:
fft(A [, dims])

Performs a multidimensional FFT of the array A. The optional dims argument specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to transform along. Most efficient if the size of A along the transformed dimensions is a product of small primes; see nextprod(). See also plan_fft() for even greater efficiency.

A one-dimensional FFT computes the one-dimensional discrete Fourier transform (DFT) as defined by

$\operatorname{DFT}(A)[k] = \sum_{n=1}^{\operatorname{length}(A)} \exp\left(-i\frac{2\pi (n-1)(k-1)}{\operatorname{length}(A)} \right) A[n].$ A multidimensional FFT simply performs this operation along each transformed dimension of A.

Higher performance is usually possible with multi-threading. Use FFTW.set_num_threads(np) to use np threads, if you have np processors.


In [36]:
?sinc


search: sinc significand isinteractive IntrinsicFunction DimensionMismatch

Out[36]:
sinc(x)

Compute $\sin(\pi x) / (\pi x)$ if $x \neq 0$, and $1$ if $x = 0$.

New frequencies introduced by sample-and-hold

We have sampling frequency $\omega_s$ and Nyquist frequency $\omega_N = \frac{\omega_s}{2}$. A continous sinusoid signal of frequency $\omega_1 = 0.8\omega_N$ is sampled and then reconstructed using zero-order-hold. How does the spectrum look like?


In [60]:
ωs = 20
h = 2*pi/ωs
ωN = ωs/2.0
ω1 = 0.8ωN;
# Sampling instants
N = 1000
t = h*linspace(0,N-1, N)
xs = sin.(ω1*t)
# Construct zero-order-hold "continuous" signal
Nc = 100
hc = h/Nc
ωfft = 2π/hc;
x_zoh = repeat(xs, inner=Nc)
tc = hc*linspace(0, N*Nc-1, N*Nc)
figure(figsize=(14,3))
stem(t[1:100], xs[1:100], linefmt="r--", markerfmt="ro", basefmt = "r-")
plot(tc[1:10000], x_zoh[1:10000])
title("sampled signal and zero-order-hold")


Out[60]:
PyObject <matplotlib.text.Text object at 0x7f5982e03090>

In [64]:
X_zoh = fft(x_zoh)
Nhalf = Int32(length(X_zoh)/2)
tTot = hc*length(x_zoh)
ωstep = 2*π/tTot
w = ωstep * linspace(0, Nhalf-1, Nhalf)
figure(figsize=(14,3))
    
pS = plot(w[1:1000], abs.(X_zoh[1:1000]), linewidth=2)


Out[64]:
1-element Array{PyCall.PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x7f5982847f90>

In [52]:
0:ωstep:10


Out[52]:
0.0:0.39999999999999997:10.0

In [51]:
w


Out[51]:
0.0:0.4001600640256102:999.9999999999999

In [ ]: