Exemplo n.º 1
0
    R_MIN, R_MAX = 0, 5
    K_MIN, K_MAX = -5, 5

    # Making sure that there's W_MIN_DIFF between all W
    while True:
        W = np.random.random(oscN) * W_MAX + W_MIN
        if np.all(np.diff(W) > W_MIN_DIFF): break

    R = np.random.random(oscN) * R_MAX + R_MIN
    Y0 = np.random.random(oscN) * Y_MAX + Y_MIN
    K = np.random.random((oscN, nH * (oscN - 1))) * K_MAX + K_MIN
    K[:] = 0.8 * W[:, None] * K / np.sum(K, axis=1)[:, None]

    theta = np.column_stack((W, Y0, R, K))

    kursl = KurSL(theta)
    _, _, s_gen = kursl.generate(t)
    s_gen = np.sum(s_gen, axis=0)
    t = t[:-1]

    ####################################################
    ## Estimate peaks present in signal
    preprocess = Preprocessor(max_osc=oscN, nH=nH)
    theta_init = preprocess.compute_prior(t, s_gen)
    peaks = theta_init[:, 0] * 0.5 / np.pi

    ####################################################
    ## Plot extracted frequencies in spectrum
    plt.figure()

    freq = np.fft.fftfreq(len(t), dt)