.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_1_3_1_chirp_spectrum.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. 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_chirp_spectrum.py: ================================== Energy Spectral Density of a Chirp ================================== Construct a chirp and plot its `energy spectral density `_. Figure 1.2 from the tutorial. .. GENERATED FROM PYTHON SOURCE LINES 19-38 .. image-sg:: /auto_examples/images/sphx_glr_plot_1_3_1_chirp_spectrum_001.png :alt: Spectrum :srcset: /auto_examples/images/sphx_glr_plot_1_3_1_chirp_spectrum_001.png :class: sphx-glr-single-img .. code-block:: default from tftb.generators import fmlin import matplotlib.pyplot as plt import numpy as np n_points = 128 fmin, fmax = 0.0, 0.5 signal, _ = fmlin(n_points, fmin, fmax) # Plot the energy spectrum of the chirp dsp1 = np.fft.fftshift(np.abs(np.fft.fft(signal)) ** 2) plt.plot(np.arange(-64, 64, dtype=float) / 128.0, dsp1) plt.xlim(-0.5, 0.5) plt.title('Spectrum') 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.131 seconds) .. _sphx_glr_download_auto_examples_plot_1_3_1_chirp_spectrum.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_1_3_1_chirp_spectrum.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_1_3_1_chirp_spectrum.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_