{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "19c1992d",
            "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": "beec9bf1",
            "cell_type": "markdown",
            "source": "We want to construct a band-pass filter. Note that the behavior in the\nfrequency ranges between our stop bands and pass bands is unspecified,\nand thus may overshoot depending on the parameters of our filter:\n",
            "metadata": {}
        },
        {
            "id": "a6020838",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import signal\nimport matplotlib.pyplot as plt\nfig, axs = plt.subplots(2)\nfs = 10.0  # Hz\ndesired = (0, 0, 1, 1, 0, 0)\nfor bi, bands in enumerate(((0, 1, 2, 3, 4, 5), (0, 1, 2, 4, 4.5, 5))):\n    fir_firls = signal.firls(73, bands, desired, fs=fs)\n    fir_remez = signal.remez(73, bands, desired[::2], fs=fs)\n    fir_firwin2 = signal.firwin2(73, bands, desired, fs=fs)\n    hs = list()\n    ax = axs[bi]\n    for fir in (fir_firls, fir_remez, fir_firwin2):\n        freq, response = signal.freqz(fir)\n        hs.append(ax.semilogy(0.5*fs*freq/np.pi, np.abs(response))[0])\n    for band, gains in zip(zip(bands[::2], bands[1::2]),\n                           zip(desired[::2], desired[1::2])):\n        ax.semilogy(band, np.maximum(gains, 1e-7), 'k--', linewidth=2)\n    if bi == 0:\n        ax.legend(hs, ('firls', 'remez', 'firwin2'),\n                  loc='lower center', frameon=False)\n    else:\n        ax.set_xlabel('Frequency (Hz)')\n    ax.grid(True)\n    ax.set(title='Band-pass %d-%d Hz' % bands[2:4], ylabel='Magnitude')\n\nfig.tight_layout()\nplt.show()",
            "outputs": []
        }
    ]
}