# column_names=['2000-2020'] list_df = [df_1, df_2] list_df_out = [] for k in range(len(list_df)): df = list_df[k] list_dh = [] list_dh_err = [] list_dm = [] list_dm_err = [] df_out = pd.DataFrame() for period in periods: df_p = df[df.period == period] df_global = tt.aggregate_indep_regions_rates(df_p) df_global['reg'] = 'global' df_noperiph = tt.aggregate_indep_regions_rates( df_p[~df_p.reg.isin([5, 19])]) df_noperiph['reg'] = 'global_noperiph' df_full_p = pd.concat([df_p, df_noperiph, df_global]) column_dh = [] column_err_dh = [] for i in range(len(df_full_p)): dh = '{:.2f}'.format(df_full_p.dhdt.values[i]) err_dh = '{:.2f}'.format(2 * df_full_p.err_dhdt.values[i]) column_dh.append(dh) column_err_dh.append(err_dh)
list_df = [] for fn_reg in list_fn_reg: for period in periods: df_tmp = tt.aggregate_all_to_period(pd.read_csv(fn_reg), [tlims[periods.index(period)]], fn_tarea=fn_tarea, frac_area=1) list_df.append(df_tmp) df = pd.concat(list_df) list_df_all = [] for period in periods: df_p = df[df.period == period] df_global = tt.aggregate_indep_regions_rates(df_p) df_global['reg'] = 'global' df_global['period'] = period df_noperiph = tt.aggregate_indep_regions_rates( df_p[~df_p.reg.isin([5, 19])]) df_noperiph['reg'] = 'global_noperiph' df_noperiph['period'] = period df_full_p = pd.concat([df_p, df_noperiph, df_global]) list_df_all.append(df_full_p) df_all = pd.concat(list_df_all) df_g = df_all[df_all.reg == 'global'] df_np = df_all[df_all.reg == 'global_noperiph']
l.get_frame().set_linewidth(0.5) reg_dir = '/home/atom/ongoing/work_worldwide/vol/final' list_fn_reg_multann = [os.path.join(reg_dir,'dh_'+str(i).zfill(2)+'_rgi60_int_base_reg_subperiods.csv') for i in np.arange(1,20)] df_all = pd.DataFrame() for fn_reg_multann in list_fn_reg_multann: df_all= df_all.append(pd.read_csv(fn_reg_multann)) tlims = [np.datetime64('20'+str(i).zfill(2)+'-01-01') for i in range(21)] list_df_glob = [] list_df_per = [] for i in range(len(tlims)-1): period = str(tlims[i])+'_'+str(tlims[i+1]) df_p = df_all[df_all.period==period] df_global = tt.aggregate_indep_regions_rates(df_p) df_global['period']=period df_noperiph = tt.aggregate_indep_regions_rates(df_p[~df_p.reg.isin([5, 19])]) df_noperiph['period']=period list_df_glob.append(df_global) list_df_per.append(df_noperiph) df_glob = pd.concat(list_df_glob) df_per = pd.concat(list_df_per) df_g = df[df.tag=='gard'] df_g_glo = tt.aggregate_indep_regions_rates(df_g) df_g_per = tt.aggregate_indep_regions_rates(df_g[~df_g.reg.isin([5, 19])]) df_z = df[df.tag=='zemp']
df_reg = pd.read_csv(fn_reg) df_srocc = aggregate_all_to_period(df_reg, [tlim_srocc], fn_tarea=fn_tarea, frac_area=1) df_srocc['comp'] = 'srocc' df_full = aggregate_all_to_period(df_reg, [tlim_full], fn_tarea=fn_tarea, frac_area=1) df_full['comp'] = 'full' df_tmp = pd.concat([df_srocc, df_full]) list_df.append(df_tmp) df = pd.concat(list_df) df_s = df[df.comp == 'srocc'] df_global_srocc = aggregate_indep_regions_rates(df_s) df_global_srocc['reg'] = 22 df_noperiph_srocc = aggregate_indep_regions_rates( df_s[~df_s.reg.isin([5, 19])]) df_noperiph_srocc['reg'] = 23 df_a_srocc = aggregate_indep_regions_rates(df_s[df_s.reg.isin( [1, 3, 4, 5, 6, 7, 8, 9])]) df_a_srocc['reg'] = 24 df_m_srocc = aggregate_indep_regions_rates(df_s[df_s.reg.isin( [1, 2, 6, 8, 10, 11, 12, 21, 16, 17, 18])]) df_m_srocc['reg'] = 25 df_srocc_total = pd.concat( [df_s, df_global_srocc, df_noperiph_srocc, df_a_srocc, df_m_srocc]) df_srocc_total['comp'] = 'srocc' df_srocc_total.period = df[df.comp == 'srocc'].period.values[0]