-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegional_pdfs_ovl_metrics.py
More file actions
690 lines (414 loc) · 18.8 KB
/
Regional_pdfs_ovl_metrics.py
File metadata and controls
690 lines (414 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
##************** code to make regional pdf and plot overlapping metric
## author Mustapha Adamu::
## date: 13-07-2020
### Code for regional analysis of CMIP6 data
import xarray as xr
import numpy as np
import xarray as xr
import cartopy.crs as ccrs # This a library for making 2D spatial plots in python
import matplotlib
import matplotlib.pyplot as plt # Also for plotting in python
plt.switch_backend('agg')
import numpy as np
import xarray as xr
import pandas as pd
import matplotlib.pyplot as plt
from cartopy.util import add_cyclic_point
import numpy as np
import scipy
import scipy.signal
import scipy.stats as s
import glob
import sys
import os
from scipy.stats import genextreme as gev
from math import sqrt
from sklearn.metrics import mean_squared_error
import seaborn as sns
import regionmask
import matplotlib.patches as mpatches
## PATH FOR CMIP6 DATA
data_path1= "/g/data/w35/ma9839/PREC_CMIP6/For_evaluation/regrid/mask" # path for CMIP6 Historical dat
# data_path1= "/Volumes/G/RAWORK/Historical/regrid"
## This is a function to compute the overlap skill score of two arrays
bins = 12
def OVL_two_random_arr(arr1, arr2, number_bins):
''' arr1: input vector 1
arr2: input vector 2
bins: number of bins
usage example : OVL_two_random_arr( TOP10,BOT10, 100)
'''
# Determine the range over which the integration will occur
min_value = np.min((arr1.min(), arr2.min()))
max_value = np.min((arr1.max(), arr2.max()))
# Determine the bin width
bin_width = (max_value-min_value)/number_bins
#For each bin, find min frequency
lower_bound = min_value #Lower bound of the first bin is the min_value of both arrays
min_arr = np.empty(number_bins) #Array that will collect the min frequency in each bin
for b in range(number_bins):
higher_bound = lower_bound + bin_width #Set the higher bound for the bin
#Determine the share of samples in the interval
freq_arr1 = np.ma.masked_where((arr1<lower_bound)|(arr1>=higher_bound), arr1).count()/len(arr1)
freq_arr2 = np.ma.masked_where((arr2<lower_bound)|(arr2>=higher_bound), arr2).count()/len(arr2)
#Conserve the lower frequency
min_arr[b] = np.min((freq_arr1, freq_arr2))
lower_bound = higher_bound #To move to the next range
return min_arr.sum()
# extracting all REGEN data
# processing regen_data
regen_data = xr.open_dataset('/g/data/w35/ma9839/DATA_OBS/low_res_obs/reg_mon.nc').p
clim = regen_data.groupby('time.month').mean('time')
# *** calculating anomalies
regen_data = regen_data.groupby('time.month') - clim
## get arrays for lon and lat use for regridding models
lon = regen_data.lon
lat = regen_data.lat
## select African here from the global precipitation data
data_reg = regen_data
## create Regional mask
mask = regionmask.defined_regions.srex.mask(data_reg)
## select time slice here
data = data_reg.sel(time=data_reg.time.dt.month.isin([9,10,11]))
data_reg= data.sel(time=slice('1950-01', '2005-12'))
print(data_reg)
mean_obs = data_reg.mean(dim='time')
# Selection regions of Africa here::
## West Africa
WAF =data_reg.where(mask == regionmask.defined_regions.srex.map_keys('WAF')).mean(dim=['lon','lat'])
## North Africa
NAF = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('SAH')).mean(dim=['lon','lat'])
## East Africa
EAF = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('EAF')).mean(dim=['lon','lat'])
print(f'mean_EAF {np.nanmean(EAF)}')
## S Africa
SAF = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('SAF')).mean(dim=['lon','lat'])
print(f'mean_SAF_obs {np.nanmean(SAF)}')
# create empty arrays for storing models REGIONAL data
WAF_all = []
NAF_all = []
EAF_all = []
SAF_all = []
SAHEL_all = []
## create arrays for storing overlap metric
WAF_ovl = []
NAF_ovl = []
EAF_ovl = []
SAF_ovl = []
SAHEL_ovl = []
#
# ## create array for storing exceedance::
waf_all = []
saf_all = []
naf_all = []
eaf_all = []
sahel_all = []
JJA_models = np.zeros(regen_data.shape) * np.nan
models = sorted((os.listdir(data_path1))) # list all the data in the model
models_cmip6 = models
# #
# np.save('models_cmi6', models[1:])
# #
for m in range(len(models)): #**** loop through all models, amip and hist data must be have same names in different folders
# print(models)
if models[m].startswith('.'): # get rid of missing data\
continue
# print(models)
files = (glob.glob(data_path1 + "/" + models[m]))
print(files)
for data in files: # find files in folder
#** Grad model dataset
dset = xr.open_dataset(data).pr * 86400
clim = dset.groupby('time.month').mean('time')
# *** calculating anomalies
dset = dset.groupby('time.month') - clim
dset = dset.sel(time=dset.time.dt.month.isin([9,10,11]))
data_cmip = dset.sel(time=slice('1950-01', '2005-12'))
# mean_mods = data_cmip.mean(dim='time')
# JJA_models[m] = mean_mods
data_reg = data_cmip
mask = regionmask.defined_regions.srex.mask(data_reg)
## West Africa
WAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('WAF'))[:324].mean(dim=['lon','lat'])
WAF_all.append(np.array(WAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(WAF1, WAF, bins)
WAF_ovl.append(ovl)
## North Africa
NAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('SAH'))[:324].mean(dim=['lon','lat'])
NAF_all.append(np.array(NAF1))
ovl = OVL_two_random_arr(NAF1, NAF, bins)
NAF_ovl.append(ovl)
print(ovl)
## East Africa
EAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('EAF'))[:324].mean(dim=['lon','lat'])
EAF_all.append(np.array(EAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(EAF1, EAF, bins)
print(f'mean_EAF {np.nanmean(EAF1)}')
EAF_ovl.append(ovl)
## S Africamean(dim=['lon','lat'])
SAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('SAF'))[:324].mean(dim=['lon','lat'])
print(f'mean_SAF {np.nanmean(SAF1)}')
SAF_all.append(np.array(SAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(SAF1, SAF, bins)
SAF_ovl.append(ovl)
# del SAF_all[7]
# del WAF_all[7]
# del EAF_all[7]
# del NAF_all[7]
WAF_esm = [val for sublist in WAF_all for val in sublist]
NAF_esm = [val for sublist in NAF_all for val in sublist]
EAF_esm = [val for sublist in EAF_all for val in sublist]
SAF_esm = [val for sublist in SAF_all for val in sublist]
#---------------------------------------------------------------------------------------
### FOR CMIP5
data_path1= "/g/data/w35/ma9839/PRECIP_CMIP5/regrid/mask/"
WAF_all1 = []
NAF_all1 = []
EAF_all1 = []
SAF_all1 = []
WAF_ovl1 = []
NAF_ovl1 = []
EAF_ovl1 = []
SAF_ovl1 = []
models = sorted((os.listdir(data_path1))) # list all the data in the model
models_cmip5 = models
# #
# np.save('models_cmi6', models[1:])
# #
for m in range(len(models)): #**** loop through all models, amip and hist data must be have same names in different folders
# print(models)
if models[m].startswith('.'): # get rid of missing data\
continue
# print(models)
files = (glob.glob(data_path1 + "/" + models[m]))
print(files)
for data in files: # find files in folder
#** Grad model dataset
dset = xr.open_dataset(data).pr * 86400
clim = dset.groupby('time.month').mean('time') ### compute climatology
# *** calculating anomalies
dset = dset.groupby('time.month') - clim
dset = dset.sel(time=dset.time.dt.month.isin([9,10,11]))
data_cmip = dset.sel(time=slice('1950-01', '2005-12'))
## selecting regions for MODELS and apppend them to respective empty arrays::
## Change data_reg to match models i.e. Data_reg::
data_reg = data_cmip
mask = regionmask.defined_regions.srex.mask(data_reg)
## West Africa
WAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('WAF')).mean(dim=['lon','lat'])
WAF_all1.append(np.array(WAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(WAF1, WAF, bins)
WAF_ovl1.append(ovl)
## North Africa
NAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('SAH')).mean(dim=['lon','lat'])
NAF_all1.append(np.array(NAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(NAF1, NAF, bins)
NAF_ovl1.append(ovl)
print(ovl)
## East Africa
EAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('EAF')).mean(dim=['lon','lat'])
EAF_all1.append(np.array(EAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(EAF1, EAF, bins)
EAF_ovl1.append(ovl)
## S Africamean(dim=['lon','lat'])
SAF1 = data_reg.where(mask == regionmask.defined_regions.srex.map_keys('SAF')).mean(dim=['lon','lat'])
SAF_all1.append(np.array(SAF1))
## Compute overlap metric and append the results
ovl = OVL_two_random_arr(SAF1, SAF, bins)
SAF_ovl1.append(ovl)
WAF_esm1 = [val for sublist in WAF_all1 for val in sublist] ## flattern list of list ::::
NAF_esm1 = [val for sublist in NAF_all1 for val in sublist]
EAF_esm1 = [val for sublist in EAF_all1 for val in sublist]
SAF_esm1 = [val for sublist in SAF_all1 for val in sublist]
# west Africa
WAF_ovl_esm = np.mean(WAF_ovl,0)
## for cmip5
WAF_ovl_esm1 = np.mean(WAF_ovl1,0)
## North
NAF_ovl_esm = np.mean(NAF_ovl,0)
## for CMIP5
NAF_ovl_esm1 = np.mean(NAF_ovl1,0)
##SAF
SAF_ovl_esm = np.mean(SAF_ovl,0)
## For CMIP5
SAF_ovl_esm1= np.mean(SAF_ovl1,0)
##Eastt
EAF_ovl_esm = np.mean(EAF_ovl,0)
## for CMIP5
EAF_ovl_esm1 = np.mean(EAF_ovl1,0)
## strip model names of .nc
m_all = []
for i in range(len(models_cmip6)):
m = models_cmip6[i].strip('.nc')
m_all.append(m)
models= m_all
# print((models))
## creating dictionaries for ovls and model names::::
from collections import OrderedDict
WAF_cmip6 = dict(zip(np.array(models_cmip6), np.array(WAF_ovl)))
WAF_cmip5 = dict(zip(np.array(models_cmip5), np.array(WAF_ovl1)))
dall = {}
dall.update(WAF_cmip6)
dall.update(WAF_cmip5)
# >>> print(dictionary)
# OrderedDict(sorted(d.items(), key=lambda t: t[0]))
print('dict', dict(sorted(dall.items())))
## Save all ovls as numpy arrays:::
# np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/models_cmip6', models_cmip6)
# np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/models_cmip5', models_cmip5)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/WAF_ovl_son_cmip6', WAF_ovl)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/SAH_ovl_son_cmip6', NAF_ovl)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/EAF_ovl_son_cmip6', EAF_ovl)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/SAF_ovl_son_cmip6', SAF_ovl)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/WAF_ovl_son_cmip5', WAF_ovl1)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/SAH_ovl_son_cmip5', NAF_ovl1)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/EAF_ovl_son_cmip5', EAF_ovl1)
np.save('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Data/SAF_ovl_son_cmip5', SAF_ovl1)
fig, axes = plt.subplots(nrows=4,ncols=2, figsize=(10, 10),gridspec_kw={'wspace': 0.2, 'hspace': 0.3})
axes = axes.flatten()
import seaborn as sns
for i in range(len(WAF_all)):
sns.distplot(WAF_all[i], ax=axes[0],hist=False,kde=True,color='grey',kde_kws={'linewidth':1,'alpha':0.7})
sns.distplot(np.array(WAF), ax=axes[0],hist=False,kde=True,color='b',kde_kws={'linewidth':5,})
sns.distplot(WAF_esm, ax=axes[0],hist=False,color='k',kde_kws={'linewidth':5,'linestyle':'--'})
sns.distplot(WAF_esm1, ax=axes[0],hist=False,color='r',kde_kws={'linewidth':4.5,'linestyle':'-.','alpha':0.6},)
axes[0].set_ylabel('PDF', fontsize=11,weight='bold')
axes[0].tick_params(axis='both', which='major', labelsize=8)
axes[0].tick_params(axis = 'both', which = 'major', labelsize = 10)
axes[0].grid(linestyle='--')
for axis in ['top','bottom','left','right']:
axes[0].spines[axis].set_linewidth(2)
black_patch = mpatches.Patch(color='k', label='CMIP6-MMM')
blue_patch = mpatches.Patch(color='blue', label='REGEN')
grey_patch = mpatches.Patch(color='grey', label='CMIP6 MODELS')
red_patch = mpatches.Patch(color='red', label='CMIP5-MMM')
axes[0].legend(handles=[black_patch, blue_patch,grey_patch, red_patch], prop={'size': 6.5,'weight':'bold'})
for i in range(len(WAF_all)):
sns.distplot(NAF_all[i], ax=axes[2],color='grey',hist=False,kde_kws={'linewidth':1,'alpha':0.7})
sns.distplot(np.array(NAF), ax=axes[2],hist=False,color='b',kde_kws={'linewidth':5,})
sns.distplot(NAF_esm, ax=axes[2],hist=False,color='k',kde_kws={'linewidth':5,'linestyle':'--'})
sns.distplot(NAF_esm1, ax=axes[2],hist=False,color='r',kde_kws={'linewidth':5,'linestyle':'-.','alpha':0.8})
axes[2].set_ylabel('PDF', fontsize=11,weight='bold')
axes[2].tick_params(axis='both', which='major', labelsize=8)
axes[2].set_xlim(-0.05,0.05)
axes[2].grid(linestyle='--')
axes[2].tick_params(axis = 'both', which = 'major', labelsize = 10)
for axis in ['top','bottom','left','right']:
axes[2].spines[axis].set_linewidth(2)
for i in range(len(WAF_all)):
sns.distplot(EAF_all[i], ax=axes[4],color='grey',hist=False,kde_kws={'linewidth':1,'alpha':0.7})
sns.distplot(np.array(EAF), ax=axes[4],hist=False,color='b',kde_kws={'linewidth':5,})
sns.distplot(EAF_esm, ax=axes[4],hist=False,color='k',kde_kws={'linewidth':5,'linestyle':'--'})
sns.distplot(EAF_esm1, ax=axes[4],hist=False,color='r',kde_kws={'linewidth':5,'linestyle':'-.','alpha':0.8})
axes[4].set_ylabel('PDF', fontsize=11,weight='bold')
axes[4].tick_params(axis='both', which='major', labelsize=8)
axes[4].set_xlim(-2,2)
axes[4].grid(linestyle='--')
axes[4].tick_params(axis = 'both', which = 'major', labelsize = 10)
for axis in ['top','bottom','left','right']:
axes[4].spines[axis].set_linewidth(2)
for i in range(len(WAF_all)):
sns.distplot(SAF_all[i], ax=axes[6],color='grey',hist=False,kde_kws={'linewidth':1,'alpha':0.7})
sns.distplot(np.array(SAF), ax=axes[6],hist=False,color='b',kde_kws={'linewidth':5,})
sns.distplot(SAF_esm, ax=axes[6],hist=False,color='k',kde_kws={'linewidth':5,'linestyle':'--'})
sns.distplot(SAF_esm1, ax=axes[6],hist=False,color='r',kde_kws={'linewidth':5,'linestyle':'-.','alpha':0.8,})
axes[6].set_ylabel('PDF', fontsize=11,weight='bold')
axes[6].tick_params(axis='both', which='major', labelsize=8)
axes[6].grid(linestyle='--')
axes[6].set_xlabel('precipitation [mm/day]', fontsize=9,weight='bold')
axes[6].set_xlim(-1.5,1.5)
axes[6].tick_params(axis = 'both', which = 'major', labelsize = 10)
for axis in ['top','bottom','left','right']:
axes[6].spines[axis].set_linewidth(2)
y = np.arange(0,24,1)
w=0.5
y_ticks = [0,20,40,60,80,100]
print(len(models))
for i in range(len(WAF_ovl)):
axes[1].bar(y[i], WAF_ovl[i]*100, width=w, align='center')
axes[1].bar(22, WAF_ovl_esm*100, width=w, align='center',color='k')
axes[1].bar(23, WAF_ovl_esm1*100, width=w, align='center',color='r')
axes[1].tick_params(axis='both', which='major', labelsize=8)
axes[1].set_ylabel('%', fontsize=11,weight='bold', )
axes[1].set_xticks([])
axes[1].set_yticks(y_ticks)
axes[1].set_yticklabels(y_ticks)
axes[1].grid(linestyle='--')
axes[1].set_ylim(0,100)
axes[1].text(1.02, 0.5, "WAF",
rotation=90, size=12, weight='bold',
bbox=dict(edgecolor='lightgreen', facecolor='none', pad=7, linewidth=1.5),
ha='left', va='center', transform=axes[1].transAxes)
axes[1].tick_params(axis = 'both', which = 'major', labelsize = 10)
for axis in ['top','bottom','left','right']:
axes[1].spines[axis].set_linewidth(2)
for i in range(len(WAF_ovl)):
print(i)
axes[3].bar(y[i], NAF_ovl[i]*100, width=w, align='center')
print(i,NAF_ovl[i])
axes[3].bar(22, NAF_ovl_esm*100, width=w, align='center',color='k')
axes[3].bar(23, NAF_ovl_esm1*100, width=w, align='center',color='r')
axes[3].tick_params(axis='both', which='major', labelsize=8)
axes[3].set_ylabel('%', fontsize=11,weight='bold',)
axes[3].set_xticks([])
axes[3].grid(linestyle='--')
axes[3].set_yticks(y_ticks)
axes[3].set_yticklabels(y_ticks)
axes[3].set_ylim(0,100)
axes[3].text(1.02, 0.5, "SAH",
rotation=90, size=12, weight='bold',
bbox=dict(edgecolor='lightgreen', facecolor='none', pad=7, linewidth=1.5),
ha='left', va='center', transform=axes[3].transAxes)
axes[3].tick_params(axis = 'both', which = 'major', labelsize = 10)
for axis in ['top','bottom','left','right']:
axes[3].spines[axis].set_linewidth(2)
for i in range(len(WAF_ovl)):
axes[5].bar(y[i], EAF_ovl[i]*100, width=w, align='center')
axes[5].bar(22, EAF_ovl_esm*100, width=w, align='center',color='k')
axes[5].bar(23, EAF_ovl_esm1*100, width=w, align='center',color='r')
axes[5].tick_params(axis='both', which='major', labelsize=8)
axes[5].set_ylabel('%', fontsize=11,weight='bold')
axes[5].set_xticks([])
axes[5].set_ylim(0,100)
axes[5].set_yticks(y_ticks)
axes[5].set_yticklabels(y_ticks)
axes[5].grid(linestyle='--')
axes[5].tick_params(axis = 'both', which = 'major', labelsize = 10)
axes[5].text(1.02, 0.5, "EAF",
rotation=90, size=12, weight='bold',
bbox=dict(edgecolor='lightgreen', facecolor='none', pad=7, linewidth=1.5),
ha='left', va='center', transform=axes[5].transAxes)
for axis in ['top','bottom','left','right']:
axes[5].spines[axis].set_linewidth(2)
for i in range(len(WAF_ovl)):
axes[7].bar(y[i], SAF_ovl[i]*100, width=w, align='center')
axes[7].bar(22, SAF_ovl_esm*100, width=w, align='center',color='k')
axes[7].bar(23, SAF_ovl_esm1*100, width=w, align='center',color='r')
axes[7].tick_params(axis='both', which='major', labelsize=8)
axes[7].set_ylabel('%', fontsize=11,weight='bold')
axes[7].set_ylim(0,100)
axes[7].set_xticks(y)
axes[7].set_yticks(y_ticks)
axes[7].set_yticklabels(y_ticks)
axes[7].grid(axis='y',linestyle='--')
axes[7].text(1.02, 0.5, "SAF",
rotation=90, size=12, weight='bold',
bbox=dict(edgecolor='lightgreen', facecolor='none', pad=7, linewidth=1.5),
ha='left', va='center', transform=axes[7].transAxes)
# models = models_cmip6
models = list(models)
models.append('CMIP6_MMM')
models.append('CMIP5_MMM')
print(len(models), len(y))
print(models[23])
print(y[23])
axes[7].set_xticklabels(models, fontsize=10,weight='bold', rotation='vertical')
axes[7].tick_params(axis = 'both', which = 'major', labelsize = 10)
plt.subplots_adjust(bottom=0.18,right=0.975,)
# plt.savefig('/g/data/w35/ma9839/Africa_Project/Mustongo_project/Results/MAM_PDFS_OVL')