140 lines
112 KiB
Plaintext
140 lines
112 KiB
Plaintext
|
{
|
||
|
"metadata": {
|
||
|
"name": "",
|
||
|
"signature": "sha256:46ebd0819e8459e236e33293377fddb82dc24781d6125093a26ed0006b1ede44"
|
||
|
},
|
||
|
"nbformat": 3,
|
||
|
"nbformat_minor": 0,
|
||
|
"worksheets": [
|
||
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"%matplotlib inline\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import numpy as np\n",
|
||
|
"import pylab, fir"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 95
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"sample_rate = 20 # Hz\n",
|
||
|
"corner_frequency = 1.6 # Hz\n",
|
||
|
"npoints = 51\n",
|
||
|
"nyquist_freq = sample_rate / 2\n",
|
||
|
"\n",
|
||
|
"sinc = np.linspace(npoints / -2, npoints / 2, npoints)\n",
|
||
|
"sinc = np.sinc(sinc * 2 * (corner_frequency / sample_rate))\n",
|
||
|
"plt.plot(sinc)"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "pyout",
|
||
|
"prompt_number": 96,
|
||
|
"text": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7fa0a36e9860>]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEACAYAAABfxaZOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xm8VfP+x/HXUVGGIqWo3Ih7VWaaCJtcKrkZMoRrzli5\n+JGui8N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t6ZjpVv2gKbA6cA\nYytt8zLQHTvpuyXQBZjnsV2R35g8ORr1/BSN4JGgeC3vbAAGAm9iSf1R4FPgwuTzD2HDOccBs7Bv\nAQ+jpC9ZFpWTuCkdO8LSpfD991bjF/FLmC5WV3lHMta+PYwaBfvuG3QkddejB/zP/0CvXkFHIlHm\nd3lHJHArV9qUxWFbNKU2Gq8vQVDSl8ibOhUOPBDqey1W+kx1fQmCkr5EXtTq+Sldutgw07KyoCOR\nOFHSl8iLykVZlTVvbj/zNKxBfKSkL5FWVmblnSgmfbC4VeIRPynpS6QVF8P228MOOwQdSWa6ddPJ\nXPGXkr5EWtQuyqpMPX3xm5K+RFpUT+Km7L03LFoEP/wQdCQSF0r6EmlRPYmbUr8+HHCAjeIR8YOS\nvkTWqlVQUmK95SjTRVriJyV9iaxp02D//aFBg6Aj8UYXaYmflPQlsqJ+Ejela1cbdqqLtMQPSvoS\nWVOmRLuen9KiBWy7bXTWApBoU9KXSCori/7InYpU1xe/KOlLJH3+OTRpAi1bBh1JdqiuL35R0pdI\nivpQzcrU0xe/KOlLJOVTaQdsgfQvvoDVq4OORPKdkr5EUr719Dff3Fb90kVakmtK+hI5q1fDggXR\nWhqxLjT5mvghG0m/J7b4+efA
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x7fa0a3953828>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 96
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"def filter_from_points(points):\n",
|
||
|
" return fir.Filter(points / sum(points))\n",
|
||
|
"\n",
|
||
|
"bode_points = 997\n",
|
||
|
"respfunc = pylab.vectorize(lambda fi, freq: fi.response(freq/sample_rate))\n",
|
||
|
"freq = pylab.logspace(-1, pylab.log10(nyquist_freq), bode_points)\n",
|
||
|
"\n",
|
||
|
"fi_list = { }\n",
|
||
|
"fi_list[\"rectangle\"] = filter_from_points(sinc)\n",
|
||
|
"fi_list[\"blackman\"] = filter_from_points(sinc * np.blackman(len(sinc)))\n",
|
||
|
"fi_list[\"hamming\"] = filter_from_points(sinc * np.hamming(len(sinc)))\n",
|
||
|
"fi_list[\"hann\"] = filter_from_points(sinc * np.hanning(len(sinc)))\n",
|
||
|
"fi_list[\"kaiser_8\"] = filter_from_points(sinc * np.kaiser(len(sinc), 8))\n",
|
||
|
"fi_list[\"kaiser_10\"] = filter_from_points(sinc * np.kaiser(len(sinc), 10))"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 93
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [
|
||
|
"fig, axes = plt.subplots(figsize=(10,6), dpi=100)\n",
|
||
|
"axes.set_xlabel('Frequency (Hz)')\n",
|
||
|
"\n",
|
||
|
"for name, fi in fi_list.items():\n",
|
||
|
" resp = respfunc(fi, freq)\n",
|
||
|
" axes.plot(freq, 20 * np.log10(np.abs(resp)), label=name)\n",
|
||
|
" \n",
|
||
|
"axes.legend()"
|
||
|
],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "pyout",
|
||
|
"prompt_number": 94,
|
||
|
"text": [
|
||
|
"<matplotlib.legend.Legend at 0x7fa0a37a6c88>"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data",
|
||
|
"png": "iVBORw0KGgoAAAANSUhEUgAAAl8AAAF/CAYAAAB3+6y2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XdcldUfwPHPBRSRjbKHgLhw7z2yNLc5M0dmmiNt2a/l\nNs0cuMo9K7fmIrdhapppDhw5cYACyt6be35/oCQyvCCg1vf9et0X9z7nPN/n3OcyvpxznvOAEEII\nIYQQQgghhBBCCCGEEEIIIYQQQ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Xvef/99oqKiSE1N5ejRowDY2toSHh5OTExMZqy4uDhMTU0pXbo0V69eZfHi\nxXkeWymVObTYu3dv5s+fT1BQEFFRUcyYMSPXOV/Dhw9n2rRpXL58GYDo6Gi2bNlSGKdDJ5J8CSGE\nEKLAnJyc2LlzJ9OmTcPGxgYXFxdmz56deZXhmjVrKFGiBJUrV8bW1pbvvvsOgMqVK/PWW2/h7u6O\nlZUV9+/fx8vLi/Xr12NmZsbQoUPp06dPlgTqyWTq8bW73nvvPdq2bUuNGjWoW7cuHTt2RF9fHz29\n7KnOG2+8wRdffEGfPn0wNzenevXqmRP3i8OLsdpYdiq3SXJCCCHEf4VGo8l10rjI2969exkxYgR3\n7twptJi5fR4PE0Cdcyrp+RJCCCHESy8pKYk9e/aQlpZGYGAgkydPpnv37s+7WTmSni8hhBDiBSU9\nX7pLTEykZcuWXL16FSMjIzp16sT8+fMxMTEptGMUVs+XJF9CCCHEC0qSrxeLDDsKIYQQQryEJPkS\nQgghhChGknwJIYQQQhQjSb6E
|
||
|
"text": [
|
||
|
"<matplotlib.figure.Figure at 0x7fa0a37a6da0>"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"prompt_number": 94
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"prompt_number": 86
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"collapsed": false,
|
||
|
"input": [],
|
||
|
"language": "python",
|
||
|
"metadata": {},
|
||
|
"outputs": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {}
|
||
|
}
|
||
|
]
|
||
|
}
|