.. 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_1_noisy_chirp_spectrum.py: ================================ Energy Spectrum of a Noisy Chirp ================================ Generate a noisy chirp and plot its energy spectrum. Figure 1.5 from the tutorial. .. image:: /auto_examples/images/sphx_glr_plot_1_3_1_noisy_chirp_spectrum_001.png :class: sphx-glr-single-img .. code-block:: default from tftb.generators import fmlin, sigmerge, noisecg import matplotlib.pyplot as plt import numpy as np # Generate a chirp signal n_points = 128 fmin, fmax = 0.0, 0.5 signal, _ = fmlin(n_points, fmin, fmax) # Noisy chirp noisy_signal = sigmerge(signal, noisecg(128), 0) # Enery spectrum of the noisy chirp. dsp1 = np.fft.fftshift(np.abs(np.fft.fft(noisy_signal)) ** 2) plt.plot(np.arange(-64, 64, dtype=float) / 128.0, dsp1) plt.xlim(-0.5, 0.5) plt.title('Spectrum of Noisy Chirp') plt.ylabel('Squared modulus') plt.xlabel('Normalized Frequency') plt.grid() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.164 seconds) .. _sphx_glr_download_auto_examples_plot_1_3_1_noisy_chirp_spectrum.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_1_3_1_noisy_chirp_spectrum.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_1_3_1_noisy_chirp_spectrum.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_