-
Notifications
You must be signed in to change notification settings - Fork 1
/
Heat_Budget_Plot_ZonalAverage.m
284 lines (245 loc) · 9.16 KB
/
Heat_Budget_Plot_ZonalAverage.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
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
% This script makes plots of the heat budget in the MOM
% simulations.
close all;
clear all;
base = '/srv/ccrc/data03/z3500785/mom/mat_data/';
RUNS = { ...
% MOM01-SIS:
% $$$ {'MOM01',[4567]}, ...
% $$$ % MOM025-SIS:
% $$$ {'MOM025_kb3seg',[101120],'(a) MOM025 Control'}, ...
% $$$ {'MOM025',[15:19]}, ...
% $$$ {'MOM025_kb1em5',[95:99]}, ...
% $$$ {'MOM025_kb1em6',[30]}, ...
% $$$ % ACCESS-OM2 Gadi runs:
% $$$ {'ACCESS-OM2_1deg_jra55_ryf',[31],'(b) ACCESS-OM2-1-KDS50'}, ...
% $$$ {'ACCESS-OM2_1deg_jra55_ryf_gfdl50',[31]}, ...
% $$$ {'ACCESS-OM2_1deg_jra55_ryf_kds75',[3135]}, ...
% $$$ {'ACCESS-OM2_1deg_jra55_ryf_kds100',[3135]}, ...
% $$$ {'ACCESS-OM2_1deg_jra55_ryf_kds135',[3135],'(c) ACCESS-OM2-1-KDS135'}, ...
% $$$ {'ACCESS-OM2_025deg_jra55_ryf',[7680],'ACCESS-OM2-025-RG'}, ...
% $$$ {'ACCESS-OM2_025deg_jra55_ryf8485_gmredi',[73]}, ...
{'ACCESS-OM2_025deg_jra55_ryf_norediGM',[7680],'ACCESS-OM2-025'}, ...
% $$$ {'ACCESS-OM2_025deg_jra55_ryf_noGM',[7680],'ACCESS-OM2-025-R'}, ...
% $$$ {'ACCESS-OM2_025deg_jra55_ryf',[80]}, ...
% $$$ {'ACCESS-OM2_025deg_jra55_ryf',[300]}, ...
% $$$ {'ACCESS-OM2_01deg_jra55_ryf',[636639],'(f) ACCESS-OM2-01'}, ...
% $$$ {'ACCESS-OM2_01deg_jra55_ryf_k_smag_iso3',[640643],'(f) ACCESS-OM2-01'}, ...
};
doZAremap = 1; % remap too depth.
subCont = 1; % subtract control and plot anomalies.
for rr = 1:length(RUNS)
outputs = RUNS{rr}{2};
model = RUNS{rr}{1};
label = RUNS{rr}{3};
load([base model sprintf('_output%03d_BaseVars.mat',outputs(1))]);
if (~exist('ndays'))
ndays = diff(time_snap);
end
% Latitude difference vector for plotting per-degree:
dy = [yu(2)-yu(1); diff(yu)]; % (First-element is done by hand - but dy is equal to second).
regions = {'Global'};
regLets = {'G'};
% $$$ if (rr == 6);
% $$$ NUMs = ZA_G.NUM;
% $$$ end
for reg = 1:length(regions)
region = regions{reg}
regLet = regLets{reg};
%% Make Vars
type = 'ZA';
load([base model sprintf('_output%03d_',outputs(1)) region '_' type 'HBud.mat']);
eval(['names = fieldnames(' type ');']); % names in this file
namesEX = {'K33','RED','AHDR','GM','PSIGM','AHDGM','MDS','SIG'}; % extra names that might not exist
namesALL = {names{:},namesEX{:}};
for i=1:length(outputs)
i
load([base model sprintf('_output%03d_',outputs(i)) region '_' type 'HBud.mat']);
for ii=1:length(names)
eval(['ZAR.' names{ii} '(:,:,:,i) = ZA.' names{ii} ';']);
end
for ii=1:length(namesEX) % add extras as zeros if they don't exist
if (~isfield(ZA,namesEX{ii}))
eval(['ZAR.' namesEX{ii} '(:,:,:,i) = zeros(size(ZAR.F(:,:,:,i)));']);
end
end
clear ZA;
% Heat Function:
ZAR.AIadv(:,:,:,i) = ZAR.AHD(:,:,:,i) - rho0*Cp*repmat(Te',[yL 1 tL]).*ZAR.PSI(:,:,:,i); % advective-AI (defined on Te and v-points)
ZAR.AI(:,:,:,i) = ZAR.AIadv(:,:,:,i)+ZAR.AHDGM(:,:,:,i)+ZAR.AHDSUB(:,:,:,i)+ZAR.AHDR(:,:,:,i); % total internal heat content transport
% NaN lats on zAI for convergence calculation (for sub-regions):
NANlats = ZAR.AI(:,end,1) == 0;
ZAR.AI(NANlats,:,:,i) = NaN;
ZAR.JSH(:,:,:,i) = ZAR.JS(:,:,:,i).*repmat(Te',[yL 1 tL])*rho0*Cp;
ZAR.PI(:,:,:,i) = ZAR.P(:,:,:,i) - ZAR.JSH(:,:,:,i);
ZAR.N(:,:,:,i) = ZAR.dHdt(:,:,:,i) - ZAR.dVdt(:,:,:,i).*repmat(Te',[yL 1 tL])*rho0*Cp;
if (doZAremap)
ZAtempS(:,:,i) = ZAtemp;
tempZAS(:,:,i) = tempZA;
rhoZAS(:,:,i) = rhoZA;
end
end
ZAtemp = mean(ZAtempS,3);
tempZA = mean(tempZAS,3);
rhoZA = mean(rhoZAS,3);
% Take annual and mean across outputs:
names = fieldnames(ZAR);
for ii=1:length(names)
eval(['ZAR.' names{ii} ' = monmean(mean(ZAR.' names{ii} ',4),3,ndays);']);
end
% Generate NaNst and NANsu arrays:
ZAR.NaNst = zeros(size(ZAR.F));
ZAR.NaNsu = zeros(size(ZAR.PSI));
for i = 1:(TL+1)
ZAR.NaNst(:,i) = ZAR.F(:,i) == ZAR.F(:,end);
ZAR.NaNsu(:,i) = ZAR.PSI(:,i) == ZAR.PSI(:,end);
end
% Max SST (not monthly, ever) line and add to NaNs (note: on Te):
ZAR.maxTt = zeros(yL,1);ZAR.maxTit = zeros(yL,1);
ZAR.maxTu = zeros(yL,1);ZAR.maxTiu = zeros(yL,1);ZAR.psiTu = zeros(yL,1);
for i = 1:yL
indt = find(ZAR.NaNst(i,:),1,'first');
indu = find(ZAR.NaNsu(i,:),1,'first');
ZAR.maxTit(i) = indt;
ZAR.maxTt(i) = Te(indt);
ZAR.NaNst(i,indt) = 0;
ZAR.maxTiu(i) = indu;
ZAR.maxTu(i) = Te(indu);
ZAR.NaNsu(i,indu) = 0;
ZAR.psiTu(i) = ZAR.PSI(i,indu);
end
% Min SST (monthly - from surface forcing):
% Load SST for plotting:
load([base model sprintf('_output%03d_SurfaceVars.mat',outputs(1))],'SST');
SSTa = SST;
for i=2:length(outputs)
load([base model sprintf('_output%03d_SurfaceVars.mat',outputs(i))],'SST');
SSTa = SSTa+SST;
end
SST = SSTa/length(outputs);
if (~(strcmp(region,'') | strcmp(region,'Global')))
[maskREG,~,~,~,~,~,~] = Heat_Budget_Mask(region,'','',base,model);
else
maskREG = ones(size(SST(:,:,1)));
end
SST = SST.*repmat(maskREG,[1 1 length(SST(1,1,:))]);
SST(SST==0) = NaN;
% $$$ ZAR.minSST = squeeze(min(monmean(SST,3,ndays),[],1)');
% $$$ if (max(ZAR.minSST)>100); ZAR.minSST = ZAR.minSST-273.15; end
% Total MHTs:
ZAR.MHTSUB = ZAR.AHDSUB(:,end);
ZAR.MHTADV = ZAR.AI(:,end);
ZAR.MHTGM = ZAR.AHDGM(:,end);
ZAR.MHTR = ZAR.AHDR(:,end);
ZAR.MHT = ZAR.MHTADV + ZAR.MHTSUB + ZAR.MHTGM + ZAR.MHTR;
% $$$ % Zonal average isotherm depths for remapping:
% $$$ ZAR.
eval(['ZA_' regLet ' = ZAR;']);
clear ZAR;
end %end region loop
% $$$ if (rr == 6)
% $$$ ZA_G.NUM = ZA_G.NUM-NUMs;
% $$$ end
% $$$
%% Calculate total diathermal transport and numerical mixing (special for Atlantic):
[X,Y] = ndgrid(yt,Te);
% Add KPPNL for old processing files:
if (~isfield(ZA_G,'KPPNL'))
ZA_G.KPPNL = 0*ZA_G.M;
end
% Global:
dAI_mR_dphi = diff(cat(1,zeros(1,TL+1),ZA_G.AI-ZA_G.AHDR),[],1); % convergence of that transport
ZA_G.Jdia = -ZA_G.N-dAI_mR_dphi; % total diathermal transport
ZA_G.I = -(ZA_G.Jdia+ZA_G.M+ZA_G.KPPNL+ZA_G.F+ZA_G.PI+ZA_G.RED+ZA_G.K33+ZA_G.MDS+ZA_G.SIG); % numerical mixing (both advective and submesoscale)
if (isfield(ZA_G,'NUM_SUBlf'))
ZA_G.NUM = ZA_G.NUM_SUBlf;
end
%% Plot latitude - temperature plane for different basins:
dy = diff(yu);
dy = [dy(1); dy];
% NumMix:
fields = { ...
{'NUM',1./repmat(dy,[1 TL+1])/1e12,'Numerical Mixing',[-25 0],0.5,'TW/$^\circ$latitude'},
{'M',-1./repmat(dy,[1 TL+1])/1e12,'Vertical Mixing',[-25 0],0.5,'TW/$^\circ$latitude'},
};
cpts = cell(1,length(fields));
for i=1:length(fields)
cpts{i} = [-1e10 fields{i}{4}(1):fields{i}{5}:fields{i}{4}(2) 1e10];
end
npts = length(cpts{1});
clab = [1 1 1 1 1 1];
cmap = parula(npts-3);
cmap(end,:) = [0.97 0.97 0.8];
cmap(end-1,:) = (cmap(end-1,:)+cmap(end,:))/2;
AIsp = 0.25;
latfilt = 1;
set(gcf,'Position',[3 40 1278 963]);
set(gcf,'defaulttextfontsize',15);
set(gcf,'defaultaxesfontsize',15);
poss = [0.12 0.39 0.35 0.25; ...
0.5210 0.39 0.35 0.25];
labels = {'(a) Numerical Mixing','(b) Vertical Mixing'};
for i=1:length(fields)
subplot(3,2,2*(rr-1)+i);
if (doZAremap)
X =repmat(yt,[1 TL+1]);
Y = ZAtemp;
else
[X,Y] = ndgrid(yt,Te);
end
eval(['VAR = ZA_' regLets{reg} '.' fields{i}{1} '.*fields{i}{2};']);
if (subCont)
if (rr==1)
VARC = VAR;
else
VAR = VAR-VARC;
end
end
VAR(VAR==0) = NaN;
eval(['VAR(ZA_' regLets{reg} '.NaNst==1) = NaN;']);
VAR = filter_field(VAR',latfilt,'-t')';
contourf(X,Y,VAR,cpts{i},'linestyle','none');
hold on;
col = [0 0 0];
if (doZAremap)
[X,Y] = ndgrid(yt,-z);
[c,h] = contour(X,Y,tempZA,[-2:2:34],'-k');
clabel(c,h);
[c,h] = contour(X,Y,tempZA,[5 15 22.5],'-m','linewidth',1);
else
eval(['plot(yt,filter_field(ZA_' regLets{reg} '.maxTt,latfilt,''-t''),'':k'');']);
end
% $$$ ylim([-2000 0]);
% $$$ text(-79,-1900,labels{i});%,'BackgroundColor','w');%[strrep(model,'_','\_')]);%RUNS{letlabs{letno} ' ' fields{i}{3}]);
ylim([-4000 -500]);
text(-79,-3800,labels{i},'BackgroundColor','w');%[strrep(model,'_','\_')]);%RUNS{letlabs{letno} ' ' fields{i}{3}]);
caxis([-25 0]);%fields{i}{4});
box on;
grid on;
letno = rr;%3*(i-1)+r;
xlim([-80 80]);
set(gca,'xtick',[-90:30:90]);
xlabel('Latitude ($^\circ$N)');
if (i == 1)
ylabel('Depth (m)');
else
set(gca,'yticklabel',[]);
cb = colorbar;
ylabel(cb,fields{i}{6});
end
set(gca,'color','k');
set(gca,'Position',poss(i,:));
gca2 = copyobj(gca,gcf);
axes(gca2);
colorbar off;
pos = poss(i,:);
pos(2) = pos(2)+pos(4);
pos(4) = pos(4)/4*3;
set(gca2,'Position',pos);
set(gca2,'xticklabel',[]);
xlabel(gca2,'');
ylabel(gca2,'');
ylim([-500 0]);
end
colormap(cmap);
end