-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathallplots.py
2948 lines (2257 loc) · 140 KB
/
allplots.py
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
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import cdms2 as cdms
import cdutil
import MV2 as MV
import numpy as np
import pylab as pl
import matplotlib as mpl
mpl.use('Agg')
import sys
import cartopy.crs as ccrs
import cartopy
import matplotlib.pyplot as plt
import os
import pandas as pd
import cdtime
import genutil
from matplotlib import ticker
from genutil import statistics
import scipy.stats
import PlotDefinedFunction as PDF
import copy
import cal_global_radiation_feedback_E3SM as GRF
import cal_RadKernel_E3SM as RK
import cal_CloudRadKernel_E3SM as CRK
import cal_LCF_E3SM as LCF
import cal_cloud_E3SM as CLOUD
import cal_webb_decomposition as WD
import cal_EIS as calEIS
import sort_cloud_regime as SCR
import sort_cloud_3regime as SCR3
import glob
import LonPivot as LP
#############################################################################################
def prepare_pd2html(outfig,varname,desc,casevscase=''):
print(casevscase)
pd_plot = pd.DataFrame([[varname,desc,casevscase,outfig]],columns=['Variables','Description','Case.VS.Case','Plot'])
pd_plot['Plot'] = pd_plot['Plot'].apply(lambda x: '<a href='+outfig+' target="_blanck">plot</a>')
return pd_plot
#############################################################################################
def make_dir(outdir):
if os.path.isdir(outdir):
print("----------"+outdir+' exists.-------------')
else:
os.mkdir(outdir)
print("----------Successfully created the directory %s " % outdir)
#############################################################################################
def get_cal_dics(direc_data, case_stamp, yearS2, yearE2, run_id1, run_id2, outdir_final,
RadKernel_dir, figdir, exp1, exp2,
CloudRadKernel_dir):
dics_cal = {}
print(direc_data, case_stamp, yearS2, yearE2, run_id1, run_id2, outdir_final)
my_cal = calculation(direc_data, case_stamp, yearS2, yearE2, run_id1, run_id2, outdir_final,
RadKernel_dir, figdir, exp1, exp2,
CloudRadKernel_dir)
dics_cal['RadFeedback'] = my_cal.cal_Global_RadFeedback
dics_cal['RadKernel'] = my_cal.cal_RadKernel
dics_cal['Webb_Decomp'] = my_cal.cal_webb_decomp
dics_cal['CloudRadKernel'] = my_cal.cal_CloudRadKernel
dics_cal['cal_LCF'] = my_cal.cal_LCF
dics_cal['cal_cloud'] = my_cal.cal_cloud
dics_cal['cal_EIS'] = my_cal.cal_EIS
dics_cal['sort_cloud_regime'] = my_cal.sort_cloud_regime
dics_cal['sort_cloud_3regime'] = my_cal.sort_cloud_3regime
return dics_cal
class calculation:
def __init__(self,direc_data, case_stamp, yearS2, yearE2, run_id1, run_id2, outdir_final,
RadKernel_dir, figdir, exp1, exp2,
CloudRadKernel_dir ):
self.direc_data = direc_data
self.case_stamp = case_stamp
self.yearS2 = yearS2
self.yearE2 = yearE2
self.run_id1 = run_id1
self.run_id2 = run_id2
self.outdir_final = outdir_final
self.RadKernel_dir = RadKernel_dir
self.figdir = figdir
self.exp1 = exp1
self.exp2 = exp2
self.CloudRadKernel_dir = CloudRadKernel_dir
def cal_Global_RadFeedback(self):
result = GRF.Global_RadFeedback(self.direc_data, self.case_stamp, self.yearS2, self.yearE2, self.run_id1, self.run_id2, self.outdir_final,self.exp1,self.exp2)
def cal_RadKernel(self):
result = RK.RadKernel(self.RadKernel_dir,self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir,self.exp1,self.exp2)
def cal_webb_decomp(self):
result = WD.cal_webb_decomp(self.outdir_final,self.case_stamp,self.yearS2,self.yearE2,self.outdir_final,self.figdir)
def cal_CloudRadKernel(self):
result = CRK.CloudRadKernel(self.CloudRadKernel_dir,self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir)
def cal_LCF(self):
result = LCF.cal_LCF(self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir)
def cal_cloud(self):
result = CLOUD.cal_cloud(self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir,self.exp1,self.exp2)
def cal_EIS(self):
result = calEIS.cal_EIS(self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir,self.exp1,self.exp2)
def sort_cloud_regime(self):
result = SCR.sort_cloud_regime(self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir,self.exp1,self.exp2)
def sort_cloud_3regime(self):
result = SCR3.sort_cloud_3regime(self.direc_data,self.case_stamp,self.yearS2,self.yearE2,self.run_id1,self.run_id2,self.outdir_final,self.figdir,self.exp1,self.exp2)
#############################################################################################
def get_plot_dics(cases,ref_casesA,Add_otherCMIPs,datadir_v2, datadir_v1, s1, s2, fh, fh1, a1, colors, figdir,ncase, linestyles, linewidths,Add_amipFutue,highlight_CESM2,lw_CESM2,ls_CESM2,lc_CESM2, datadir_Ringer, datadir_RadKernel, datadir_CldRadKernel):
'''
Aug 20, 201: get the plot dictionary for all plot types.
'''
dics_plots = {}
my_plot = plots(cases,ref_casesA,Add_otherCMIPs,datadir_v2, datadir_v1, s1, s2, fh, fh1, a1, colors, figdir,ncase, linestyles, linewidths,Add_amipFutue,highlight_CESM2,lw_CESM2,ls_CESM2,lc_CESM2, datadir_Ringer, datadir_RadKernel, datadir_CldRadKernel)
dics_plots['CRE_globalmean'] = my_plot.plot_CRE_globalmean
dics_plots['RadKernel_globalmean'] = my_plot.plot_RadKernel_globalmean
dics_plots['CldRadKernel_globalmean'] = my_plot.plot_CldRadKernel_globalmean
dics_plots['RadKernel_zonalmean'] = my_plot.plot_RadKernel_zonalmean
dics_plots['CldRadKernel_zonalmean'] = my_plot.plot_CldRadKernel_zonalmean
dics_plots['RadKernel_latlon'] = my_plot.plot_RadKernel_latlon
dics_plots['CldRadKernel_latlon'] = my_plot.plot_CldRadKernel_latlon
dics_plots['RadKernel_latlon_dif'] = my_plot.plot_RadKernel_latlon_dif
dics_plots['CldRadKernel_latlon_dif'] = my_plot.plot_CldRadKernel_latlon_dif
dics_plots['tas_latlon'] = my_plot.plot_tas_latlon
dics_plots['LCF'] = my_plot.plot_LCF
dics_plots['zm_CLOUD'] = my_plot.plot_zm_CLOUD
dics_plots['latlon_CLOUD'] = my_plot.plot_latlon_CLOUD
dics_plots['webb_decomp'] = my_plot.plot_webb_decomp
dics_plots['CLOUD_profile'] = my_plot.plot_CLOUD_profile
dics_plots['NRMSE_RadKern'] = my_plot.plot_NRMSE_RadKern
dics_plots['cal_regionCor'] = my_plot.cal_RadKernel_regional_correspondence
return dics_plots
class plots:
def __init__(self, cases,ref_casesA,Add_otherCMIPs,datadir_v2, datadir_v1, s1, s2, fh, fh1, a1, colors,figdir,ncase, linestyles, linewidths,Add_amipFuture,highlight_CESM2,lw_CESM2,ls_CESM2,lc_CESM2, datadir_Ringer, datadir_RadKernel, datadir_CldRadKernel):
self.cases = cases
self.ref_casesA = ref_casesA
self.Add_otherCMIPs = Add_otherCMIPs
self.datadir_v2 = datadir_v2
self.datadir_v1 = datadir_v1
self.s1 = s1
self.s2 = s2
self.fh = fh
self.fh1 = fh1
self.a1 = a1
self.colors = colors
self.figdir = figdir
self.ncase = ncase
self.linestyles = linestyles
self.linewidths = linewidths
self.Add_amipFuture = Add_amipFuture
self.highlight_CESM2 = highlight_CESM2
self.lw_CESM2 = lw_CESM2
self.ls_CESM2 = ls_CESM2
self.lc_CESM2 = lc_CESM2
self.datadir_Ringer = datadir_Ringer
self.datadir_RadKernel = datadir_RadKernel
self.datadir_CldRadKernel = datadir_CldRadKernel
####################################################################################
### bar plot for global mean CRE feedback: including E3SMv1 piControl and amip
####################################################################################
def plot_CRE_globalmean(self):
print('ScatterPlot-CRE-feedback starts ........')
cases_here = copy.deepcopy(self.cases)
if 'amip-4xCO2' in self.cases:
cases_here.remove('amip-4xCO2')
df_all = pd.DataFrame()
if self.Add_otherCMIPs:
# read other CMIP5 and CMIP6 models
# Oct 19, 2020: reduce model lists to fit both amip-p4K and amipFuture
exp_cntl = [['piControl','amip'],['piControl','amip']]
exp_new = [['abrupt4xCO2','amip4K'],['abrupt-4xCO2','amip-p4K']]
prefix = 'global_mean_features'
suffix1 = '*.csv'
suffix2 = '*.csv'
models_all,cmip5_models,cmip6_models = PDF.get_intersect_withripf(exp_cntl,exp_new,prefix,suffix1,suffix2,self.datadir_Ringer)
exp_cntl = [['piControl','amip'],['piControl','amip']]
exp_new = [['abrupt4xCO2','amipFuture'],['abrupt-4xCO2','amip-future4K']]
models_all_future,cmip5_models_future,cmip6_models_future = PDF.get_intersect_withripf(exp_cntl,exp_new,prefix,suffix1,suffix2,self.datadir_Ringer)
#print('models_all',models_all,len(models_all))
#print('cmip5_models', cmip5_models,len(cmip5_models))
#print('cmip6_models', cmip6_models,len(cmip6_models))
#print('models_all_future',models_all_future,len(models_all_future))
#print('cmip5_models_future', cmip5_models_future,len(cmip5_models_future))
#print('cmip6_models_future', cmip6_models_future,len(cmip6_models_future))
# ---- amip4K ---------------------
df_p4K = pd.DataFrame()
for model in models_all:
if model in cmip5_models:
if model == 'CanESM2_r1i1p1':
model_amip = 'CanAM4_r1i1p1'
elif model == 'HadGEM2-ES_r1i1p1':
model_amip = 'HadGEM2-A_r1i1p1'
else:
model_amip = model
filename = self.datadir_Ringer+'global_mean_features_CMIP5_amip4K_'+model_amip+'.csv'
else:
filename = self.datadir_Ringer+'global_mean_features_CMIP6_amip-p4K_'+model+'.csv'
df = pd.read_csv(filename,index_col=0)
df.index = df.loc[:,'varname']
df2 = df.loc[:,'anomaly_perK']
df_p4K[model] = df2
# ---- amipFuture ---------------------
df_future = pd.DataFrame()
for model in models_all_future:
if model in cmip5_models_future:
if model == 'CanESM2_r1i1p1':
model_amip = 'CanAM4_r1i1p1'
elif model == 'HadGEM2-ES_r1i1p1':
model_amip = 'HadGEM2-A_r1i1p1'
else:
model_amip = model
filename = self.datadir_Ringer+'global_mean_features_CMIP5_amipFuture_'+model_amip+'.csv'
else:
filename = self.datadir_Ringer+'global_mean_features_CMIP6_amip-future4K_'+model+'.csv'
df = pd.read_csv(filename,index_col=0)
df.index = df.loc[:,'varname']
df2 = df.loc[:,'anomaly_perK']
df_future[model] = df2
# read amip
for icase,case in enumerate(cases_here):
if case == 'v1_coupled':
# read v1-coupled
df_coupled = pd.read_csv(self.datadir_v1+'global_mean_features_CMIP6_abrupt-4xCO2_E3SM-1-0_r1i1p1f1.csv',index_col=0)
df_coupled.index = df_coupled.loc[:,'varname']
df_all['v1_coupled'] = df_coupled.loc[:,'anomaly_perK']
elif case == 'v1_amip4K':
# read v1-amip
df_amip = pd.read_csv(self.datadir_v1+'global_mean_features_CMIP6_amip-p4K_E3SM-1-0_r2i1p1f1.csv',index_col=0)
df_amip.index = df_amip.loc[:,'varname']
df_all['v1_amip4K'] = df_amip.loc[:,'anomaly_perK']
elif case == 'v1_future4K':
# read v1-amip
df_amip = pd.read_csv(self.datadir_v1+'global_mean_features_CMIP6_amip-future4K_E3SM-1-0_r2i1p1f1.csv',index_col=0)
df_amip.index = df_amip.loc[:,'varname']
df_all['v1_future4K'] = df_amip.loc[:,'anomaly_perK']
elif case == 'amip-4xCO2':
continue
else:
df1 = pd.read_csv(self.datadir_v2+'global_mean_features_'+case+'.csv',index_col=0)
df1.index = df1.loc[:,'varname']
df2 = df1.loc[:,'anomaly_perK']
df_all[case] = df2
# start plotting
fig = plt.figure(figsize=(18,12))
ax = fig.add_subplot(1,1,1)
if 'ts' in df_all.index:
drop_index = ['ts','SWCLR','LWCLR']
else:
drop_index = ['tas','SWCLR','LWCLR']
df_plot = df_all.drop(index=drop_index)
if self.Add_otherCMIPs:
df_p4K_plot = df_p4K.drop(index=drop_index)
df_future_plot = df_future.drop(index=drop_index)
x = np.arange(1,len(df_plot.index)+1,1)
for idx,index in enumerate(df_plot.index):
for icol,column in enumerate(df_plot.columns):
if column == 'v1_coupled' or column == 'v2_coupled':
L1 = ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=column,color=self.colors[icol],marker='x')
elif column == 'v1_amip4K':
ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=column,color=self.colors[icol],marker='x')
elif column == 'v1_future4K':
ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=column,color=self.colors[icol],marker='x')
else:
ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=column,color=self.colors[icol])
if self.Add_otherCMIPs:
# add other CMIP models
for icol,column in enumerate(df_p4K_plot.columns):
if self.highlight_CESM2 and 'CESM2' in column:
ax.scatter(x[idx]-0.2,df_p4K_plot.loc[index,column].tolist(),edgecolor='none',facecolor=self.lc_CESM2,alpha=1.0,s=self.s2,marker='x',\
label=column.split('_')[0]+'_amip-p4K')
else:
ax.scatter(x[idx]-0.2,df_p4K_plot.loc[index,column].tolist(),edgecolor='none',facecolor='grey',alpha=self.a1,s=self.s2)
# ensemble mean
L2 = ax.scatter(x[idx]-0.2,df_p4K_plot.loc[index,:].mean().tolist(),color='black',s=self.s2)
if self.Add_amipFuture:
for icol,column in enumerate(df_future_plot.columns):
if self.highlight_CESM2 and 'CESM2' in column:
ax.scatter(x[idx]+0.2,df_future_plot.loc[index,column].tolist(),edgecolor='none',facecolor=self.lc_CESM2,alpha=1.0,s=self.s2,marker='x',\
label=column.split('_')[0]+'_amip-future4K')
else:
ax.scatter(x[idx]+0.2,df_future_plot.loc[index,column].tolist(),edgecolor='none',facecolor='grey',alpha=self.a1,s=self.s2)
# ensemble mean
L3 = ax.scatter(x[idx]+0.2,df_future_plot.loc[index,:].mean().tolist(),color='red',s=self.s2)
ax.tick_params(labelsize=self.fh)
ax.set_ylabel('W/m$^2$/K',fontsize=self.fh)
if idx==0:
if self.Add_amipFuture:
if Add_otherCMIPs:
legend1 = ax.legend([L2,L3],['amip4K','amipFuture'],fontsize=self.fh1,loc='upper left')
ax.legend(fontsize=self.fh1)
ax.add_artist(legend1)
else:
ax.legend(fontsize=self.fh1)
else:
if self.Add_otherCMIPs:
legend1 = ax.legend([L2],['amip4K'],fontsize=self.fh1,loc='upper left')
ax.legend(fontsize=self.fh1)
ax.add_artist(legend1)
else:
ax.legend(fontsize=self.fh1)
plt.xticks(x,df_plot.index)
ax.set_title('Radiative Feedback',fontsize=self.fh)
ax.set_ylim(-2.5,2.5)
ax.grid(which='major', linestyle=':', linewidth='1.0', color='grey')
fig.savefig(self.figdir+'ScatterPlot-CRE-feedback_'+self.cases[-1]+'.png',bbox_inches='tight',dpi=300)
plt.close(fig)
#<2021-12-21
pd_plot = prepare_pd2html('../figure/ScatterPlot-CRE-feedback_'+self.cases[-1]+'.png',
'Radiative feedback [W/m2/K]',
'TOA radiative feedbacks [SWCRE, LWCRE, netCRE, clear-sky SW, clear-sky LW, net TOA, net TOA SW, net TOA LW, clear-sky net TOA, clear-sky net TOA SW, clear-sky net TOA LW]',
'')
#>2021-12-21
del(df_all,df_plot)
print('------------------------------------------------')
print('ScatterPlot-CRE-feedback is done!')
print('------------------------------------------------')
return pd_plot
####################################################################
### bar plot for radiative feedback based on Radiative kernel
####################################################################
def plot_RadKernel_globalmean(self):
print('ScatterPlot-RadKernel-Feedback starts........')
cases_here = copy.deepcopy(self.cases)
if 'amip-4xCO2' in self.cases:
cases_here.remove('amip-4xCO2')
df_all = pd.DataFrame()
# read other CMIP5&6 models
if self.Add_otherCMIPs:
# if only add those models with both amip and cmip runs, set do_amip_cmip = True
do_amip_cmip = False
phases = ['CMIP5','CMIP6']
if do_amip_cmip:
exp_cntl = [['piControl','amip'],['piControl','amip']]
exp_new = [['abrupt4xCO2','amip4K'],['abrupt-4xCO2','amip-p4K']]
suffix1 = '*_1yr-150yr.csv'
suffix2 = '*.csv'
else:
exp_cntl = [['piControl','piControl'],['piControl','piControl']]
exp_new = [['abrupt4xCO2','abrupt4xCO2'],['abrupt-4xCO2','abrupt-4xCO2']]
suffix1 = '*_1yr-150yr.csv'
suffix2 = '*_1yr-150yr.csv'
prefix = 'FDBK'
models_all,cmip5_models,cmip6_models = PDF.get_intersect(exp_cntl,exp_new,prefix,suffix1,suffix2,self.datadir_RadKernel+'/20220208/')
#print('models_all',models_all,len(models_all))
#print('cmip5_models',cmip5_models,len(cmip5_models))
#print('cmip6_models',cmip6_models,len(cmip6_models))
models = [cmip5_models, cmip6_models]
df_others = pd.DataFrame()
for iphase,phase in enumerate(phases):
if phase == 'CMIP5':
suffix = '_Latest-Oct18_1yr-27yr'
else:
suffix = '_Latest-Oct18_1yr-36yr'
for imodel,model in enumerate(models[iphase]):
if do_amip_cmip:
if model == 'CanESM2':
model_amip = 'CanAM4'
elif model == 'HadGEM2-ES':
model_amip = 'HadGEM2-A'
else:
model_amip = model
df = pd.read_csv(self.datadir_RadKernel+'FDBK_'+phase+'_'+exp_new[iphase][1]+'_'+model_amip+suffix+'.csv',index_col=0)
else:
ff = glob.glob(self.datadir_RadKernel+'/20220208/FDBK_'+phase+'_'+exp_new[iphase][1]+'_'+model+'_*_1yr-150yr.csv')
if len(ff) == 0:
print('We dont find data for ',model,'please check!!!')
else:
print(ff)
df = pd.read_csv(ff[0],index_col=0)
df2 = df.iloc[:,0]
df_others[model] = df2
# E3SM
for icase,case in enumerate(cases_here):
if case == 'v1_coupled':
# read v1-coupled
df_coupled = pd.read_csv(self.datadir_v1+'FDBK_CMIP6_abrupt-4xCO2_E3SM-1-0_r1i1p1f1_1yr-150yr.csv',index_col=0)
df_all['v1_coupled'] = df_coupled.iloc[:,0]
elif case == 'v1_amip4K':
# read v1-amip
df_amip = pd.read_csv(self.datadir_v1+'FDBK_CMIP6_amip-p4K_E3SM-1-0_r2i1p1f1_1yr-36yr.csv',index_col=0)
df_all['v1_amip4K'] = df_amip.iloc[:,0]
elif case == 'v1_future4K':
# read v1-amip
df_amip = pd.read_csv(self.datadir_v1+'FDBK_CMIP6_amip-future4K_E3SM-1-0_r2i1p1f1_1yr-36yr.csv',index_col=0)
df_all['v1_future4K'] = df_amip.iloc[:,0]
elif case == 'amip-4xCO2':
continue
else:
df1 = pd.read_csv(self.datadir_v2+'FDBK_CMIP6_'+case+'.csv',index_col=0)
if 'a4SST' in case or 'amip-p4K-CESM2' in case:
MODEL = 'CESM2'
else:
MODEL = 'E3SM-1-0'
df2 = df1.loc[:,MODEL]
df_all[case] = df2
# start plotting
fig = plt.figure(figsize=(18,9))
ax = fig.add_subplot(1,1,1)
drop_index = ['T','dLW_adj','dSW_adj','dnet_adj','LW_resd','SW_resd',\
#'net_resd',\
'T_clr','Planck_clr','LR_clr','WV_clr','ALB_clr','WV_clr_SW','WV_clr_LW','WV_SW','WV_LW',\
'SWCRE','LWCRE','netCRE','Planck_clr_fxRH','LR_clr_fxRH','RH_clr','LW_clr_sum','SW_clr_sum',\
'net_clr_sum','LW_clr_dir','SW_clr_dir','net_clr_dir','LW_cld_sum','SW_cld_sum',\
#,'net_cld_sum',\
'LW_cld_dir','SW_cld_dir','net_cld_dir','LW_clr_resd','SW_clr_resd','net_clr_resd']
df_plot = df_all.drop(index=drop_index)
x = np.arange(1,len(df_plot.index)+1,1)
print(df_plot.index)
# redefine column orders
indexA = ['Planck','LR','WV','ALB','netCRE_adj','SWCRE_adj','LWCRE_adj','net_cld_sum','net_resd','Planck_fxRH','LR_fxRH','RH']
xticks = ['Planck','LR','WV','Albedo','Cloud','Cloud$_{sw}$','Cloud$_{lw}$','Total','Residual','Planck\n[fixed RH]','LR\n[fixed RH]','RH']
# output the dataframe df_plot as a table
df_plot_flip = df_plot.transpose()
df_plot_flip = df_plot_flip.reindex(columns=indexA)
df_plot_flip.columns = xticks
df_plot_flip.index = [item.split('.')[-1] for item in df_plot_flip.index]
print(df_plot_flip.round(2))
df_plot_flip_out = df_plot_flip.round(2)
df_out = df_plot_flip_out.applymap("{:.2f}".format)
print(df_out)
df_out.to_csv(self.datadir_v2+'climate_feedback_table_'+cases_here[-1]+'.csv')
if self.Add_otherCMIPs:
df_others_plot = df_others.drop(index=drop_index)
for idx,index in enumerate(indexA):
for icol,column in enumerate(df_plot.columns):
if column == 'v1_coupled' or column == 'v2_coupled':
label = column.split('_')[0]+" [abrupt4xCO2]"
if 'v2.NARRM.coupled' in df_plot.columns and column == 'v2_coupled':
label = 'v2.LR'
L1 = ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=label,color=self.colors[icol],marker='x')
elif column == 'v1_amip4K':
ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=column,color=self.colors[icol],marker='x')
elif column == 'v1_future4K':
ax.scatter(x[idx],df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=column,color=self.colors[icol],marker='x')
else:
if 'gwenergy' in column:
label = 'All'
elif column == 'v2.NARRM.coupled':
label = 'v2.NARRM'
else:
label = column.split('.')[-1]
ax.scatter(x[idx]+icol/20.-len(df_plot.columns)/2.*1/20.,df_plot.loc[index,column].tolist(),s=self.s1,alpha=self.a1,label=label,color=self.colors[icol],edgecolor='grey')
# other CMIP models
if self.Add_otherCMIPs:
for icol,column in enumerate(df_others_plot.columns):
if self.highlight_CESM2 and 'CESM2' in column:
ax.scatter(x[idx], df_others_plot.loc[index,column].tolist(),s=self.s2,edgecolor='none',facecolor=self.lc_CESM2,alpha=1, marker='X',\
label = column.split('_')[0]+'_amip-p4K')
else:
ax.scatter(x[idx]-0.2, df_others_plot.loc[index,column].tolist(),s=self.s2,edgecolor='none',facecolor='grey',alpha=0.3,marker='x')
# ensemble mean
L2 = ax.scatter(x[idx]-0.2, df_others_plot.loc[index,:].mean(),s=self.s2,edgecolor='black',facecolor='black',marker='X')
ax.tick_params(labelsize=self.fh)
ax.set_ylabel('Feedback [W/m$^2$/K]',fontsize=self.fh)
if idx == 0:
if self.Add_otherCMIPs:
if do_amip_cmip:
label = 'amip4K'
else:
label = 'abrupt4xCO2'
legend1 = ax.legend([L2],[label],fontsize=self.fh1,loc='upper left')
ax.legend(fontsize=self.fh1)
ax.add_artist(legend1)
else:
ax.legend(fontsize=self.fh1)
#ax.grid(which='major', linestyle=':', linewidth='1.0', color='grey')
ax.axhline(y=0,ls='-',color='black',lw=1)
degrees = 0
plt.xticks(x,xticks,rotation=degrees)
ax.set_title('Global Mean Feedbacks',fontsize=self.fh)
# Add reference line between Cloud and Cloud_sw
ax.axvline(x=5.5,ls='--',color='grey')
# between Cloud_lw and Total
ax.axvline(x=7.5,ls='--',color='grey')
# between Total and Residual
ax.axvline(x=8.5,ls='--',color='grey')
# between Residual and Planck_fxRH
ax.axvline(x=9.5,ls='--',color='grey')
fig.savefig(self.figdir+'ScatterPlot-RadKernel-Feedback_'+self.cases[-1]+'.png',bbox_inches='tight',dpi=300)
plt.close(fig)
#<2021-12-22
pd_plot = prepare_pd2html('../figure/ScatterPlot-RadKernel-Feedback_'+self.cases[-1]+'.png',
'CRE [W/m2/K]',
'Adjusted CRE feedbacks derived from radiative kernel method (SW, LW, NET)',
'')
#>2021-12-22
print('------------------------------------------------')
print('ScatterPlot-RadKernel-Feedback is done!')
print('------------------------------------------------')
return pd_plot
#########################################################################
### zonal mean plot of radiative feedback based on radiative kernel
#########################################################################
def plot_RadKernel_zonalmean(self):
print('plot_RadKernel_zonalmean starts ..........')
cases_here = copy.deepcopy(self.cases)
if 'amip-4xCO2' in self.cases:
cases_here.remove('amip-4xCO2')
variables = ['SWCRE_ano_grd_adj','LWCRE_ano_grd_adj','netCRE_ano_grd_adj']
variables_out = ['SW Cloud Feedback','LW Cloud Feedback','NET Cloud Feedback']
nlat = 73
nlon = 144
pd_plot_all = pd.DataFrame(columns=['Variables','Description','Case.VS.Case','Plot'])
# generate figure based on case categories
for ii in self.ncase:
fig = plt.figure(figsize=(18,9))
num1 = 0
# add other CMIP models
if self.Add_otherCMIPs:
phases = ['CMIP5','CMIP6']
exp_cntl = [['piControl','amip'],['piControl','amip']]
exp_new = [['abrupt4xCO2','amip4K'],['abrupt-4xCO2','amip-p4K']]
prefix = 'FDBK'
suffix1 = '*1yr-150yr.csv'
suffix2 = '*.csv'
models_all,cmip5_models,cmip6_models = PDF.get_intersect(exp_cntl,exp_new,prefix,suffix1,suffix2,self.datadir_RadKernel)
#print('models_all',models_all,len(models_all))
#print('cmip5_models',cmip5_models,len(cmip5_models))
#print('cmip6_models',cmip6_models,len(cmip6_models))
models = [cmip5_models, cmip6_models]
model_list = cmip5_models + cmip6_models
for ivar,svar in enumerate(variables):
# get other CMIP models
if self.Add_otherCMIPs:
data_others = np.zeros((nlat,len(model_list)))
for iphase,phase in enumerate(phases):
if phase == 'CMIP5':
suffix = '_Latest-Oct18_1yr-27yr'
else:
suffix = '_Latest-Oct18_1yr-36yr'
# define the array to save the overall data for cross-model correlation
data1 = np.zeros((nlat,len(models[iphase])))
for imodel,model in enumerate(models[iphase]):
if model == 'CanESM2':
model_amip = 'CanAM4'
elif model == 'HadGEM2-ES':
model_amip = 'HadGEM2-A'
else:
model_amip = model
f1 = cdms.open(self.datadir_RadKernel+'lat-lon-gfdbk-'+phase+'-'+exp_new[iphase][1]+'-'+model_amip+suffix+'.nc')
tmp1 = f1(svar)
lats = tmp1.getLatitude()[:]
data1[:,imodel] = MV.average(tmp1,axis=1)
if iphase == 0:
data_others[:,:len(cmip5_models)] = data1
else:
data_others[:,len(cmip5_models):] = data1
# E3SM
data_all = np.zeros((nlat,len(cases_here[:ii])))
for icase,case in enumerate(cases_here[:ii]):
if case == 'v1_coupled':
f1 = cdms.open(self.datadir_v1+'lat-lon-gfdbk-CMIP6-abrupt-4xCO2-E3SM-1-0_r1i1p1f1_1yr-150yr.nc')
elif case == 'v1_amip4K':
f1 = cdms.open(self.datadir_v1+'lat-lon-gfdbk-CMIP6-amip-p4K-E3SM-1-0_r2i1p1f1_1yr-36yr.nc')
elif case == 'v1_future4K':
f1 = cdms.open(self.datadir_v1+'lat-lon-gfdbk-CMIP6-amip-future4K-E3SM-1-0_r2i1p1f1_1yr-36yr.nc')
elif case == 'amip-4xCO2':
continue
else:
f1 = cdms.open(self.datadir_v2+'lat-lon-gfdbk-CMIP6-'+case+'.nc')
data = f1(svar)
lats = data.getLatitude()[:]
######################################################
# Compute weights and take weighted average over latitude dimension
clat = np.cos(np.deg2rad(lats))
clat1 = clat/MV.sum(clat)
clat1[0] = 0.
clats = np.zeros(len(clat1))
for ilat in range(len(clat1)):
clats[ilat] = np.sum(clat1[:ilat+1])
# clats[0] = 0.
#Needs = [-90,-50,-30,-15,0, 15,30,50,90]
Needs = [-85, -55, -35, -15, 15, 35, 55, 85]
N = [i for i in range(len(lats)) if lats[i] in Needs]
spec_lats = Needs
spec_clats = list(np.array(clats)[N])
# print('clat1=',clat1)
# print('lats=',lats)
# print('clats=',clats)
# print('spec_lats=',spec_lats)
# print('spec_clats=',spec_clats)
######################################################
# get zonal mean
data_all[:,icase] = MV.average(data,axis=1)
# start plotting ...
ax = fig.add_subplot(2,2,num1+1)
ax.set_prop_cycle(color=self.colors,lw=self.linewidths,linestyle=self.linestyles)
L1 = ax.plot(clats,data_all,alpha=self.a1)
# highlight CESM2
if self.highlight_CESM2:
data_others = pd.DataFrame(data_others,columns = model_list)
for column in data_others.columns:
if column == 'CESM2':
L3 = ax.plot(clats,data_others.loc[:,column],lw=self.lw_CESM2,ls=self.ls_CESM2,color=self.lc_CESM2)
# plot other CMIP models
if self.Add_otherCMIPs:
L2 = ax.plot(clats,np.average(data_others,axis=1),lw=3,label='ENS-MEAN',color='grey',linestyle='-')
ax.fill_between(clats, np.amax(data_others,axis=1),np.amin(data_others,axis=1),alpha=0.2,color='grey')
plt.xticks(spec_clats,spec_lats,fontsize=self.fh)
ax.set_xlim((0,1))
plt.yticks(fontsize=self.fh)
ax.set_title(variables_out[ivar],fontsize=self.fh)
ax.set_ylabel('W/m$^2$/K',fontsize=self.fh)
ax.tick_params(axis='both', which='major', labelsize=self.fh)
# ax.set_xlim((-90,90))
ax.set_ylim((-2,2))
ax.grid(which='major', linestyle=':', linewidth='1.0', color='grey')
ax.axhline(y=0,color='grey',linestyle='--',lw=2)
if ivar == len(variables)-1:
if self.highlight_CESM2:
ax.legend(L1+L3,cases_here+['CESM2-amip4K'],fontsize=self.fh1,bbox_to_anchor=(1.04,0), loc='lower left')
else:
#ax.legend(L1,cases_here,fontsize=self.fh1,bbox_to_anchor=(1.04,0), loc='lower left')
ax.legend(L1,cases_here,fontsize=self.fh1,loc='best')
num1 += 1
plt.tight_layout()
fig.savefig(self.figdir+'Zonal-mean-Cloud-RadKernel-Feedback_'+str(np.round(ii,0))+'-'+self.cases[-1]+'.png',bbox_inches='tight',dpi=300)
plt.close(fig)
pd_plot = prepare_pd2html('../figure/Zonal-mean-Cloud-RadKernel-Feedback_'+str(np.round(ii,0))+'-'+self.cases[-1]+'.png',
'CRE [W/m2/K]',
'Adjusted CRE feedbacks derived from radiative kernel method (SW, LW, NET)',
'ncases = '+str(np.round(ii,0)))
pd_plot_all = pd.merge(pd_plot_all, pd_plot, on =['Variables','Description','Case.VS.Case','Plot'],how='outer')
print('------------------------------------------------')
print('plot_RadKernel_zonalmean is done!')
print('------------------------------------------------')
return pd_plot_all
###################################################################
### 4. bar plot of cloud feedback based on cloud radiative kernel
###################################################################
def plot_CldRadKernel_globalmean(self):
cases_here = copy.deepcopy(self.cases)
if 'amip-4xCO2' in self.cases:
cases_here.remove('amip-4xCO2')
print('ScatterPlot-Cloud-feedback-Decomposition starts .........')
# other CMIP models
if self.Add_otherCMIPs:
phases = ['CMIP5','CMIP6']
exp_cntl = [['piControl','amip'],['piControl','amip']]
exp_new = [['abrupt4xCO2','amip4K'],['abrupt-4xCO2','amip-p4K']]
# exp_cntl = [['amip','amip'],['amip','amip']]
# exp_new = [['amip4K','amip4K'],['amip-p4K','amip-p4K']]
prefix = 'decomp_global_mean_lw'
suffix1 = '*1yr-150yr.csv'
suffix2 = '*.csv'
models_all,cmip5_models,cmip6_models = PDF.get_intersect(exp_cntl,exp_new,prefix,suffix1,suffix2,self.datadir_CldRadKernel)
models = [cmip5_models, cmip6_models]
model_list = cmip5_models + cmip6_models
# print('models_all=',models_all)
# print('cmip5_models=',cmip5_models)
# print('cmip6_models=',cmip6_models)
df_LW_others = pd.DataFrame()
df_SW_others = pd.DataFrame()
for iphase,phase in enumerate(phases):
for imodel,model in enumerate(models[iphase]):
df = pd.read_csv(self.datadir_CldRadKernel+'decomp_global_mean_lw_'+phase+'_'+exp_new[iphase][1]+'_'+model+'.csv',index_col=0)
df2 = df.loc[:,model]
df_LW_others[model] = df2
df = pd.read_csv(self.datadir_CldRadKernel+'decomp_global_mean_sw_'+phase+'_'+exp_new[iphase][1]+'_'+model+'.csv',index_col=0)
df2 = df.loc[:,model]
df_SW_others[model] = df2
# E3SM
pd_plot_all = pd.DataFrame(columns=['Variables','Description','Case.VS.Case','Plot'])
for ii in self.ncase:
print('ii = ',ii)
df_LW_all = pd.DataFrame()
df_SW_all = pd.DataFrame()
for icase,case in enumerate(cases_here[:ii]):
if case == 'v1_coupled':
df1 = pd.read_csv(self.datadir_v1+'decomp_global_mean_lw_CMIP6_abrupt-4xCO2_E3SM-1-0_r1i1p1f1_1yr-150yr.csv',index_col=0)
df2 = df1.loc[:,'E3SM-1-0']
df_LW_all[case] = df2
df1 = pd.read_csv(self.datadir_v1+'decomp_global_mean_sw_CMIP6_abrupt-4xCO2_E3SM-1-0_r1i1p1f1_1yr-150yr.csv',index_col=0)
df2 = df1.loc[:,'E3SM-1-0']
df_SW_all[case] = df2
elif case == 'v1_amip4K':
df1 = pd.read_csv(self.datadir_v1+'decomp_global_mean_lw_CMIP6_amip-p4K_E3SM-1-0_r2i1p1f1_1yr-36yr.csv',index_col=0)
df2 = df1.loc[:,'E3SM-1-0']
df_LW_all[case] = df2
df1 = pd.read_csv(self.datadir_v1+'decomp_global_mean_sw_CMIP6_amip-p4K_E3SM-1-0_r2i1p1f1_1yr-36yr.csv',index_col=0)
df2 = df1.loc[:,'E3SM-1-0']
df_SW_all[case] = df2
elif case == 'v1_future4K':
df1 = pd.read_csv(self.datadir_v1+'decomp_global_mean_lw_CMIP6_amip-future4K_E3SM-1-0_r2i1p1f1_1yr-36yr.csv',index_col=0)
df2 = df1.loc[:,'E3SM-1-0']
df_LW_all[case] = df2
df1 = pd.read_csv(self.datadir_v1+'decomp_global_mean_sw_CMIP6_amip-future4K_E3SM-1-0_r2i1p1f1_1yr-36yr.csv',index_col=0)
df2 = df1.loc[:,'E3SM-1-0']
df_SW_all[case] = df2
elif case == 'amip-4xCO2':
continue
else:
if 'a4SST' in case or 'amip-p4K-CESM2' in case:
MODEL = 'CESM2'
else:
MODEL = 'E3SM-1-0'
df1 = pd.read_csv(self.datadir_v2+'decomp_global_mean_lw_'+case+'.csv',index_col=0)
df2 = df1.loc[:,MODEL]
df_LW_all[case] = df2
df1 = pd.read_csv(self.datadir_v2+'decomp_global_mean_sw_'+case+'.csv',index_col=0)
df2 = df1.loc[:,MODEL]
df_SW_all[case] = df2
# get net cloud feedback
df_net_all = df_SW_all + df_LW_all
if self.Add_otherCMIPs:
df_net_others = df_SW_others + df_LW_others
# ----------------------------------------------------------
# start plotting
fig, axes = plt.subplots(nrows=3,ncols=1,figsize=(12,15))
titles = ['All Cloud CTP bins', "Non-Low Cloud CTP bins", "Low Cloud CTP bins"]
labels = ['Total','Amount','Altitude','Optical Depth','Residual']
wc = 1 # circle
wf = 0 # filled
w = 0.25
w2 = 0.08
w3 = 0.08
x = np.asarray([1,2,3,4,5])
for jj in range(3): ## loop for each panel, jj reprents All, Non-Low and Low Cloud
for icol,column in enumerate(df_LW_all.columns):
print('Doing LW...')
y1 = df_LW_all.iloc[jj*5:(jj+1)*5,icol]
if column == 'v1_coupled' or column == 'v2_coupled':
La = axes[jj].scatter(x-w+w2,y1.values.tolist(),marker='v',s=self.s1,color=self.colors[icol],alpha=self.a1,label=column)
elif column == 'v1_amip4K':
axes[jj].scatter(x-w+w2,y1.values.tolist(),marker='x',s=self.s1,color=self.colors[icol],alpha=self.a1,label=column)
elif column == 'v1_future4K':
axes[jj].scatter(x-w+w2,y1.values.tolist(),marker='x',s=self.s1,color=self.colors[icol],alpha=self.a1,label=column)
else:
# L1 = axes[jj].scatter(x-w+w2,y1.values.tolist(),marker='o',s=self.s2,color=self.colors[icol],alpha=self.a1,label=column)
La = axes[jj].scatter(x-w+w2,y1.values.tolist(),marker='v',s=self.s2,color=self.colors[icol],alpha=self.a1,label=column)
for icol,column in enumerate(df_net_all.columns):
print('Doing NET...')
y1 = df_net_all.iloc[jj*5:(jj+1)*5,icol]
if column == 'v1_coupled' or column == 'v2_coupled':
Lb = axes[jj].scatter(x+w2,y1.values.tolist(),marker='o',s=self.s1,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
elif column == 'v1_amip4K':
axes[jj].scatter(x+w2,y1.values.tolist(),marker='x',s=self.s1,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
elif column == 'v1_future4K':
axes[jj].scatter(x+w2,y1.values.tolist(),marker='x',s=self.s1,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
else:
# L2 = axes[jj].scatter(x+w2,y1.values.tolist(),marker='o',s=self.s2,color=self.colors[icol],alpha=self.a1,label=column)
Lb = axes[jj].scatter(x+w2,y1.values.tolist(),marker='o',s=self.s2,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
for icol,column in enumerate(df_SW_all.columns):
print('Doing SW...')
y1 = df_SW_all.iloc[jj*5:(jj+1)*5,icol]
if column == 'v1_coupled' or column == 'v2_coupled':
Lc = axes[jj].scatter(x+w+w2,y1.values.tolist(),marker='^',s=self.s1,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
elif column == 'v1_amip4K':
axes[jj].scatter(x+w+w2,y1.values.tolist(),marker='x',s=self.s1,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
elif column == 'v1_future4K':
axes[jj].scatter(x+w+w2,y1.values.tolist(),marker='x',s=self.s1,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
else:
# L3 = axes[jj].scatter(x+w+w2,y1.values.tolist(),marker='o',s=self.s2,color=self.colors[icol],alpha=self.a1,label=column)
Lc = axes[jj].scatter(x+w+w2,y1.values.tolist(),marker='^',s=self.s2,color=self.colors[icol],alpha=self.a1,label='_nolegend_')
plt.legend([La,Lb,Lc],["LW","NET","SW"],scatterpoints=1,loc="upper left",fontsize=self.fh1)
# CMIP - other models
if self.Add_otherCMIPs:
a2 = 0.3
s3 = 100
for icol,column in enumerate(df_LW_others.columns):
y1 = df_LW_others.iloc[jj*5:(jj+1)*5,icol]
if self.highlight_CESM2 and 'CESM2' in column:
axes[jj].scatter(x-w+w2-w3,y1.values.tolist(),marker='X',s=s3,color='red',alpha=a2,\
label=column.split('_')[0]+'_amip-p4K')
else:
axes[jj].scatter(x-w+w2-w3,y1.values.tolist(),marker='v',s=s3,color='red',alpha=a2,label='_nolegend_')
for icol,column in enumerate(df_net_others.columns):
y1 = df_net_others.iloc[jj*5:(jj+1)*5,icol]
if self.highlight_CESM2 and 'CESM2' in column:
axes[jj].scatter(x+w2-w3,y1.values.tolist(),marker='X',s=s3,color='grey',alpha=a2,\
label=column.split('_')[0]+'_amip-p4K')
else:
axes[jj].scatter(x+w2-w3,y1.values.tolist(),marker='o',s=s3,color='grey',alpha=a2,label='_nolegend_')
for icol,column in enumerate(df_SW_others.columns):
y1 = df_SW_others.iloc[jj*5:(jj+1)*5,icol]
if self.highlight_CESM2 and 'CESM2' in column:
axes[jj].scatter(x+w+w2-w3,y1.values.tolist(),marker='X',s=s3,color='blue',alpha=a2,\
label=column.split('_')[0]+'_amip-p4K')
else:
axes[jj].scatter(x+w+w2-w3,y1.values.tolist(),marker='^',s=s3,color='blue',alpha=a2,label='_nolegend_')
L1 = axes[jj].scatter(x-w+w2-w3,df_LW_others.iloc[jj*5:(jj+1)*5,:].mean(axis=1),marker='v',s=s3,color='red',alpha=1.0,label='_nolegend_')
L2 = axes[jj].scatter(x+w2-w3,df_net_others.iloc[jj*5:(jj+1)*5,:].mean(axis=1),marker='o',s=s3,color='grey',alpha=1.0,label='_nolegend_')
L3 = axes[jj].scatter(x+w+w2-w3,df_SW_others.iloc[jj*5:(jj+1)*5,:].mean(axis=1),marker='^',s=s3,color='blue',alpha=1.0,label='_nolegend_')
#plt.legend((L1,L2,L3),["LW","NET","SW"],scatterpoints=1,bbox_to_anchor=(1,1),loc="best",fontsize=self.fh1)
if jj == 0:
axes[jj].legend(fontsize=self.fh1,ncol=2)
axes[jj].grid(which='major', linestyle=':', linewidth='1.0', color='grey')
axes[jj].axhline(0, color="grey", linestyle="-",linewidth=2)
axes[jj].set_ylabel('W/$m^2$/K',fontsize=self.fh)
axes[jj].set_title(titles[jj],fontsize=self.fh)
axes[jj].set_ylim([-0.5,1.5])
major_ticks = np.arange(-1.0,1.5,0.5)
minor_ticks = np.arange(-1.0,1.5,0.25)
axes[jj].set_yticks(major_ticks)
axes[jj].set_yticks(minor_ticks,minor=True)
axes[jj].tick_params(axis='both', which='major', labelsize=self.fh)
axes[jj].grid(axis='y',c='grey',linestyle='-.',which = 'major')