{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Wavelets\nThis example shows how to use the different wavelets available PyLops.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport pylops\n\nplt.close(\"all\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Let's start with defining a time axis and creating the FFT operator\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "dt = 0.004\nnt = 1001\nt = np.arange(nt) * dt\n\nFop = pylops.signalprocessing.FFT(2 * nt - 1, sampling=dt, real=True)\nf = Fop.f"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We can now create the different wavelets and display them\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Gaussian\nwg, twg, wgc = pylops.utils.wavelets.gaussian(t, std=2)\n\n# Gaussian\nwk, twk, wgk = pylops.utils.wavelets.klauder(t, f=[4, 30], taper=np.hanning)\n\n# Ormsby\nwo, two, woc = pylops.utils.wavelets.ormsby(t, f=[5, 9, 25, 30], taper=np.hanning)\n\n# Ricker\nwr, twr, wrc = pylops.utils.wavelets.ricker(t, f0=17)\n\n# Frequency domain\nwgf = Fop @ wg\nwkf = Fop @ wk\nwof = Fop @ wo\nwrf = Fop @ wr"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig, axs = plt.subplots(1, 2, figsize=(14, 6))\naxs[0].plot(twg, wg, \"k\", lw=2, label=\"Gaussian\")\naxs[0].plot(twk, wk, \"r\", lw=2, label=\"Klauder\")\naxs[0].plot(two, wo, \"b\", lw=2, label=\"Ormsby\")\naxs[0].plot(twr, wr, \"y--\", lw=2, label=\"Ricker\")\naxs[0].set(xlim=(-0.4, 0.4), xlabel=\"Time [s]\")\naxs[0].legend()\naxs[1].plot(f, np.abs(wgf) / np.abs(wgf).max(), \"k\", lw=2, label=\"Gaussian\")\naxs[1].plot(f, np.abs(wkf) / np.abs(wkf).max(), \"r\", lw=2, label=\"Klauder\")\naxs[1].plot(f, np.abs(wof) / np.abs(wof).max(), \"b\", lw=2, label=\"Ormsby\")\naxs[1].plot(f, np.abs(wrf) / np.abs(wrf).max(), \"y--\", lw=2, label=\"Ricker\")\naxs[1].set(xlim=(0, 50), xlabel=\"Frequency [Hz]\")\naxs[1].legend()\nplt.tight_layout()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.9.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}