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 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:
phase = np.arctan2(np.imag(wave), np.real(wave)) # get phases from oscillatory modes if AMPLITUDE: 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 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: