source: LMDZ6/trunk/libf/phylmd/ecrad/test/i3rc/plot_i3rc.m @ 5456

Last change on this file since 5456 was 4773, checked in by idelkadi, 13 months ago
  • Update of Ecrad in LMDZ The same organization of the Ecrad offline version is retained in order to facilitate the updating of Ecrad in LMDZ and the comparison between online and offline results. version 1.6.1 of Ecrad (https://github.com/lguez/ecrad.git)
  • Implementation of the double call of Ecrad in LMDZ


File size: 8.7 KB
Line 
1% Location of loadnc.m
2path(path, '../common')
3
4do_plot_sw_libradtran = 1;
5do_plot_sw_spartacus_extras = 0; % Need to have run "make i3rc_spartacus_extra"
6
7% Load libRadTran benchmark
8load i3rc_mls_cumulus_LIBRADTRAN
9
10% Load ECRAD/SPARTACUS cases
11sp_code = 'i3rc_mls_cumulus';
12scases = {[sp_code '_ECRAD_ICA_OUT.nc'],... % Stored result of running ECRAD in ICA mode
13          [sp_code '_3reg_3d_out.nc'],...
14          [sp_code '_3reg_3d_clustering_out.nc'],...
15          [sp_code '_mcica_out.nc'],...
16          [sp_code '_tc_out.nc'],...
17          [sp_code '_3reg_1d_out.nc']};
18id_ica = 1;
19id_1d = 6;
20id_3d = 2; % Maximum entrapment
21%id_3d = 7; % Computed entrapment
22ecrad_sw_list = [id_ica id_3d 4 5];
23ecrad_legend = {'ECRAD ICA','ECRAD SPARTACUS','ECRAD McICA','ECRAD Tripleclouds'};
24ecrad_styles = {'b--','r--','g--','c--'};
25
26if do_plot_sw_spartacus_extras
27  scases(end+1:end+6)={[sp_code '_3reg_3d_computed_out.nc'],...
28                       [sp_code '_3reg_3d_minimum_out.nc'],...
29                       [sp_code '_3reg_1d_computed_out.nc'],...
30                       [sp_code '_3reg_1d_minimum_out.nc'],...
31                       [sp_code '_3reg_3d_computedleast_out.nc'],...
32                       [sp_code '_3reg_3d_fractal_out.nc']};
33  ecrad_sw_list = [id_3d 7 8 id_1d 9 10 5 11 12];
34  ecrad_legend = {'SPARTACUS 3D Max','SPARTACUS 3D Comp','SPARTACUS 3D Min',...
35                  'SPARTACUS 1D Max','SPARTACUS 1D Comp','SPARTACUS 1D Min',...
36                  'Tripleclouds','SPARTACUS 3D Comp least','SPARTACUS 3D Fract'};
37  ecrad_styles = {'r--','r-','r-.','b--','bo','bx','c--','m--','m-.'};
38  id_3d_min = 8;
39end
40
41% Factor for conversion to heating rates in K day-1
42ff = 24.*3600.*(9.81./1004);
43for icase = 1:length(scases)
44  sp{icase} = loadnc([scases{icase}]);
45  sp{icase}.hr_sw = ff.*diff(sp{icase}.flux_up_sw-sp{icase}.flux_dn_sw)./diff(sp{icase}.pressure_hl);
46  sp{icase}.hr_lw = ff.*diff(sp{icase}.flux_up_lw-sp{icase}.flux_dn_lw)./diff(sp{icase}.pressure_hl);
47end
48
49% Load input data
50sp_input = loadnc([sp_code '_sza.nc']);
51sp_sza = acosd(sp_input.cos_solar_zenith_angle);
52
53
54sza_axis = [0 90];
55sza_tick = [0:15:90];
56
57% Plot shortwave 3D effect as shown in Fig. 4 of Hogan et al. (2016)
58figure(1)
59clf
60set(gcf,'defaultlinelinewidth',1,'paperposition',[0.25 2.5 21 16]);
61
62subplot(2,2,1);
63if do_plot_sw_libradtran
64  plot(sza,up_toa_1D,'b');
65  hold on
66  errorbar(sza,up_toa_3D,up_toa_std_3D,'r');
67end
68
69for ii = 1:length(ecrad_sw_list)
70  iecrad = ecrad_sw_list(ii);
71  plot(sp_sza,sp{iecrad}.flux_up_sw(1,:),ecrad_styles{ii});
72  hold on
73end
74
75plot(sp_sza,sp{1}.flux_up_sw_clear(1,:),'k');
76
77xlim(sza_axis);
78ylabel('TOA upwelling flux (W m^{-2})');
79text(0,1.02,' \bf(a)','verticalalignment','bottom','units','normalized');
80ylim([0 300]);
81grid on
82set(gca,'xtick',sza_tick);
83xlabel('Solar zenith angle (\circ)')
84ylim([0 250]);
85if do_plot_sw_libradtran
86  leg = {'libRadtran ICA (DISORT)',...
87         'libRadtran 3D (MYSTIC)'};
88  leg([1:length(ecrad_legend)]+2) = ecrad_legend;
89else
90  leg = ecrad_legend;
91end
92leg{length(leg)+1} = 'Clear sky';
93hh=legend(leg,3);
94set(hh,'fontsize',7)
95
96subplot(2,2,2);
97plot(sza,dn_direct_surf_1D./cosd(sza),'b');
98hold on
99errorbar(sza,dn_direct_surf_3D./cosd(sza), dn_direct_surf_std_3D./cosd(sza),'r');
100
101for ii = 1:length(ecrad_sw_list)
102  iecrad = ecrad_sw_list(ii);
103  plot(sp_sza,sp{iecrad}.flux_dn_direct_sw(end,:)./cosd(sp_sza'),ecrad_styles{ii});
104end
105
106plot(sp_sza,sp{id_3d}.flux_dn_direct_sw_clear(end,:)./cosd(sp_sza'),'k');
107
108xlim(sza_axis);
109ylim([0 1100]);
110grid on
111set(gca,'xtick',sza_tick);
112xlabel('Solar zenith angle (\circ)')
113ylabel('Direct flux in direction of sun (W m^{-2})');
114h=legend(leg,3);
115set(h,'fontsize',7)
116text(0,1.02,' \bf(b)','verticalalignment','bottom','units','normalized');
117
118up1dinterp = interp1(sza,up_toa_1D,sp_sza)';
119
120subplot(2,2,3)
121errorbar(sza,...
122         100.*(up_toa_3D-up_toa_1D)./(up_toa_1D-sw_up_clear(end,:)),...
123         100.*(up_toa_std_3D)./(up_toa_1D-sw_up_clear(end,:)),...
124         'r');
125hold on
126effect_3d = 100.*(sp{id_3d}.flux_up_sw(1,:)-sp{id_ica}.flux_up_sw(1,:)) ...
127            ./(sp{id_ica}.flux_up_sw(1,:)-sp{id_3d}.flux_up_sw_clear(1,:));
128effect_3d(end) = NaN;
129plot(sp_sza,effect_3d,'r--');
130
131if do_plot_sw_spartacus_extras
132  effect_edge = 100.*(sp{id_3d_min}.flux_up_sw(1,:)-sp{id_ica}.flux_up_sw(1,:)) ...
133              ./(sp{id_ica}.flux_up_sw(1,:)-sp{id_3d_min}.flux_up_sw_clear(1,:));
134  effect_edge(end) = NaN;
135  plot(sp_sza,effect_edge,'r-.');
136end
137
138xlim(sza_axis);
139ylim([-40 140]);
140set(gca,'xtick',sza_tick);
141ylabel('3D change to cloud radiative effect (%)');
142xlabel('Solar zenith angle (\circ)')
143text(0,1.02,' \bf(d)','verticalalignment','bottom','units','normalized');
144grid on
145if do_plot_sw_spartacus_extras
146  h=legend('libRadtran','SPARTACUS','SPARTACUS edge only',2);
147else
148  h=legend('libRadtran','SPARTACUS',2);
149end
150set(h,'fontsize',8)
151
152subplot(2,2,4)
153errorbar(sza,-(up_toa_3D-up_toa_1D),up_toa_std_3D,'r');
154hold on
155effect_3d = sp{id_3d}.flux_up_sw(1,:)-sp{id_ica}.flux_up_sw(1,:);
156effect_3d(end) = NaN;
157plot(sp_sza,-effect_3d,'r--');
158
159if do_plot_sw_spartacus_extras
160  effect_edge = sp{id_3d_min}.flux_up_sw(1,:)-sp{id_ica}.flux_up_sw(1,:);
161  effect_edge(end) = NaN;
162  plot(sp_sza,-effect_edge,'r-.');
163end
164
165xlim(sza_axis);
166ylim([-25 30]);
167set(gca,'xtick',sza_tick);
168ylabel('3D change to cloud radiative effect (W m^{-2})');
169xlabel('Solar zenith angle (\circ)')
170text(0,1.02,' \bf(c)','verticalalignment','bottom','units','normalized');
171grid on
172if do_plot_sw_spartacus_extras
173  h=legend('libRadtran','SPARTACUS','SPARTACUS edge only',2);
174else
175  h=legend('libRadtran','SPARTACUS',2);
176end
177
178set(h,'fontsize',8)
179
180% Write selected cloud radiative forcings to the terminal window
181isza = [1 6];
182sza(isza)
183
184crf_mystic_1d_toa = -(up_toa_1D(isza)-sw_up_clear(end,isza))
185crf_mystic_3deffect = up_toa_1D(isza)-up_toa_3D(isza)
186
187crf_spartacus_1d_toa = interp1(sp_sza,-sp{id_ica}.flux_up_sw(1,:) + sp{id_ica}.flux_up_sw_clear(1,:), sza(isza))
188crf_spartacus_3deffect = interp1(sp_sza,-effect_3d(:), sza(isza))
189
190crf_mystic_3deffect_percentage = 100.* crf_mystic_3deffect ./ crf_mystic_1d_toa
191crf_spartacus_3deffect_percentage = 100.* crf_spartacus_3deffect ./ crf_spartacus_1d_toa
192
193
194% Plot the 3D impact on shortwave heating rates as in Fig. 5 of Hogan et al. (2016)
195figure(2)
196clf
197set(gcf,'units','inches','paperposition',[0.25 0.25 10 9],'defaultlinelinewidth',1);
198
199sza_map = [1 9 16 24 31 38 41 45];
200sza_map = {1, [8 9], 16, [23 24], 31, [38 39], 41, 45};
201
202for isza = [1 5]; %[2 6]
203  sza(isza)
204  hr_sp_clear = ff.*diff(sp{id_3d}.flux_up_sw_clear-sp{id_3d}.flux_dn_sw_clear)./diff(sp{id_3d}.pressure_hl);
205  ii = sza_map{isza};
206  z_mid_sp = (sp_input.height_hl(1:end-1,1) + sp_input.height_hl(2:end,1))./2;
207
208  plot(dat1D{isza}.hr,dat1D{isza}.z_mid,'b')
209  axis([1 4.5 0 3]);
210  hold on
211
212  plot(dat3D{isza}.hr,dat3D{isza}.z_mid,'r')
213  if isza == 5
214    errs=nan.*dat3D{isza}.hr_std;
215    ind = [2 4 6 16 26 36 43:2:49];
216    ind = [1:5 8:5:38 42:50];
217    errs(ind) = dat3D{isza}.hr_std(ind);
218    herrorbar(dat3D{isza}.hr,dat3D{isza}.z_mid,errs,'r')
219  end
220 
221  SPARTACUS_SZA = sp_sza(ii);
222  plot(mean(sp{id_ica}.hr_sw(:,ii),2),z_mid_sp./1000,'b--');
223  plot(mean(sp{id_3d}.hr_sw(:,ii),2),z_mid_sp./1000,'r--');
224  plot(mean(hr_sp_clear(:,ii),2),z_mid_sp./1000,'k-');
225end
226
227axis([1 4.5 0 3]);
228xlabel('Shortwave heating rate (K d^{-1})');
229ylabel('Height (km)');
230text(1.25,3,['\theta_0=' num2str(sza(isza)) '\circ'],'verticalalignment','bottom')
231text(2.4,3,'\theta_0=0\circ','verticalalignment','bottom')
232h=legend(leg{[1 2 3 4 end]},4);
233set(h,'fontsize',7);
234
235% Plot longwave 3D effect on heating rates as shown in Fig. 6 of Hogan
236% et al. (2016)
237p = interp1(sp_input.height_hl(:,1),sp_input.pressure_hl(:,1),z.*1000);
238z_mid = 0.5.*(z(1:end-1)+z(2:end));
239
240hr_clear = ff.*diff(lw_up_clear-lw_dn_clear)./diff(p);
241hr_1d = ff.*diff(d{1}.lw_up-d{1}.lw_dn)./diff(p);
242hr_3d = ff.*diff(d{2}.lw_up-d{2}.lw_dn)./diff(p);
243hr_sp_3d = ff.*diff(sp{id_3d}.flux_up_lw-sp{id_3d}.flux_dn_lw)./diff(sp{id_3d}.pressure_hl);
244hr_sp_1d = ff.*diff(sp{id_1d}.flux_up_lw-sp{id_1d}.flux_dn_lw)./diff(sp{id_1d}.pressure_hl);
245hr_sp_clear = ff.*diff(sp{id_1d}.flux_up_lw_clear-sp{id_1d}.flux_dn_lw_clear)./diff(sp{id_1d}.pressure_hl);
246hr_sp_3d_clustering = ff.*diff(sp{3}.flux_up_lw-sp{3}.flux_dn_lw)./diff(sp{3}.pressure_hl);
247
248cols = 'brmg';
249cols_clear = 'km';
250
251figure(3)
252clf
253set(gcf,'units','inches','paperposition',[0.25 0.25 10 9],'defaultlinelinewidth',1);
254
255plot(smooth1D(hr_clear),z_mid,'k');
256hold on
257plot(smooth1D(hr_1d),z_mid,cols(1));
258plot(smooth1D(hr_3d),z_mid,cols(2));
259plot(smooth1D(hr_sp_clear(:,1)),z_mid_sp./1000,'k--');
260plot(smooth1D(hr_sp_1d(:,1)),z_mid_sp./1000,[cols(1) '--']);
261plot(smooth1D(hr_sp_3d_clustering(:,1)),z_mid_sp./1000,[cols(2) '--']);
262h=plot(smooth1D(hr_sp_3d(:,1)),z_mid_sp./1000,[cols(3) '--']);
263if cols(3) == 'm'
264  set(h,'color',[1 0.65 0]);
265end
266
267ylim([0 3]);
268
269xlabel('Longwave heating rate (K d^{-1})');
270ylabel('Height (km)');
271xlim([-5 -1]);
272h=legend('libRadtran clear','libRadtran ICA (DISORT)','libRadtran 3D (MYSTIC)',...
273         'SPARTACUS clear','SPARTACUS 1D','SPARTACUS 3D clust', ...
274         'SPARTACUS 3D no clust',3);
275set(h,'fontsize',6);
Note: See TracBrowser for help on using the repository browser.