示例#1
0
This example compares the spectrogram and the reassigned spectrogram of a
hybrid signal (containing sinusoidal, constant and linear frequency
modulations), against its ideal time-frequency characteristics.

Figure 4.34 from the tutorial.
"""

from tftb.generators import fmsin, fmhyp
from tftb.processing import ideal_tfr, reassigned_spectrogram, Spectrogram
import numpy as np
import matplotlib.pyplot as plt

n_points = 128
sig1, if1 = fmsin(n_points, 0.15, 0.45, 100, 1, 0.4, -1)
sig2, if2 = fmhyp(n_points, [1, .5], [32, 0.05])
sig = sig1 + sig2
ideal, t, f = ideal_tfr(np.vstack((if1, if2)))
_, re_spec, _ = reassigned_spectrogram(sig)
spec, t3, f3 = Spectrogram(sig).run()

# Ideal tfr
plt.subplot(221)
plt.contour(t, f, ideal, 1)
plt.grid(True)
plt.gca().set_xticklabels([])
plt.title("Ideal time-frequency distro")
plt.ylabel('Normalized Frequency')

# Spectrogram
plt.subplot(222)
示例#2
0
文件: fmhyp.py 项目: xz885511/pytftb
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.
"""

"""

from tftb.generators import fmhyp
import numpy as np
import matplotlib.pyplot as plt

signal, iflaw = fmhyp(128, (1, 0.5), (32, 0.1))
plt.subplot(211), plt.plot(np.real(signal))
plt.xlim(0, 128)
plt.grid()
plt.title('Hyperbolic Frequency Modulation')
plt.subplot(212), plt.plot(iflaw)
plt.xlim(0, 128)
plt.grid()
plt.title('Instantaneous Frequency')
plt.show()
========================================================

This example compares the spectrogram and the reassigned spectrogram of a
hybrid signal (containing sinusoidal, constant and linear frequency
modulations), against its ideal time-frequency characteristics.

"""

from tftb.generators import fmsin, fmhyp
from tftb.processing import ideal_tfr, reassigned_spectrogram, Spectrogram
import numpy as np
import matplotlib.pyplot as plt

n_points = 128
sig1, if1 = fmsin(n_points, 0.15, 0.45, 100, 1, 0.4, -1)
sig2, if2 = fmhyp(n_points, [1, .5], [32, 0.05])
sig = sig1 + sig2
ideal, t, f = ideal_tfr(np.vstack((if1, if2)))
_, re_spec, _ = reassigned_spectrogram(sig)
spec, t3, f3 = Spectrogram(sig).run()

# Ideal tfr
plt.subplot(221)
plt.contour(t, f, ideal, 1)
plt.grid(True)
plt.gca().set_xticklabels([])
plt.title("Ideal time-frequency distro")
plt.ylabel('Normalized Frequency')

# Spectrogram
plt.subplot(222)