Beispiel #1
0
    def test_filter(self, n_filters=5):
        g = filters.MexicanHat(self._G, n_filters)

        s1 = self._rs.uniform(size=self._G.N)
        s2 = s1.reshape((self._G.N, 1))
        s3 = g.filter(s1)
        s4 = g.filter(s2)
        s5 = g.analyze(s1)
        assert s3.shape == (self._G.N, n_filters)
        np.testing.assert_allclose(s3, s4)
        np.testing.assert_allclose(s3, s5)

        s1 = self._rs.uniform(size=(self._G.N, 4))
        s2 = s1.reshape((self._G.N, 4, 1))
        s3 = g.filter(s1)
        s4 = g.filter(s2)
        s5 = g.analyze(s1)
        assert s3.shape == (self._G.N, 4, n_filters)
        np.testing.assert_allclose(s3, s4)
        np.testing.assert_allclose(s3, s5)

        s1 = self._rs.uniform(size=(self._G.N, n_filters))
        s2 = s1.reshape((self._G.N, 1, n_filters))
        s3 = g.filter(s1)
        s4 = g.filter(s2)
        s5 = g.synthesize(s1)
        assert s3.shape == (self._G.N, )
        np.testing.assert_allclose(s3, s4)
        np.testing.assert_allclose(s3, s5)

        s1 = self._rs.uniform(size=(self._G.N, 10, n_filters))
        s3 = g.filter(s1)
        s5 = g.synthesize(s1)
        assert s3.shape == (self._G.N, 10)
        np.testing.assert_allclose(s3, s5)
Beispiel #2
0
 def test_complement(self, frame_bound=2.5):
     """Any filter bank becomes tight upon addition of their complement."""
     g = filters.MexicanHat(self._G)
     g += g.complement(frame_bound)
     A, B = g.estimate_frame_bounds()
     np.testing.assert_allclose(A, frame_bound)
     np.testing.assert_allclose(B, frame_bound)
Beispiel #3
0
 def test_mexicanhat(self):
     f = filters.MexicanHat(self._G, Nf=5, normalize=False)
     self._test_methods(f, tight=False)
     f = filters.MexicanHat(self._G, Nf=4, normalize=True)
     self._test_methods(f, tight=False)
Beispiel #4
0
DELTA = 255
s = g.localize(DELTA)
fig = plt.figure(figsize=(10, 2.5))
for i in range(4):
    ax = fig.add_subplot(1, 4, i + 1, projection='3d')
    G.plot_signal(s[:, i], ax=ax)
    _ = ax.set_title('Wavelet {}'.format(i + 1))
    ax.set_axis_off()
fig.tight_layout()
plt.show()

# Mexican hat wavelets on a torus
G = graphs.Torus()
G.estimate_lmax()
g = filters.MexicanHat(G, Nf=6)
fig, ax = plt.subplots(figsize=(10, 5))
g.plot(ax=ax)
_ = ax.set_title('Filter bank of Mexican Hat wavelets')

DELTA = 255
s = g.localize(DELTA)
fig = plt.figure(figsize=(10, 2.5))
for i in range(4):
    ax = fig.add_subplot(1, 4, i + 1, projection='3d')
    G.plot_signal(s[:, i], ax=ax)
    _ = ax.set_title('Wavelet {}'.format(i + 1))
    ax.set_axis_off()
fig.tight_layout()
plt.show()