Exemple #1
0
    def test_wigner_ville_regionprops(self):
        """Test the regional property of the Wigner Ville representation."""
        signal, _ = fmsin(128)
        signal[64:] = 0
        tfr = cohen.wigner_ville(signal)
        self.assertTrue(np.all(tfr[:, 64:] == 0))

        signal, _ = fmsin(128)
        signal[:64] = 0
        tfr = cohen.wigner_ville(signal)
        self.assertTrue(np.all(tfr[:, :64] == 0))
Exemple #2
0
    def test_wigner_ville_regionprops(self):
        """Test the regional property of the Wigner Ville representation."""
        signal, _ = fmsin(128)
        signal[64:] = 0
        tfr = cohen.wigner_ville(signal)
        self.assertTrue(np.all(tfr[:, 64:] == 0))

        signal, _ = fmsin(128)
        signal[:64] = 0
        tfr = cohen.wigner_ville(signal)
        self.assertTrue(np.all(tfr[:, :64] == 0))
Exemple #3
0
 def test_wigner_ville_projection(self):
     """Test the projection property of the Wigner Ville representation."""
     signal, _ = fmsin(128)
     tfr = cohen.wigner_ville(signal)
     x = np.abs(signal) ** 2
     y = np.sum(tfr, axis=0) / 128
     np.testing.assert_allclose(x, y)
Exemple #4
0
 def test_wigner_ville_projection(self):
     """Test the projection property of the Wigner Ville representation."""
     signal, _ = fmsin(128)
     tfr = cohen.wigner_ville(signal)
     x = np.abs(signal)**2
     y = np.sum(tfr, axis=0) / 128
     np.testing.assert_allclose(x, y)
Exemple #5
0
 def test_wigner_ville_energy(self):
     """Test the energy property of the Wigner Ville representation."""
     signal, _ = fmsin(128)
     signal = signal / 128.0
     tfr = cohen.wigner_ville(signal)
     x = np.sum(np.sum(tfr))
     y = np.sum(np.abs(signal) ** 2) * 128
     self.assertEqual(x, y)
Exemple #6
0
 def test_wigner_ville_energy(self):
     """Test the energy property of the Wigner Ville representation."""
     signal, _ = fmsin(128)
     signal = signal / 128.0
     tfr = cohen.wigner_ville(signal)
     x = np.sum(np.sum(tfr))
     y = np.sum(np.abs(signal)**2) * 128
     self.assertEqual(x, y)
Exemple #7
0
 def test_reality(self):
     """Test the reality property of the Wigner Ville representation."""
     signal, _ = fmsin(128)
     tfr = cohen.wigner_ville(signal)
     self.assertTrue(np.all(np.isreal(tfr)))
Exemple #8
0
 def test_reality(self):
     """Test the reality property of the Wigner Ville representation."""
     signal, _ = fmsin(128)
     tfr = cohen.wigner_ville(signal)
     self.assertTrue(np.all(np.isreal(tfr)))
Exemple #9
0
            if np.any(indices):
                time_points = np.ones((indices.sum(),)) * ti
                freq_points = np.arange(indices.shape[0])[indices] / (2.0 * n_fbins)
    elif method in ("rsp", "type1"):
        for icol in xrange(tfrcol):
            ti = timestamps[icol]
            condt1 = np.real(re_mat[:, icol]) - freqs == 0
            condt2 = np.imag(re_mat[:, icol]) - icol == 0
            condt3 = tfr[:, icol] > threshold
            indices = np.logical_and(condt1, condt2, condt3)
            if np.any(indices):
                time_points = np.ones((indices.sum(),)) * ti
                freq_points = np.arange(indices.shape[0])[indices] / n_fbins
    else:
        raise ValueError("Unknown time frequency representation.")
    return time_points, freq_points

if __name__ == '__main__':
    from tftb.generators import fmlin
    from tftb.processing.cohen import wigner_ville
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    y = fmlin(64, 0.1, 0.3)[0]
    image = wigner_ville(y, np.arange(64), 64)
    ht, rho, theta = hough_transform(image, 64, 64)
    theta, rho = np.meshgrid(theta, rho)
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.plot_wireframe(theta, rho, ht)
    plt.show()
Exemple #10
0
                freq_points = np.arange(
                    indices.shape[0])[indices] / (2.0 * n_fbins)
    elif method in ("rsp", "type1"):
        for icol in xrange(tfrcol):
            ti = timestamps[icol]
            condt1 = np.real(re_mat[:, icol]) - freqs == 0
            condt2 = np.imag(re_mat[:, icol]) - icol == 0
            condt3 = tfr[:, icol] > threshold
            indices = np.logical_and(condt1, condt2, condt3)
            if np.any(indices):
                time_points = np.ones((indices.sum(), )) * ti
                freq_points = np.arange(indices.shape[0])[indices] / n_fbins
    else:
        raise ValueError("Unknown time frequency representation.")
    return time_points, freq_points


if __name__ == '__main__':
    from tftb.generators import fmlin
    from tftb.processing.cohen import wigner_ville
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    y = fmlin(64, 0.1, 0.3)[0]
    image = wigner_ville(y, np.arange(64), 64)
    ht, rho, theta = hough_transform(image, 64, 64)
    theta, rho = np.meshgrid(theta, rho)
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.plot_wireframe(theta, rho, ht)
    plt.show()