1 | from netCDF4 import Dataset |
---|
2 | import numpy as np |
---|
3 | import matplotlib.pyplot as plt |
---|
4 | |
---|
5 | #% This python scripts plots some of the inputs to the radiation scheme |
---|
6 | #% in Fig. 1 and the outputs in Fig. 2 |
---|
7 | code = 'ecrad_meridian' |
---|
8 | in_file=Dataset(code+'.nc','r') |
---|
9 | pressure_hl=in_file.variables['pressure_hl'][:] |
---|
10 | temperature_hl=in_file.variables['temperature_hl'][:] |
---|
11 | lat=in_file.variables['lat'][:] |
---|
12 | cos_solar_zenith_angle=in_file.variables['cos_solar_zenith_angle'][:] |
---|
13 | skin_temperature=in_file.variables['skin_temperature'][:] |
---|
14 | cloud_fraction=in_file.variables['cloud_fraction'][:] |
---|
15 | aerosol_mmr=in_file.variables['aerosol_mmr'][:] |
---|
16 | cases = [code+'_noaer_out.nc', |
---|
17 | code+'_default_out.nc', |
---|
18 | code+'_expran_out.nc', |
---|
19 | code+'_tc_out.nc', |
---|
20 | code+'_spartacus_out.nc', |
---|
21 | code+'_spartacus_maxentr_out.nc'] |
---|
22 | |
---|
23 | |
---|
24 | f = [0]*6 |
---|
25 | k=0 |
---|
26 | for icase in cases: |
---|
27 | f[k] = Dataset(icase,'r') |
---|
28 | k=k+1 |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | case_list = [0,1,2,3,4,5] |
---|
33 | leg = ['McICA Exp-Exp no aerosols', |
---|
34 | 'McICA Exp-Exp', |
---|
35 | 'McICA Exp-Ran', |
---|
36 | 'Tripleclouds Exp-Ran', |
---|
37 | 'SPARTACUS Exp-Ran', |
---|
38 | 'Classic SPARTACUS Exp-Ran'] |
---|
39 | |
---|
40 | styles = ['b','r','g','m','c','k'] |
---|
41 | |
---|
42 | |
---|
43 | p = 0.01*0.5*np.median(pressure_hl[:,0:-1]+pressure_hl[:,1::],0) |
---|
44 | |
---|
45 | nplot=4 |
---|
46 | plt.figure(1,figsize=(10,10)) |
---|
47 | # set(gcf,'defaultlinelinewidth',1); |
---|
48 | # set(gcf,'units','inches','paperposition',[0.5 0.5 15 30]); |
---|
49 | # nplot = 4; |
---|
50 | #fig, (ax0, ax1) = plt.subplots(nrows=2) |
---|
51 | |
---|
52 | plt.subplot(nplot,1,1) |
---|
53 | plt.plot(lat,cos_solar_zenith_angle,color='k', linewidth=2.0) |
---|
54 | ax= plt.gca() |
---|
55 | ax.set_xlim([-90,90]) |
---|
56 | plt.ylabel('Cos solar zenith ang.') |
---|
57 | |
---|
58 | |
---|
59 | plt.subplot(nplot,1,2) |
---|
60 | plt.plot(lat,skin_temperature-273.15,color='r',linewidth=2.0,label='Skin temperature') |
---|
61 | plt.plot(lat,temperature_hl[:,-1]-273.15,color='b', linewidth=2.0,label='Air between first two model levels') |
---|
62 | plt.gca().set_xlim([-90,90]) |
---|
63 | plt.ylabel('Temperature ($^\circ$C)'); |
---|
64 | plt.gca().set_ylim([-50,60]); |
---|
65 | plt.gca().legend(loc='best',fontsize='xx-small') |
---|
66 | |
---|
67 | plt.subplot(nplot,1,3) |
---|
68 | CS=plt.contourf(lat,p,cloud_fraction.T,10, vmin=0.05, vmax=0.95,cmap="viridis") |
---|
69 | plt.colorbar() |
---|
70 | plt.contour(CS,levels=CS.levels[::4],colors='k') |
---|
71 | plt.gca().set_ylim([0,1013]) |
---|
72 | plt.gca().invert_yaxis() |
---|
73 | plt.gca().set_xlim([-90,90]) |
---|
74 | plt.ylabel('Pressure (hPa)') |
---|
75 | textstyle = dict(size=10, color='white') |
---|
76 | plt.gca().text(-70,100,'Cloud fraction',**textstyle) |
---|
77 | # text(-90, 0, [' ' 10 ' Cloud fraction'],'verticalalignment','top') |
---|
78 | |
---|
79 | |
---|
80 | print(aerosol_mmr.shape) |
---|
81 | plt.subplot(nplot,1,4) |
---|
82 | sea_salt = 1e9*np.sum(aerosol_mmr[:,0:2,-1],1); |
---|
83 | dust = 1e9*np.sum(aerosol_mmr[:,3:5,-1],1); |
---|
84 | organics = 1e9*np.sum(aerosol_mmr[:,6:7,-1],1); |
---|
85 | black_carbon = 1e9*np.sum(aerosol_mmr[:,8:9,-1],1); |
---|
86 | sulphate = 1e9*np.sum(aerosol_mmr[:,10:11,-1],1); |
---|
87 | |
---|
88 | plt.semilogy(lat,sea_salt,'b',label='Sea salt') |
---|
89 | plt.semilogy(lat,dust,'r',label='Dust') |
---|
90 | plt.semilogy(lat,organics,'g',label='Organics') |
---|
91 | plt.semilogy(lat,black_carbon,'k',label='Black carbon') |
---|
92 | plt.semilogy(lat,sulphate,'m',label='Sulphate') |
---|
93 | plt.gca().legend(loc='best',fontsize='xx-small') |
---|
94 | plt.ylabel('Aerosol mass mixing ratio\n ($\mu$g/kg)') |
---|
95 | plt.xlabel('Latitude (deg N)') |
---|
96 | plt.gca().set_xlim([-90,90]) |
---|
97 | |
---|
98 | plt.savefig('input.png') |
---|
99 | |
---|
100 | nplot=4 |
---|
101 | plt.figure(2,figsize=(10,10)) |
---|
102 | # set(gcf,'defaultlinelinewidth',1); |
---|
103 | # set(gcf,'units','inches','paperposition',[0.5 0.5 15 30]); |
---|
104 | |
---|
105 | plt.subplot(nplot,1,1) |
---|
106 | for icase in case_list: |
---|
107 | print(leg[icase]) |
---|
108 | plt.plot(lat, f[icase].variables['flux_dn_sw'][:,-1],label=leg[icase]) |
---|
109 | plt.gca().set_xlim([-90, 90]); |
---|
110 | plt.ylabel('Surface SW down \n(W m$^{-2}$)'); |
---|
111 | plt.gca().legend(loc='best',fontsize='xx-small') |
---|
112 | |
---|
113 | |
---|
114 | plt.subplot(nplot,1,2) |
---|
115 | for icase in case_list: |
---|
116 | cre = f[icase].variables['flux_dn_sw'][:,1]-f[icase].variables['flux_dn_sw_clear'][:,1]-f[icase].variables['flux_up_sw'][:,1]+f[icase].variables['flux_up_sw_clear'][:,1] |
---|
117 | plt.plot(lat, cre,label=leg[icase]) |
---|
118 | plt.gca().set_xlim([-90, 90]); |
---|
119 | plt.ylabel('SW cloud radiative effect \n(W m$^{-2}$)'); |
---|
120 | plt.gca().legend(loc='best',fontsize='xx-small') |
---|
121 | |
---|
122 | |
---|
123 | plt.subplot(nplot,1,3) |
---|
124 | for icase in case_list: |
---|
125 | cre = f[icase].variables['flux_dn_lw'][:,1]-f[icase].variables['flux_dn_lw_clear'][:,1]-f[icase].variables['flux_up_lw'][:,1]+f[icase].variables['flux_up_lw_clear'][:,1] |
---|
126 | plt.plot(lat, cre,label=leg[icase]) |
---|
127 | plt.gca().set_xlim([-90, 90]); |
---|
128 | plt.ylabel('LW cloud radiative effect \n(W m$^{-2}$)'); |
---|
129 | plt.gca().legend(loc='best',fontsize='xx-small') |
---|
130 | |
---|
131 | plt.subplot(nplot,1,4) |
---|
132 | for icase in case_list: |
---|
133 | plt.plot(lat, f[icase].variables['cloud_cover_sw'],label=leg[icase]); |
---|
134 | plt.gca().set_xlim([-90, 90]); |
---|
135 | plt.ylabel('Cloud cover'); |
---|
136 | plt.gca().legend(loc='best',fontsize='xx-small') |
---|
137 | plt.xlabel('Latitude (deg N)'); |
---|
138 | |
---|
139 | |
---|
140 | plt.savefig('output.png') |
---|
141 | #plt.show() |
---|