{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Tapers\nThis example shows how to create some basic tapers in 1d, 2d, and 3d\nusing the :py:mod:`pylops.utils.tapers` module.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport pylops\n\nplt.close('all')"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Let's first define the time and space axes\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "par = {'ox':-200, 'dx':2, 'nx':201,\n       'oy':-100, 'dy':2, 'ny':101,\n       'ot':0, 'dt':0.004, 'nt':501,\n       'ntapx': 21, 'ntapy': 31}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We can now create tapers in 1d\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "tap_han = pylops.utils.tapers.hanningtaper(par['nx'],\n                                           par['ntapx'])\ntap_cos = pylops.utils.tapers.cosinetaper(par['nx'], par['ntapx'], False)\ntap_cos2 = pylops.utils.tapers.cosinetaper(par['nx'], par['ntapx'], True)\n\nplt.figure()\nplt.plot(tap_han, 'r', label='hanning')\nplt.plot(tap_cos, 'k', label='cosine')\nplt.plot(tap_cos2, 'b', label='cosine square')\nplt.title('Tapers')\nplt.legend()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Similarly we can create 2d and 3d tapers with any of the tapers above\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "tap2d = pylops.utils.tapers.taper2d(par['nt'], par['nx'],\n                                    par['ntapx'])\n\nplt.figure(figsize=(7, 3))\nplt.plot(tap2d[:, par['nt']//2], 'k', lw=2)\nplt.title('Taper')\n\ntap3d = pylops.utils.tapers.taper3d(par['nt'], (par['ny'], par['nx']),\n                                    (par['ntapy'], par['ntapx']))\n\nplt.figure(figsize=(7, 3))\nplt.imshow(tap3d[:, :, par['nt']//2], 'jet')\nplt.title('Taper in y-x slice')\nplt.xlabel('x')\nplt.ylabel('y')"
      ]
    }
  ],
  "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.6.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}