{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "efa27eb8",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "cc99113c",
            "cell_type": "markdown",
            "source": "Design a digital bandstop filter which rejects -60 dB from 0.2*(fs/2) to\n0.5*(fs/2), while staying within 3 dB below 0.1*(fs/2) or above\n0.6*(fs/2). Plot its frequency response, showing the passband and\nstopband constraints in gray.\n",
            "metadata": {}
        },
        {
            "id": "e0b15ed5",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy import signal\nimport matplotlib.pyplot as plt\nimport numpy as np",
            "outputs": []
        },
        {
            "id": "b1b65ca6",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "N, Wn = signal.cheb2ord([0.1, 0.6], [0.2, 0.5], 3, 60)\nb, a = signal.cheby2(N, 60, Wn, 'stop')\nw, h = signal.freqz(b, a)\nplt.semilogx(w / np.pi, 20 * np.log10(abs(h)))\nplt.title('Chebyshev II bandstop filter fit to constraints')\nplt.xlabel('Normalized frequency')\nplt.ylabel('Amplitude [dB]')\nplt.grid(which='both', axis='both')\nplt.fill([.01, .1, .1, .01], [-3,  -3, -99, -99], '0.9', lw=0) # stop\nplt.fill([.2,  .2, .5,  .5], [ 9, -60, -60,   9], '0.9', lw=0) # pass\nplt.fill([.6,  .6,  2,   2], [-99, -3,  -3, -99], '0.9', lw=0) # stop\nplt.axis([0.06, 1, -80, 3])\nplt.show()",
            "outputs": []
        }
    ]
}