Skip to content

Commit

Permalink
Merge pull request #94 from jaidevd/jd-fix-fig4.4567
Browse files Browse the repository at this point in the history
Add Wigner-Ville contour plots to the gallery
  • Loading branch information
jaidevd committed Feb 9, 2016
2 parents fd3ddec + 7d16101 commit 1947ebc
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 111 deletions.
28 changes: 0 additions & 28 deletions doc/_gallery/noplot/noplot_4_1_1_pwv_atoms.py

This file was deleted.

28 changes: 0 additions & 28 deletions doc/_gallery/noplot/noplot_4_1_1_wv_analytic_signal.py

This file was deleted.

28 changes: 0 additions & 28 deletions doc/_gallery/noplot/noplot_4_1_1_wv_atoms.py

This file was deleted.

27 changes: 0 additions & 27 deletions doc/_gallery/noplot/noplot_4_1_1_wv_real_signal.py

This file was deleted.

33 changes: 33 additions & 0 deletions doc/_gallery/plot_4_1_1_pwv_atoms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /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)
34 changes: 34 additions & 0 deletions doc/_gallery/plot_4_1_1_wv_analytic_signal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
====================================================
Wigner Ville Distribution of Analytic Gaussian Atoms
====================================================
This example shows the WVD of and analytic Gaussian atom. As seen in Figure
4.6, the WVD of a real valued signal may present interference terms and
spectral aliasing. One of the ways to fix this is to use an analytic signal,
which divides the spectral domain into two parts: real and imaginary. Thus, the
number of interference terms is also halved. Secondly, analytic signals have no
negative components, so the terms present in the negative half plane also
vanish.
Figure 4.7 from the tutorial.
"""

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

x = np.array([[32, .15, 20, 1],
[96, .32, 20, 1]])
g = atoms(128, x)
spec = WignerVilleDistribution(g)
spec.run()
spec.plot(show_tf=True, kind="contour", scale="log")
32 changes: 32 additions & 0 deletions doc/_gallery/plot_4_1_1_wv_atoms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
===========================================
Wigner-Ville Distribution of Gaussian Atoms
===========================================
This example shows the WV distribution of four Gaussian atoms, each localized
at the corner of a rectangle in the time-frequency plane. The distribution does
show the four signal terms, as well as six interference terms.
Figure 4.4 from the tutorial.
"""

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

x = np.array([[32, .15, 20, 1],
[96, .15, 20, 1],
[32, .35, 20, 1],
[96, .35, 20, 1]])
g = atoms(128, x)
spec = WignerVilleDistribution(g)
spec.run()
spec.plot(kind="contour", show_tf=True, scale="log")
31 changes: 31 additions & 0 deletions doc/_gallery/plot_4_1_1_wv_real_signal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
================================================================================
Sampling Effects on the Wigner-Ville Distribution of a Real Valued Gaussian Atom
================================================================================
This example shows the Wigner-Ville distribution of a real valued Gaussian
atom. If a signal is sampled at the Nyquist rate, the WVD is affected by
spectral aliasing and many additional interferences. To fix this, either the
signal may be oversampled, or an analytical signal may be used.
Figure 4.6 from the tutorial.
"""

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

x = np.array([[32, .15, 20, 1],
[96, .32, 20, 1]])
g = atoms(128, x)
spec = WignerVilleDistribution(np.real(g))
spec.run()
spec.plot(kind="contour", show_tf=True, scale="log")

0 comments on commit 1947ebc

Please sign in to comment.