def get_wvd_data_for_frames(frames, num_columns, num_rows):
    # Create stack of planes for WVD with values corresponding to each
    #   sensor
    len_frames = len(frames)
    wvd_planes = np.zeros((num_columns * num_rows, len_frames, len_frames))
    count = 0
    for i in range(num_columns):
        for j in range(num_rows):
            # Compute Wigner Ville Distribution along frame aisle (z axis)
            wvd_data, _, _ = WignerVilleDistribution(frames[:, i, j]).run()
            wvd_planes[count, :, :] = wvd_data

    return wvd_planes
#! /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 two simultaneous chirps.
"""

from tftb.generators import fmlin, sigmerge
from tftb.processing.cohen import WignerVilleDistribution

N = 64
sig = sigmerge(fmlin(N, 0, 0.4)[0], fmlin(N, 0.3, 0.5)[0], 1)
tfr = WignerVilleDistribution(sig)
tfr.run()
tfr.plot(kind='contour', sqmod=True, show_tf=True)
"""
=================================================
Hough-Wigner Transform of Two Simultaneous Chirps
=================================================

Compute the Hough transform of the Wigner-Ville distribution of a signal
composed of two chirps. Two peaks corresponding to the two chirps can be seen.

Figure 5.6 from the tutorial.
"""

from tftb.generators import fmlin, sigmerge
from tftb.processing.cohen import WignerVilleDistribution
from tftb.processing.postprocessing import hough_transform
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

N = 64
sig = sigmerge(fmlin(N, 0, 0.4)[0], fmlin(N, 0.3, 0.5)[0], 1)
tfr, _, _ = WignerVilleDistribution(sig).run()

ht, rho, theta = hough_transform(tfr, N, N)
theta, rho = np.meshgrid(theta, rho)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_wireframe(theta, rho, ht)
ax.set_xlabel('Theta')
ax.set_ylabel('Rho')
plt.show()
# Distributed under terms of the MIT license.
"""
==========================================
Wigner-Ville Distribution of a Noisy Chirp
==========================================

Generate a noisy chirp and visualize its Wigner-Ville spectrum.

Figure 1.6 from the tutorial.
"""

from tftb.generators import fmlin, sigmerge, noisecg
from tftb.processing.cohen import WignerVilleDistribution

# Generate a chirp signal

n_points = 128
fmin, fmax = 0.0, 0.5

signal, _ = fmlin(n_points, fmin, fmax)

# Noisy chirp

noisy_signal = sigmerge(signal, noisecg(128), 0)

# Wigner-Ville spectrum of noisy chirp.

wvd = WignerVilleDistribution(noisy_signal)
wvd.run()
wvd.plot(kind='contour')
Beispiel #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.
"""
Example in section 1.3.1
"""

from tftb.generators import fmlin
from tftb.processing.cohen import WignerVilleDistribution

n_points = 128
fmin, fmax = 0.0, 0.5
signal, _ = fmlin(n_points, fmin, fmax)

# Wigner-Ville distribution of the chirp.

wvd = WignerVilleDistribution(signal)
wvd.run()
wvd.plot(kind='contour', extent=[0, n_points, fmin, fmax])
Beispiel #6
0
#! /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 a Chirp
====================================

Construct a chirp signal and visualize its `Wigner-Ville distribution
<https://en.wikipedia.org/wiki/Wigner_distribution_function>`_.

"""

from tftb.generators import fmlin
from tftb.processing.cohen import WignerVilleDistribution

n_points = 128
fmin, fmax = 0.0, 0.5
signal, _ = fmlin(n_points, fmin, fmax)

# Wigner-Ville distribution of the chirp.

wvd = WignerVilleDistribution(signal)
wvd.run()
wvd.plot(kind='contour', extent=[0, n_points, fmin, fmax])
#! /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 a Noisy Chirp
==========================================

This example shows the Wigner-Ville distribution of a noisy chirp signal. The
linear frequency increase is undetectable in the time domain, but a straight
line can be seen in the distribution.

"""

from tftb.generators import noisecg, sigmerge, fmlin
from tftb.processing.cohen import WignerVilleDistribution

N = 64
sig = sigmerge(fmlin(N, 0, 0.3)[0], noisecg(N), 1)
wvd = WignerVilleDistribution(sig)
wvd.run()
wvd.plot(kind='contour', show_tf=True, sqmod=True)
Beispiel #8
0
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
Examples showing Renyi information measurement.
"""

import numpy as np
from scipy.io import loadmat
from tftb.generators import atoms
from tftb.processing import renyi_information
from tftb.processing.cohen import WignerVilleDistribution

sig = atoms(128, np.array([[64, 0.25, 20, 1]]))
tfr, t, f = WignerVilleDistribution(sig).run()
ideal = loadmat("/tmp/foo.mat")
print(renyi_information(tfr, t, f))  # -0.2075

sig = atoms(128, np.array([[32, 0.25, 20, 1], [96, 0.25, 20, 1]]))
tfr, t, f = WignerVilleDistribution(sig).run()
print(renyi_information(tfr, t, f))  # 0.77

sig = atoms(128, np.array([[32, 0.15, 20, 1], [96, 0.15, 20, 1],
                           [32, 0.35, 20, 1], [96, 0.35, 20, 1]]))
tfr, t, f = WignerVilleDistribution(sig).run()
print(renyi_information(tfr, t, f))  # 1.8029
"""
==========================================
Wigner-Ville Distribution of a Noisy Chirp
==========================================

Generate a noisy chirp and visualize its Wigner-Ville spectrum.

"""

from tftb.generators import fmlin, sigmerge, noisecg
from tftb.processing.cohen import WignerVilleDistribution

# Generate a chirp signal

n_points = 128
fmin, fmax = 0.0, 0.5

signal, _ = fmlin(n_points, fmin, fmax)

# Noisy chirp

noisy_signal = sigmerge(signal, noisecg(128), 0)


# Wigner-Ville spectrum of noisy chirp.

wvd = WignerVilleDistribution(noisy_signal)
wvd.run()
wvd.plot(kind='contour')
#! /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 a Noisy Chirp
==========================================

This example shows the Wigner-Ville distribution of a noisy chirp signal. The
linear frequency increase is undetectable in the time domain, but a straight
line can be seen in the distribution.

Figure 5.3 from the tutorial.
"""

from tftb.generators import noisecg, sigmerge, fmlin
from tftb.processing.cohen import WignerVilleDistribution

N = 64
sig = sigmerge(fmlin(N, 0, 0.3)[0], noisecg(N), 1)
wvd = WignerVilleDistribution(sig)
wvd.run()
wvd.plot(kind='contour', show_tf=True, sqmod=True)
Beispiel #11
0
test.write(":RUN")
test.write(":KEY:FORC")

plt.plot(time1, finalData1)
plt.title("Oscilloscope Channel 1")
plt.ylabel("Voltage (V)")
plt.xlabel("Time (uS)")
plt.show()

plt.plot(time2, finalData2)
plt.title("Oscilloscope Channel 2")
plt.ylabel("Voltage (V)")
plt.xlabel("Time (uS)")
plt.show()

wvd = WignerVilleDistribution(finalData1)
wvd.run()
wvd.plot(kind='cont')
#print(k)

n_fbins = 1190
signal = finalData1

y = np.linspace(0, 1000, finalData1.shape[0])
X, Y = np.meshgrid(time1, y)

tausec = round(n_fbins)
winlength = tausec - 1

ts = time1
Beispiel #12
0
def plot_wvd(signal):
    wvd = WignerVilleDistribution(signal)
    wvd.run()
    wvd.plot(kind='contour')