import matplotlib.pyplot as plt import numpy as np import os from processing_outputs import computing_confidence_intervals from data_utils import data_mean,bootstrapping_CI os.chdir('/home/vsansi01/ACC_R_values') variables = ("T2M", "U10", "V10","TP") print('-----> Choose Weeks Ahead ? 2, 3 or 4') week = int(input()) files_GraphFT_2019 = [f'ACC_GraphFT_t2m_week{week}_2019.npy',f'ACC_GraphFT_u10_week{week}_2019.npy',f'ACC_GraphFT_v10_week{week}_2019.npy',\ f'ACC_GraphFT_tp_week{week}_2019.npy'] files_GraphFT_2018_2019 = [f'ACC_GraphFT_t2m_week{week}_2018_2019.npy',f'ACC_GraphFT_u10_week{week}_2018_2019.npy',\ f'ACC_GraphFT_v10_week{week}_2018_2019.npy',f'ACC_GraphFT_tp_week{week}_2018_2019.npy'] files_GraphFT_2017_2018_2019 = [f'ACC_GraphFT_t2m_week{week}.npy',f'ACC_GraphFT_u10_week{week}.npy',f'ACC_GraphFT_v10_week{week}.npy',\ f'ACC_GraphFT_tp_week{week}.npy'] files_GraphOP = [f'ACC_GraphOP_t2m_week{week}.npy',f'ACC_GraphOP_u10_week{week}.npy',f'ACC_GraphOP_v10_week{week}.npy',\ f'ACC_GraphOP_tp_week{week}.npy'] acc_values = { 'GraphOP': data_mean(files_GraphOP), 'GraphFT-2019': data_mean(files_GraphFT_2019), 'GraphFT-2018-2019': data_mean(files_GraphFT_2018_2019), 'GraphFT-2017-2018-2019': data_mean(files_GraphFT_2017_2018_2019), } error_values = { 'GraphOP': bootstrapping_CI(files_GraphOP), 'GraphFT-2019': bootstrapping_CI(files_GraphFT_2019), 'GraphFT-2018-2019': bootstrapping_CI(files_GraphFT_2018_2019), 'GraphFT-2017-2018-2019': bootstrapping_CI(files_GraphFT_2017_2018_2019), } x = np.arange(len(variables)) # the label locations width = 0.2 # the width of the bars multiplier = 0 fig, ax = plt.subplots(layout='constrained') for (attribute, measurement),(atts,errors) in zip(acc_values.items(),error_values.items()): offset = width * multiplier rects = ax.bar(x + offset, measurement, width, label=attribute) #ax.bar_label(rects, padding=5) multiplier += 1 #yerr = np.array([computing_confidence_intervals(r,0.95) for r in measurement]) #yerr = np.swapaxes(yerr,0,1) plt.errorbar(x + offset,measurement, yerr=errors, ecolor='k',fmt = 'None', capsize=3, capthick=0.5) # Add some text for labels, title and custom x-axis tick labels, etc. ax.set_ylabel('ACC') ax.set_title('Variables') ax.set_xticks(x + width, variables) ax.legend(loc='upper right', ncols=1) ax.set_ylim(0, 0.45) plt.savefig('/home/vsansi01/Barplot_acc_3weeks_vs_training_years_bootstrapping.jpeg',dpi=300)