.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_time_frequency.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_time_frequency.py: Hilbert spectrum and Morlet wavelets on a chirp =============================================== A tone that sweeps from 0.02 to 0.2 Hz. The Hilbert spectrum of its MVMD modes follows the sweep sample by sample; the Morlet CWT smooths it over each wavelet's length and marks where edge effects make values unreliable (the cone of influence). .. GENERATED FROM PYTHON SOURCE LINES 9-34 .. image-sg:: /auto_examples/images/sphx_glr_plot_time_frequency_001.png :alt: Hilbert spectrum of the MVMD mode, Morlet CWT, outside the cone of influence :srcset: /auto_examples/images/sphx_glr_plot_time_frequency_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import modewise fs = 1.25 t = np.arange(800) / fs phase = 2 * np.pi * (0.02 * t + 0.5 * (0.18 / t[-1]) * t**2) x = np.vstack([np.sin(phase)]) modes = modewise.mvmd(x, fs, num_modes=1, alpha=50.0) hilbert = modewise.hilbert_spectrum(modewise.hilbert(modes), 0.01, 0.3, 60) cwt = modewise.cwt(x, fs, 0.01, 0.3, 60) fig, (a, b) = plt.subplots(2, 1, figsize=(9, 6), sharex=True) a.pcolormesh(t, hilbert.frequencies_hz, hilbert.power[0], shading="auto") a.set_title("Hilbert spectrum of the MVMD mode") b.pcolormesh(t, cwt.frequencies_hz, np.where(cwt.reliable, cwt.power[0], np.nan), shading="auto") b.set_title("Morlet CWT, outside the cone of influence") for ax in (a, b): ax.plot(t, 0.02 + (0.18 / t[-1]) * t, "w--", lw=0.8) ax.set_ylabel("frequency (Hz)") b.set_xlabel("time (s)") fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.119 seconds) .. _sphx_glr_download_auto_examples_plot_time_frequency.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_time_frequency.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_time_frequency.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_time_frequency.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_