Пример #1
0
def square_envelope(correlation, g_speed, window_params):

    square_envelope = correlation.data**2 + \
        np.imag(hilbert(correlation.data))**2
    if window_params['plot']:
        plot_window(correlation, square_envelope, 'N/A')

    return square_envelope
Пример #2
0
def log_en_ratio(correlation, g_speed, window_params):
    delta = correlation.stats.delta
    window = get_window(correlation.stats, g_speed, window_params)
    win = window[0]
    if window[2]:
        E_plus = np.trapz((correlation.data * win)**2) * delta
        E_minus = np.trapz((correlation.data * win[::-1])**2) * delta
        msr = log(E_plus / (E_minus + np.finfo(E_minus).tiny))
        if window_params['plot']:
            plot_window(correlation, win, msr)
    else:
        msr = np.nan
    return msr
Пример #3
0
def log_en_ratio(correlation, g_speed, window_params):
    delta = correlation.stats.delta
    window = get_window(correlation.stats, g_speed, window_params)
    win = window[0]
    data = my_centered(correlation.data, correlation.stats.npts)

    if window[2]:
        #E_plus = np.trapz((correlation.data * win)**2) * delta
        #E_minus = np.trapz((correlation.data * win[::-1])**2) * delta
        sig_c = correlation.data * win
        sig_a = correlation.data * win[::-1]
        E_plus = np.trapz(np.power(sig_c, 2)) * delta
        E_minus = np.trapz(np.power(sig_a, 2)) * delta
        msr = log(E_plus / E_minus)  #+np.finfo(E_minus).tiny))
        if window_params['plot']:
            plot_window(correlation, win, msr)
    else:
        msr = np.nan
    return msr
Пример #4
0
def energy(correlation, g_speed, window_params):

    window = get_window(correlation.stats, g_speed, window_params)
    msr = [np.nan, np.nan]
    win = window[0]

    if window[2]:
        # causal
        E = np.trapz((correlation.data * win)**2)
        msr[0] = E
        if window_params['plot']:
            plot_window(correlation, win, E)

        # acausal
        win = win[::-1]
        E = np.trapz((correlation.data * win)**2)
        msr[1] = E
        if window_params['plot']:
            plot_window(correlation, win, E)

    return np.array(msr)
Пример #5
0
def inst_mf(corr_obs, corr_syn, g_speed, window_params):
    window = get_window(corr_obs.stats, g_speed, window_params)
    win = window[0]

    if window[2]:

        sig1 = corr_obs.data * (win + win[::-1])
        sig2 = corr_syn.data * (win + win[::-1])
        # phase misfit .. try instantaneous phase
        # hilbert gets the analytic signal (only the name is confusing)
        a1 = hilbert(sig1)
        a2 = hilbert(sig2)

        cc = a1 * np.conjugate(a2)

        boxc = np.clip((win + win[::-1]), 0, 1)
        dphase = 0.5 * np.trapz(np.angle(cc * boxc)**2)

        if window_params['plot']:
            plot_window(corr_obs, win, dphase)
    else:
        dphase = np.nan

    return dphase