-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSDprof_timeprog.m
136 lines (113 loc) · 3.49 KB
/
DSDprof_timeprog.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
function DSDprof_timeprog(ti, tf, ts_plot, DSDprof_mphys,z,binmean,...
Cmap,clr_linORlog,pltflag,var_overlay)
global its bintype dt fn var1_str var2_str ivar1 ivar2 color_order test cmaps
close all
c_map = cmaps.Blues_s;
if ~exist('var_overlay','var') || isempty(var_overlay)
var_overlay=nan;
end
time_length = floor((tf-ti)/ts_plot+1);
ts_output=ts_plot/dt;
F(time_length-1) = struct('cdata',[],'colormap',[]);
if any(~isnan(var_overlay(:)))
figure('position',[233 247 800 400])
else
figure('position',[233 247 600 400])
end
tl=tiledlayout('flow');
nexttile(1)
iti = int32(ti/dt);
itf = int32(tf/dt);
istep = int32(ts_plot/dt);
time_series=iti:istep:itf;
for iframe = 1:length(time_series)
itime = time_series(iframe);
if itime<=0
itime = 1;
end
real_time = double(itime)*double(dt);
% switch pltflag
% case {'mass','mass_diff','mass_adv'}
% DSD_prof_is=squeeze(DSDprof_mphys(itime,:,:));
% case {'number','number_diff'}
% if bintype{its}=="tau"
% DSD_prof_is=squeeze(DSDprof_mphys(itime,:,:))/1e6;
% else
% DSD_prof_is=mass2conc(squeeze(DSDprof_mphys(itime,:,:)),binmean)/1e6;
% end
% end
% if length(binmean)<size(DSD_prof_is,1)
% DSD_prof_is = DSD_prof_is(1:length(binmean),:);
% end
nanimagesc(binmean,z,squeeze(DSDprof_mphys(itime,1:length(binmean),:))')
set(gca,'XScale','log')
set(gca,'YDir','normal')
if any(~isnan(var_overlay(:)))
xlim([1e-7 max(var_overlay(:))])
else
xlim([min(binmean) max(binmean)])
end
% ylim([0 3000])
colormap(c_map)
cbar = colorbar;
% cbar.Visible = 'off';
%set(gca,'Position',[0.1198 0.1100 0.7141 0.8150])
grid
switch pltflag
case 'mass'
cbar.Label.String = 'DSD [kg/kg/ln(r)]';
caxis([1e-8 1e-2])
case 'number'
cbar.Label.String = 'DSD [1/cc/ln(r)]';
caxis([1e-10 1e3])
case 'mass_adv'
cbar.Label.String = 'DSD_adv [kg/kg/ln(r)/s]';
caxis([-1e-8 1e-8])
case 'mass_diff'
cbar.Label.String = 'AMP-BIN mass';
caxis([-max(abs(DSDprof_mphys(:))) max(abs(DSDprof_mphys(:)))])
case 'number_diff'
cbar.Label.String = 'AMP-BIN number';
caxis([-1e2 1e2])
end
set(gca,'colorscale',clr_linORlog)
xlabel('Diameter [m]')
ylabel('Altitude [m]')
if any(~isnan(var_overlay(:)))
hold on
% nexttile(2)
plot(var_overlay(itime,:,1),z,'linewidth',1,'color',color_order{1})
plot(var_overlay(itime,:,2),z,'linewidth',1,'color',color_order{2})
xlabel('Dn_c, Dn_r')
set(gca,'XScale','log')
hold off
end
annotation('textbox',[.7 .7 .2 .2],'String',...
sprintf('t = %.1f s', real_time),'FitBoxToText','on')
% title(sprintf('t = %.0f s', real_time))
cdata = print('-RGBImage','-r144');
F(iframe) = im2frame(cdata);
%F(real_time) = getframe(gcf);
disp(['time=' num2str(real_time)])
delete(findall(gcf,'type','annotation'))
% title('') cmaps
end
% tic
test = F;
if isempty(var1_str)
saveVid(F,[fn, 'DSD', pltflag, ' ',...
num2str(ti) '-', num2str(tf)], 30)
else
saveVid(F,[fn, 'DSD', pltflag, ' ',...
var1_str{ivar1} ' ' var2_str{ivar2}, ...
' ', num2str(ti) '-', num2str(tf)], 30)
end
%v = VideoWriter(['vids/time progress in DSD', pltflag, ' ',...
% var1_str{ivar1} ' ' var2_str{ivar2} ' ' fn,...
% 'profile.mp4'],'MPEG-4');
%v.FrameRate=60;
%open(v)
%writeVideo(v,F)
%close(v)
% finishingTaskSound
end