# lgnth of G(t), usually 275999 but make higher so it doesnt fail topg = 276000 for col in ratios_sort[idx_rf05]: print(col) # ----- remove nans or else tts function fails utbl_full = np.array(ratios_sort[col].values, dtype=np.float64) utbl_not_null_idx = np.argwhere(~np.isnan(utbl_full)) # ----- inputs without nans my_utbl = utbl_full[utbl_not_null_idx] my_tau = tau[utbl_not_null_idx] # # ----- run tts function t, exp_decay_matrix, LT = tts_mod.prep_for_tts(my_tau) my_mustar, my_r2, my_gf, my_t, mean_age, mode_age, best_k = tts_mod.get_tts( my_utbl, my_tau, t, exp_decay_matrix, LT) # # ----- fill to make mu*, tau all length 52 diffa = len(utbl_full) - len(my_utbl) if (diffa > 0): filla = np.empty((1, diffa)) filla.fill(np.nan) my_tau = np.append(my_tau, filla) my_mustar = np.append(my_mustar, filla) my_utbl = np.append(my_utbl, filla) # ----- fill to make gf, t all length 275999 diffb = 275999 - len(my_gf) if (diffb > 0): fillb = np.empty((1, diffb)) fillb.fill(np.nan) my_gf = np.append(my_gf, fillb)
contrast_ratios = pd.read_pickle( "/UTLS/schelpon/TTS_2020/get_ratios/contrast_ratios.pkl") ratios_sort = contrast_ratios.sort_values(['BL_tau']) ratios_sort.head() # utbl, same for all utbl = ratios_sort['All RF'] ############################ GET TTS OUTPUTS FOR EA. CASE ############################ # --------------- ver 1: BL TAU tau_bl = ratios_sort['BL_tau'].values # get inputs t_bl, exp_decay_matrix_bl, LT_bl = tts_mod.prep_for_tts(tau_bl) # get tts my_mustar_bl, my_r2_bl, my_gf_bl, my_t_bl, mean_age_bl, mode_age_bl, best_k_bl = tts_mod.get_tts( utbl, tau_bl, t_bl, exp_decay_matrix_bl, LT_bl) # save campaign average for later use campaign_avg_figa = pd.DataFrame() campaign_avg_figa['tau'] = tau_bl campaign_avg_figa['utbl'] = utbl.values campaign_avg_figa['mustar'] = my_mustar_bl campaign_avg_figb = pd.DataFrame() campaign_avg_figb['t'] = t_bl / 86400 campaign_avg_figb['gf'] = my_gf_bl campaign_avg_stats = pd.DataFrame({ 'r squared': [my_r2_bl], 'mean age': [mean_age_bl], 'mode age': [mode_age_bl]
ratios_sort = contrast_ratios2.sort_values(['BL_tau']) ratios_sort.head() ############################ GET TTS OUTPUTS FOR EA. CASE ############################ # --------------- ver 1: UT = RF06, BL = IN SHEAR # need to drop any row with a nan value idx = ratios_sort['RF06_In Shear'].index[ratios_sort['RF06_In Shear'].apply( np.isnan)] ratios_sort_dirty = ratios_sort ratios_sort_dirty = ratios_sort_dirty.dropna() utbl_dirty = ratios_sort_dirty['RF06_In Shear'].values tau_dirty = ratios_sort_dirty['BL_tau'].values t_dirty, exp_decay_matrix_dirty, LT_dirty = tts_mod.prep_for_tts(tau_dirty) my_mustar_dirty, my_r2_dirty, my_gf_dirty, my_t_dirty, mean_age_dirty, mode_age_dirty, best_k_dirty = tts_mod.get_tts( utbl_dirty, tau_dirty, t_dirty, exp_decay_matrix_dirty, LT_dirty) # --------------- ver 1: UT = RF06, BL = IN SHEAR # need to drop any row with a nan value idx = ratios_sort['RF06_S of Shear'].index[ ratios_sort['RF06_S of Shear'].apply(np.isnan)] ratios_sort_clean = ratios_sort ratios_sort_clean = ratios_sort_clean.dropna() utbl_clean = ratios_sort_clean['RF06_S of Shear'].values tau_clean = ratios_sort_clean['BL_tau'].values t_clean, exp_decay_matrix_clean, LT_clean = tts_mod.prep_for_tts(tau_clean) my_mustar_clean, my_r2_clean, my_gf_clean, my_t_clean, mean_age_clean, mode_age_clean, best_k_clean = tts_mod.get_tts( utbl_clean, tau_clean, t_clean, exp_decay_matrix_clean, LT_clean)
path = "/UTLS/schelpon/TTS_2020/get_tts/tts_vary_bl/contrast_ratios_rf08.pkl" contrast_ratios = pd.read_pickle(path) ratios_sort = contrast_ratios.sort_values(['BL_tau']) ratios_sort.head() # tau, same for all tau = ratios_sort['BL_tau'].values # get gf inputs, same for all t, exp_decay_matrix, LT = tts_mod.prep_for_tts(tau) ############################ GET TTS OUTPUTS FOR EA. CASE ############################ # --------------- ver 1: UT = RF08, BL = CAMPAIGN AVG. utbl_cavg = ratios_sort['RF08_CampAvg'] # get tts my_mustar_cavg, my_r2_cavg, my_gf_cavg, my_t_cavg, mean_age_cavg, mode_age_cavg, best_k_cavg = tts_mod.get_tts( utbl_cavg, tau, t, exp_decay_matrix, LT) # In[12]: # --------------- ver 2: UT = RF08, BL = RF08 utbl_rf08 = ratios_sort['RF08_RF08'] # get tts my_mustar_rf08, my_r2_rf08, my_gf_rf08, my_t_rf08, mean_age_rf08, mode_age_rf08, best_k_rf08 = tts_mod.get_tts( utbl_rf08, tau, t, exp_decay_matrix, LT) # In[14]: # --------------- ver 3: UT = RF08, BL = RF06, 07, 08 (9 days prior) utbl_9days = ratios_sort['RF08_9days']