-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAMP_vs_bin_2d.m
165 lines (128 loc) · 5.75 KB
/
AMP_vs_bin_2d.m
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
clear
clear global
global mconfig ivar1 ivar2 its nikki output_dir vnum ...
bintype var1_str var2_str indvar2D_name indvar2D_name_set ...
indvar2D_ename indvar2D_ename_set indvar2D_units_set indvar2D_units ...
israin iscloud isprof ispath isproc %#ok<*NUSED>
vnum='0001'; % last four characters of the model output file.
nikki='2022-01-05';
run global_var.m
% get the list of configs. cant put it into globar_var
mconfig_ls_dir = dir([output_dir,nikki,'/']);
mconfig_ls_dir_flags = [mconfig_ls_dir.isdir];
mconfig_ls_dir_flags(1:2) = 0; % ignore the current and parent dir
mconfig_ls = {mconfig_ls_dir(mconfig_ls_dir_flags).name};
%%
close all
l_anim=0;
l_save=1;
l_fig=1;
l_visible=0;
if l_fig, fig_path=figure('Position',[1722 525 859 452]); end
if ~l_visible, set(fig_path,'Visible','off'), end
for iconf = 1%:length(mconfig_ls)
mconfig = mconfig_ls{iconf};
run case_dep_var.m
%% read files
for its = 1:length(bintype)
for ivar1 = 1:length(var1_str)
% close all
for ivar2 = 1:length(var2_str)
% close all
[~, ~, ~, ~, amp_struct]=...
loadnc('amp');
[~, ~, ~, ~, bin_struct]=...
loadnc('bin');
% indices of vars to compare
vars=1;
vare=length(indvar2D_name);
%%
% plot
time=bin_struct.time;
z=bin_struct.z;
x=bin_struct.x;
w=bin_struct.w;
cloudm1=bin_struct.cloud_M1*pi/6*1000;
rainm1=bin_struct.rain_M1*pi/6*1000;
indvar2D=rainm1;
indvar2D(indvar2D==-999)=nan;
if l_fig
for ivar = vars:vare
var_comp_raw_amp = amp_struct.(indvar2D_name{ivar});
[var_comp_amp,~,~] = var2phys(var_comp_raw_amp,indvar2D_name{ivar},1);
var_comp_raw_bin = bin_struct.(indvar2D_name{ivar});
[var_comp_bin,linORlog,range] = var2phys(var_comp_raw_bin,indvar2D_name{ivar},1);
% change linestyle according to cloud/rain
if israin
lsty=':';
else
lsty='-';
end
if ispath
set(0,'CurrentFigure',fig_path)
plot(time,var_comp_amp,'LineWidth',2,...
'LineStyle',lsty,'color',color_order{1},...
'DisplayName',['amp ' indvar2D_ename{ivar}])
hold on
plot(time,var_comp_bin,'LineWidth',2,...
'LineStyle',lsty,'color',color_order{2},...
'DisplayName',['bin ' indvar2D_ename{ivar}])
xlim([min(time) max(time)])
xlabel('Time [s]')
if israin
ylabel(['LWP' indvar2D_units{ivar}])
else
ylabel([indvar2D_ename{ivar} indvar2D_units{ivar}])
end
if israin || (~israin && ~iscloud)
legend('show')
set(gca,'fontsize',16)
title([mconfig ' ' bintype{its}], ...
'fontsize',20,...
'FontWeight','bold')
vnifn=indvar2D_ename{ivar};
if israin vnifn='liquid water path'; end
hold off
if l_save
saveas(fig_path,[plot_dir,'/',...
vnifn, ' ',...
'amp vs bin-',bintype{its},' ',vnum,' ',...
var1_str{ivar1}, ' ', var2_str{ivar2},'.png'])
end
end
end % if path
end
end
%%
if l_anim
time_step=1;
time_length = floor(length(time)/time_step);
for it_vididx = 1:time_length+1 %#ok<*UNRCH>
% it_vididx = time index in the video
% it_runidx = time index in the run
% itime = physical time passed since the beginning of the run
it_runidx = (it_vididx-1)*time_step;
if it_runidx>length(time) it_runidx=length(time); end
if it_runidx<1 it_runidx=1; end
itime = time(it_runidx);
% reshaped cloud m1
indvar2D_rs = reshape(indvar2D(it_runidx,:,:),length(x),[])';
nanimagesc(x,z,indvar2D_rs)
colorbar
% colormap(BrBG20)
% wbound=max(indvar2D(:));
% caxis([-wbound wbound])
colormap(Blues)
set(gca,'ColorScale','log')
caxis([1e-8 1e-2])
title(['t=' num2str(itime) 's'])
F(it_vididx)=getframe(gcf);
it_vididx=it_vididx+1;
end % for
saveVid(F,['2D yesdown rwc bin_sbm-' vnum], 10)
% saveVid(F,['2D wind bin_sbm-' vnum], 10)
end % if doanimation
end
end
end
end