Energy Spectral Density of a ChirpΒΆ

Construct a chirp and plot its energy spectral density.

Figure 1.2 from the tutorial.

../_images/sphx_glr_plot_1_3_1_chirp_spectrum_001.png
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()

Total running time of the script: ( 0 minutes 0.173 seconds)

Gallery generated by Sphinx-Gallery