.. 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_3_4_2_morlet_scalogram_dirac_impulse.py: =================================== Morlet Scalogram of a Dirac Impulse =================================== This example plots the scalogram of a Dirac impulse functions. This shows the behaviour of the scalograms as the scale (or inversely, the frequency) changes. it is well localized for small scales (large frequencies), and less localized as the scale increases (as the frequency decreases). Figure 3.19 from the tutorial. .. image:: /auto_examples/images/sphx_glr_plot_3_4_2_morlet_scalogram_dirac_impulse_001.png :class: sphx-glr-single-img .. code-block:: default from tftb.generators import anapulse from tftb.processing import Scalogram import numpy as np import matplotlib.pyplot as plt sig1 = anapulse(128) tfr, t, f, _ = Scalogram(sig1, waveparams=6, fmin=0.05, fmax=0.45, n_voices=128).run() tfr = np.abs(tfr) ** 2 threshold = np.amax(tfr) * 0.05 tfr[tfr <= threshold] = 0.0 t, f = np.meshgrid(t, f) plt.contour(t, f, tfr, 20) plt.grid() plt.title('Morlet Scalogram of a Dirac Impluse') plt.xlabel('Time') plt.ylabel('Normalized Frequency') plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.205 seconds) .. _sphx_glr_download_auto_examples_plot_3_4_2_morlet_scalogram_dirac_impulse.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_3_4_2_morlet_scalogram_dirac_impulse.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_3_4_2_morlet_scalogram_dirac_impulse.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_