示例#1
0
     # fitting oscillatory phase / amplitude to actual SAT
     reconstruction = amplitude * np.cos(phase_amp)
     fit_x = np.vstack([reconstruction, np.ones(reconstruction.shape[0])]).T
     m, c = np.linalg.lstsq(fit_x, sg_amp.surr_data)[0]
     amplitude = m * amplitude + c
 if AA:
     if AMPLITUDE:
         sg_amp.amplitude_adjust_surrogates(mean2, var2, trend2)
     else:
         sg.amplitude_adjust_surrogates(mean, var, trend)
 _, _, idx = g.get_data_of_precise_length('16k', start_cut, None, False)
 phase = phase[0, idx[0] : idx[1]]
 if AMPLITUDE:
     amplitude = amplitude[idx[0] : idx[1]]
 else:
     sg.surr_data = sg.surr_data[idx[0] : idx[1]]
 
 # subselect season
 if EVAL_SEASON:
     phase = phase[ndx_season]
     if AMPLITUDE:
         amplitude = amplitude[ndx_season]
     else:
         sg.surr_data = sg.surr_data[ndx_season]
 temp_means = np.zeros((8,))
 for i in range(cond_means.shape[0]):
     ndx = ((phase >= phase_bins[i]) & (phase <= phase_bins[i+1]))
     if AMPLITUDE:
         temp_means[i] = func(amplitude[ndx])
     else:
         temp_means[i] = func(sg.surr_data[ndx])
示例#2
0
        # fitting oscillatory phase / amplitude to actual SAT
        reconstruction = amplitude * np.cos(phase_amp)
        fit_x = np.vstack([reconstruction, np.ones(reconstruction.shape[0])]).T
        m, c = np.linalg.lstsq(fit_x, sg_amp.surr_data)[0]
        amplitude = m * amplitude + c
    if AA:
        if AMPLITUDE:
            sg_amp.amplitude_adjust_surrogates(mean2, var2, trend2)
        else:
            sg.amplitude_adjust_surrogates(mean, var, trend)
    _, _, idx = g.get_data_of_precise_length('16k', start_cut, None, False)
    phase = phase[0, idx[0]:idx[1]]
    if AMPLITUDE:
        amplitude = amplitude[idx[0]:idx[1]]
    else:
        sg.surr_data = sg.surr_data[idx[0]:idx[1]]

    # subselect season
    if EVAL_SEASON:
        phase = phase[ndx_season]
        if AMPLITUDE:
            amplitude = amplitude[ndx_season]
        else:
            sg.surr_data = sg.surr_data[ndx_season]
    temp_means = np.zeros((8, ))
    for i in range(cond_means.shape[0]):
        ndx = ((phase >= phase_bins[i]) & (phase <= phase_bins[i + 1]))
        if AMPLITUDE:
            temp_means[i] = func(amplitude[ndx])
        else:
            temp_means[i] = func(sg.surr_data[ndx])
示例#3
0
    wave, _, _, _ = wavelet_analysis.continous_wavelet(sg_amp.surr_data, 1, True, wavelet_analysis.morlet, dj = 0, s0 = s0_amp, j1 = 0, k0 = k0) # perform wavelet
    amplitude = np.sqrt(np.power(np.real(wave),2) + np.power(np.imag(wave),2))
    amplitude = amplitude[0, :]
    phase_amp = np.arctan2(np.imag(wave), np.real(wave))
    phase_amp = phase_amp[0, :]

    # fitting oscillatory phase / amplitude to actual SAT
    reconstruction = amplitude * np.cos(phase_amp)
    fit_x = np.vstack([reconstruction, np.ones(reconstruction.shape[0])]).T
    m, c = np.linalg.lstsq(fit_x, sg_amp.surr_data)[0]
    amplitude = m * amplitude + c

    _, _, idx = g.get_data_of_precise_length('16k', start_cut, None, False)
    phase = phase[0, idx[0] : idx[1]]
    amplitude = amplitude[idx[0] : idx[1]]
    sg.surr_data = sg.surr_data[idx[0] : idx[1]]

    for i in range(cond_means_surr.shape[1]):
        ndx = ((phase >= phase_bins[i]) & (phase <= phase_bins[i+1]))
        cond_means_surr[su, i, 1] = np.mean(amplitude[ndx])
        cond_means_surr[su, i, 0] = np.mean(sg.surr_data[ndx])

    if (su+1) % 10 == 0:
        print("%d. surrogate done..." % (su + 1))


fig = plt.figure(figsize = (10,8), frameon = False)
gs = gridspec.GridSpec(1, 2)
gs.update(left = 0.12, right = 0.95, top = 0.95, bottom = 0.1, wspace = 0.4, hspace = 0.4)

ax = plt.Subplot(fig, gs[0, 0])