Example #1
0
def WignerVillecal(data):
    dist = PseudoWignerVilleDistribution(data)
    result = dist.run()
    tfr, times, freqs = result
    x = []
    y = []
    z = []
    for i in range(len(times)):
        for j in range(len(freqs)):
            x.append(times[i])  #时域序号点
            y.append(freqs[j])  #频域序号点
            z.append(tfr[j][i])
    return x, y, z
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.
"""
==========================================================================
Pseudo-Wigner-Ville Distribution of a Gaussian Atom and a Complex Sinusoid
==========================================================================

This example demonstrates the pseudo Wigner Ville distribution of a signal
composed from a Gaussian atom and a complex sinusoid with constant frequency
modulation. Note that the frequency resolution is relatively worse than that of
the Wigner-Ville representation, and the interferences have not been resolved
properly.

Figure 4.9 from the tutorial.
"""

from tftb.generators import fmconst, amgauss
from tftb.processing import PseudoWignerVilleDistribution

sig = fmconst(128, 0.15)[0] + amgauss(128) * fmconst(128, 0.4)[0]
tfr = PseudoWignerVilleDistribution(sig)
tfr.run()
tfr.plot(show_tf=True, kind="contour")
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
==========================================================================
Pseudo-Wigner-Ville Distribution of a Gaussian Atom and a Complex Sinusoid
==========================================================================

This example demonstrates the pseudo Wigner Ville distribution of a signal
composed from a Gaussian atom and a complex sinusoid with constant frequency
modulation. Note that the frequency resolution is relatively worse than that of
the Wigner-Ville representation, and the interferences have not been resolved
properly.

"""

from tftb.generators import fmconst, amgauss
from tftb.processing import PseudoWignerVilleDistribution
import numpy as np

sig = fmconst(128, 0.15)[0] + amgauss(128) * fmconst(128, 0.4)[0]
tfr = PseudoWignerVilleDistribution(sig)
tfr.run()
tfr.plot(show_tf=True, kind="contour",
        freq_x=(abs(np.fft.fftshift(np.fft.fft(sig))) ** 2)[::-1][:64],
        freq_y=np.arange(sig.shape[0] / 2))
Example #4
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.
"""
Example from section 4.1.2 of the tutorials.
"""

from tftb.generators import fmconst, amgauss
from tftb.processing import PseudoWignerVilleDistribution
import numpy as np

sig = fmconst(128, 0.15)[0] + amgauss(128) * fmconst(128, 0.4)[0]
tfr = PseudoWignerVilleDistribution(sig)
tfr.run()
tfr.plot(show_tf=True,
         kind="contour",
         freq_x=(abs(np.fft.fftshift(np.fft.fft(sig)))**2)[::-1][:64],
         freq_y=np.arange(sig.shape[0] / 2))
Example #5
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.
"""
==================================================
Pseudo Wigner-Ville Distribution of Gaussian Atoms
==================================================

This example shows the Pseudo Wigner-Ville distribution of four Gaussian atoms
located at the corners of a rectangle in the time-frequency plane. The
`PseudoWignerVilleDistribution` class uses frequency smoothing, which
attenuates the interferences oscillating along the time axis.

Figure 4.5 from the tutorial.
"""

import numpy as np
from tftb.generators import atoms
from tftb.processing import PseudoWignerVilleDistribution

x = np.array([[32, .15, 20, 1], [96, .15, 20, 1], [32, .35, 20, 1],
              [96, .35, 20, 1]])
g = atoms(128, x)
spec = PseudoWignerVilleDistribution(g)
spec.run()
spec.plot(kind="contour", scale="log", show_tf=True)
Example #6
0
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
==================================================
Pseudo Wigner-Ville Distribution of Gaussian Atoms
==================================================

This example shows the Pseudo Wigner-Ville distribution of four Gaussian atoms
located at the corners of a rectangle in the time-frequency plane. The
`PseudoWignerVilleDistribution` class uses frequency smoothing, which
attenuates the interferences oscillating along the time axis.

Figure 4.5 from the tutorial.
"""

import numpy as np
from tftb.generators import atoms
from tftb.processing import PseudoWignerVilleDistribution

x = np.array([[32, .15, 20, 1],
             [96, .15, 20, 1],
             [32, .35, 20, 1],
             [96, .35, 20, 1]])
g = atoms(128, x)
spec = PseudoWignerVilleDistribution(g)
spec.run()
spec.plot(kind="contour", scale="log", show_tf=True)
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
==========================================================================
Pseudo-Wigner-Ville Distribution of a Gaussian Atom and a Complex Sinusoid
==========================================================================

This example demonstrates the pseudo Wigner Ville distribution of a signal
composed from a Gaussian atom and a complex sinusoid with constant frequency
modulation. Note that the frequency resolution is relatively worse than that of
the Wigner-Ville representation, and the interferences have not been resolved
properly.

Figure 4.9 from the tutorial.
"""

from tftb.generators import fmconst, amgauss
from tftb.processing import PseudoWignerVilleDistribution
import numpy as np

t = np.linspace(0, 1, 128)
sig = fmconst(128, 0.15)[0] + amgauss(128) * fmconst(128, 0.4)[0]
tfr = PseudoWignerVilleDistribution(sig, timestamps=t)
tfr.run()
tfr.plot(show_tf=True, kind="contour")
Example #8
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.
"""

"""

import numpy as np
from tftb.generators import atoms
from tftb.processing import PseudoWignerVilleDistribution
import matplotlib.pyplot as plt

x = np.array([[32, .15, 20, 1], [96, .15, 20, 1], [32, .35, 20, 1],
              [96, .35, 20, 1]])
g = atoms(128, x)
tfr = PseudoWignerVilleDistribution(g).run()[0]
threshold = (np.abs(tfr)**2) * 0.05
tfr[np.abs(tfr)**2 <= threshold] = 0.0

plt.contour(np.abs(tfr)**2, levels=range(5))
plt.show()