{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Spectrogram of a Noisy Transient Signal\n\nThis example demonstrates the simple use of a Spectrogram to localize a signal\nin time and frequency. The transient signal appears at the normalized frequency\n0.25 and between time points 125 and 160.\n\nFigure 1.11 from the tutorial.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nfrom scipy.signal import hamming\nfrom tftb.generators import amexpos, fmconst, sigmerge, noisecg\nfrom tftb.processing.cohen import Spectrogram\n\n# Generate a noisy transient signal.\ntranssig = amexpos(64, kind='unilateral') * fmconst(64)[0]\nsignal = np.hstack((np.zeros((100,)), transsig, np.zeros((92,))))\nsignal = sigmerge(signal, noisecg(256), -5)\n\nfwindow = hamming(65)\nspec = Spectrogram(signal, n_fbins=128, fwindow=fwindow)\nspec.run()\nspec.plot(kind=\"contour\", threshold=0.1, show_tf=False)"
      ]
    }
  ],
  "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
}