.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_1_3_3_transient_spectrogram.py: ======================================= Spectrogram of a Noisy Transient Signal ======================================= This example demonstrates the simple use of a Spectrogram to localize a signal in time and frequency. The transient signal appears at the normalized frequency 0.25 and between time points 125 and 160. Figure 1.11 from the tutorial. .. image:: /auto_examples/images/sphx_glr_plot_1_3_3_transient_spectrogram_001.png :class: sphx-glr-single-img .. code-block:: default import numpy as np from scipy.signal import hamming from tftb.generators import amexpos, fmconst, sigmerge, noisecg from tftb.processing.cohen import Spectrogram # Generate a noisy transient signal. transsig = amexpos(64, kind='unilateral') * fmconst(64)[0] signal = np.hstack((np.zeros((100,)), transsig, np.zeros((92,)))) signal = sigmerge(signal, noisecg(256), -5) fwindow = hamming(65) spec = Spectrogram(signal, n_fbins=128, fwindow=fwindow) spec.run() spec.plot(kind="contour", threshold=0.1, show_tf=False) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.177 seconds) .. _sphx_glr_download_auto_examples_plot_1_3_3_transient_spectrogram.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_1_3_3_transient_spectrogram.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_1_3_3_transient_spectrogram.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_