Time and Frequency Localization Characteristics

Generate a signal that has localized characteristics in both time and frequency and compute the following estimates:

  • time center
  • time duration
  • frequency center
  • frequency spreading

Example 2.1 from the tutorial.

../_images/sphx_glr_plot_2_2_1_time_freq_localization_001.png

Out:

Time Center: 127.00000000000001
Time Duration: 32.0
Frequency Center: 0.24901960784313726
Frequency Spreading: 0.07009643234823573

from tftb.generators import fmlin, amgauss
from tftb.processing import loctime, locfreq
import numpy as np
import matplotlib.pyplot as plt

# generate signal
signal = fmlin(256)[0] * amgauss(256)
plt.subplot(211), plt.plot(np.real(signal))
plt.xlim(0, 256)
plt.xlabel('Time')
plt.ylabel('Real part')
plt.title('Signal')
plt.grid()
fsig = np.fft.fftshift(np.abs(np.fft.fft(signal)) ** 2)
plt.subplot(212), plt.plot(np.linspace(0, 0.5, 256), fsig)
plt.xlabel('Normalized frequency')
plt.ylabel('Squared modulus')
plt.title('Spectrum')
plt.grid()
plt.subplots_adjust(hspace=0.5)
plt.show()


tm, T = loctime(signal)
print("Time Center: {}".format(tm))
print("Time Duration: {}".format(T))
num, B = locfreq(signal)
print("Frequency Center: {}".format(num))
print("Frequency Spreading: {}".format(B))

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

Gallery generated by Sphinx-Gallery