{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Morlet Scalogram of a Dirac Impulse\n\nThis example plots the scalogram of a Dirac impulse functions. This shows the\nbehaviour of the scalograms as the scale (or inversely, the frequency) changes.\nit is well localized for small scales (large frequencies), and less localized\nas the scale increases (as the frequency decreases).\n\nFigure 3.19 from the tutorial.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from tftb.generators import anapulse\nfrom tftb.processing import Scalogram\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nsig1 = anapulse(128)\ntfr, t, f, _ = Scalogram(sig1, waveparams=6, fmin=0.05, fmax=0.45,\n                         n_voices=128).run()\ntfr = np.abs(tfr) ** 2\nthreshold = np.amax(tfr) * 0.05\ntfr[tfr <= threshold] = 0.0\nt, f = np.meshgrid(t, f)\nplt.contour(t, f, tfr, 20)\nplt.grid()\nplt.title('Morlet Scalogram of a Dirac Impluse')\nplt.xlabel('Time')\nplt.ylabel('Normalized Frequency')\nplt.show()"
      ]
    }
  ],
  "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.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}