def update(self, changed, thread): wavelet = self.wavelet.get() if wavelet.get_name() in ["triangle", "triangle2", 'b1', "b3"]: dec = wtutils.uiwt else: dec = wtutils.uwt n = 1000 nscales = min(wavelet.get_max_level(np.zeros(n)), 6) w = np.logspace(0, 8, 100, base=2) intensities = np.zeros([nscales, len(w)]) widths = np.zeros([nscales, len(w)]) for i, width in enumerate(w): s = signalutils.gaussian(n, width=width) # s = s / s.sum() # s = signalutils.square(n, width) # s = signalutils.lorentzian(n, width) # s = np.sin((2 * np.pi) * np.arange(n) / (width)) scales = wtutils.wavedec(s, wavelet, nscales, dec=dec, boundary="zero") for j, scale in enumerate(scales[:-1]): # intensities[j, i] = (scale ** 2).sum() / s.sum() intensities[j, i] = scale.max() # intensities[j, i] = np.abs(scale).sum() return w, intensities, widths
def main(): # t = np.arange(0, 10, 0.01) # x = np.sin(2 * t) + np.cos(20 * t) + np.sqrt(t) # x = signalutils.linear_chirp(t, 1, 20, 0, 0) - \ # signalutils.linear_chirp(t, 1, 7, 0, 0) x = np.zeros(500) center = 20 for width in [2, 4, 8, 16, 32, 50]: x += signalutils.gaussian(500, width=width, center=center) center += min(10 * width, 120) # g1 = signalutils.gaussian(500, width=20, center_offset=-150) # # x += g1 # g2 = signalutils.gaussian(500, width=5, center_offset=150) # x = g1 + g2 # x = np.cos(np.arange(100) / 2) w = WaveletTransform(np.arange(500), x) w.gui.start()