1 |
function HT = calcHeatTransDirect(varargin) |
2 |
|
3 |
% HT = calcHeatTransDirect(d,g,dE,GM,time,flu,blkFile,[mask,phi_ref]); |
4 |
% |
5 |
% Input arguements: |
6 |
% The incoming field data (d) and grid data (g) must be in a structured |
7 |
% array format (which is the format that comes from rdmnc): |
8 |
% d [Structure] Various inputs depending on oceanic or |
9 |
% atmospheric computation, rstar or not, |
10 |
% and GM form/ouputs |
11 |
% g [Structure] drF,dxG,dyG,dxC,dyC,HFacW,HFacS,rA |
12 |
% dE [Structure] More field data |
13 |
% GM [Structure] Gent anf McWilliams data |
14 |
% Other input parameters: |
15 |
% time [vector] Time levels to analyze ([] for all) |
16 |
% flu [string] 'O' or 'A' for ocean or atmosphere |
17 |
% blkFile [string] Broken line file (eg 'isoLat_cs32_59.mat') |
18 |
% Optional parameters: |
19 |
% mask [Structure] W and S mask |
20 |
% phi_ref [vector] Reference geopotential height |
21 |
% |
22 |
% Output: |
23 |
% HT_Out is a structured array with the following fields: |
24 |
% time ([nt,1]) Time axis |
25 |
% ylatHT ([ny,1]) Heat transport latitude axis |
26 |
% ylatSF ([ny-1,1]) Implied heating latitude axis |
27 |
% AreaZon ([ny,1]) Area in zonal bands |
28 |
% SenHT ([ny,nBas,nt,nFld]) Sensible heat transport |
29 |
% SenSF ([ny-1,nBas,nt,nFld]) Implied heating above |
30 |
% LatHT ([ny,nBas,nt,nFld]) Latent heat transport (atm only) |
31 |
% LatSF ([ny-1,nBas,nt,nFld]) Implied heating from aboce (atm only) |
32 |
% Currently, the routine is only configured to handle the global basin, |
33 |
% so nBas = 1 for the output. ny is defined by the broken line file used |
34 |
% for the cube calculation. nFld is the heat transport component: |
35 |
% nFld = 1 = Eulerian circulation HT |
36 |
% nFld = 2 = HT by time mean circulation |
37 |
% nFld = 3 = Residual [3=1-2] |
38 |
% nFld = 4 = HT by zonal mean circulation |
39 |
% nFld = 5 = Residual [5=2-4] |
40 |
% Ocn only: |
41 |
% If GM advective form: |
42 |
% nFld = 6 = HT by horizontal diffusion |
43 |
% If Skew flux form: |
44 |
% nFld = 6 = total (GM+Redi) eddy transport |
45 |
% nFld = 7 = GM (advective) eddy transport |
46 |
% |
47 |
% Description: |
48 |
% Calculation heat transport, and to degree possible, decomposition. |
49 |
% Heat transport is given in PW and the implied surface heating/flux |
50 |
% in W/m^2. The incoming data arrays are all assumed to be of the |
51 |
% dimensions [6*nc,nc,nr,nt]. |
52 |
% |
53 |
% Original Author: Jean-Michel Campin |
54 |
% Modifications: Daniel Enderton |
55 |
|
56 |
% Default constants |
57 |
LhVap = 2501; |
58 |
grav = 9.81; |
59 |
CpO = 3994; |
60 |
RhoO = 1030; |
61 |
CpA = 1004; |
62 |
kappa = 2/7; |
63 |
masking=0; |
64 |
|
65 |
PHIref = grav * [ 431.199 2105.998 5536.327 10440.915 18190.889]; |
66 |
%PHIref = grav * [ 173.888 529.598 896.724 1276.210 1669.052 ... |
67 |
% 2076.380 2499.554 2940.137 3399.937 3881.061 ... |
68 |
% 4385.993 4917.689 5480.084 6078.962 6722.700 ... |
69 |
% 7420.744 8183.151 9023.181 9959.131 11019.028... |
70 |
% 12253.003 13723.604 15599.238 18412.089 24539.570]; |
71 |
|
72 |
% Read input parameters. |
73 |
d = varargin{1}; |
74 |
g = varargin{2}; |
75 |
dE= varargin{3}; |
76 |
GM= varargin{4}; |
77 |
nt= varargin{5}; |
78 |
flu = varargin{6}; |
79 |
blkFile = varargin{7}; |
80 |
if length(varargin) >= 8 & ~isempty(varargin{8}) |
81 |
mask = varargin{8}; |
82 |
masking = 1; |
83 |
disp('Masking is on...') |
84 |
end |
85 |
if length(varargin) == 9 |
86 |
PHIref= varargin{9}; |
87 |
end |
88 |
|
89 |
nBas = 0; |
90 |
if isequal(flu,'A'), nout = 5; end |
91 |
if isequal(flu,'O'), nout = 7; end |
92 |
flag_tot=0; |
93 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
94 |
% Prepare / reform incoming data % |
95 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96 |
|
97 |
% Determine time indecies. |
98 |
%if isempty(time), time = d.iters_read_from_file; i_time = 1:length(time); |
99 |
%else [dump,i_time] = ismember(time,d.iters_read_from_file); end |
100 |
|
101 |
nc = size(g.HFacC,2); |
102 |
nr = size(g.HFacC,3); |
103 |
i_time=1:nt; |
104 |
|
105 |
if nr~=5 |
106 |
LhVap = 2500e3; |
107 |
grav = 9.79764; |
108 |
RDGAS = 287.04; |
109 |
CpA = RDGAS/kappa; |
110 |
end |
111 |
|
112 |
ac = reshape(g.rA ,[6*nc*nc, 1]); |
113 |
hw = reshape(g.HFacW(1:6*nc,1:nc,1:nr),[6*nc*nc,nr]); |
114 |
hs = reshape(g.HFacS(1:6*nc,1:nc,1:nr),[6*nc*nc,nr]); |
115 |
dxc = reshape(g.dxC(1:6*nc,1:nc) ,[6*nc*nc, 1]); |
116 |
dyc = reshape(g.dyC(1:6*nc,1:nc) ,[6*nc*nc, 1]); |
117 |
dxg = reshape(g.dxG(1:6*nc,1:nc) ,[6*nc*nc, 1]); |
118 |
dyg = reshape(g.dyG(1:6*nc,1:nc) ,[6*nc*nc, 1]); |
119 |
drf = reshape(g.drF,[1,length(g.drF)]); |
120 |
Z = reshape(g.Z,[1,length(g.Z)]); |
121 |
|
122 |
%u = reshape(d.UVEL(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
123 |
%v = reshape(d.VVEL(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
124 |
ut = reshape(dE.UTHMASS(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
125 |
vt = reshape(dE.VTHMASS(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
126 |
hu = reshape(dE.UVELMASS(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
127 |
hv = reshape(dE.VVELMASS(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
128 |
t = d.THETA(1:6*nc,1:nc,:,i_time); |
129 |
if isequal(flu,'O') |
130 |
Kux = reshape(GM.GM_Kux(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
131 |
Kvy = reshape(GM.GM_Kvy(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
132 |
|
133 |
if isfield(GM,'GM_ubT') %%% if advective form of GM |
134 |
UbTgm = reshape(GM.GM_ubT(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
135 |
VbTgm = reshape(GM.GM_vbT(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
136 |
elseif isfield(GM,'GM_KuzTz') %%% if skew-flux form of GM |
137 |
UbTgm = reshape(GM.GM_KuzTz(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
138 |
VbTgm = reshape(GM.GM_KvzTz(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
139 |
elseif isfield(dE,'ADVx_TH') %%% if total advective field |
140 |
flag_tot = 1; |
141 |
UbTgm = reshape(dE.ADVx_TH(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
142 |
VbTgm = reshape(dE.ADVy_TH(1:6*nc,1:nc,:,i_time),[6*nc*nc,nr,nt]); |
143 |
else |
144 |
UbTgm = zeros(6*nc*nc,nr,nt); |
145 |
VbTgm = zeros(6*nc*nc,nr,nt); |
146 |
end |
147 |
end |
148 |
|
149 |
if isequal(flu,'A') |
150 |
up = reshape(dE.UVELPHI(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
151 |
vp = reshape(dE.VVELPHI(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
152 |
uq = reshape(dE.USLTMASS(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
153 |
vq = reshape(dE.VSLTMASS(1:6*nc,1:nc,:,i_time) ,[6*nc*nc,nr,nt]); |
154 |
q = d.SALT(1:6*nc,1:nc,:,i_time); |
155 |
p = d.PHIHYD(1:6*nc,1:nc,:,i_time); |
156 |
ut = ut .* ( repmat(Z,[6*nc*nc 1 nt]) / 1e5 ).^kappa; |
157 |
vt = vt .* ( repmat(Z,[6*nc*nc 1 nt]) / 1e5 ).^kappa; |
158 |
t = t .* ( repmat(reshape(Z,[1 1 nr]),[6*nc nc 1 nt]) / 1e5 ).^kappa; |
159 |
end |
160 |
|
161 |
if masking == 1 |
162 |
hu = repmat(reshape(mask.maskW(:,:,1),6*nc*nc,1),[1 nr nt]) .* hu; |
163 |
hv = repmat(reshape(mask.maskS(:,:,1),6*nc*nc,1),[1 nr nt]) .* hv; |
164 |
ut = repmat(reshape(mask.maskW(:,:,1),6*nc*nc,1),[1 nr nt]) .* ut; |
165 |
vt = repmat(reshape(mask.maskS(:,:,1),6*nc*nc,1),[1 nr nt]) .* vt; |
166 |
if isequal(flu,'O') |
167 |
Kux = repmat(reshape(mask.maskW(:,:,1),6*nc*nc,1),[1 nr nt]) .* Kux; |
168 |
Kvy = repmat(reshape(mask.maskS(:,:,1),6*nc*nc,1),[1 nr nt]) .* Kvy; |
169 |
UbTgm = repmat(reshape(mask.maskW(:,:,1),6*nc*nc,1),[1 nr nt]) .* UbTgm; |
170 |
VbTgm = repmat(reshape(mask.maskS(:,:,1),6*nc*nc,1),[1 nr nt]) .* VbTgm; |
171 |
end |
172 |
end |
173 |
|
174 |
|
175 |
% Load broken line information. Compute (tracer point) cell area between |
176 |
% broken lines for each basin. There are nbkl broken lines and nbkl+1 |
177 |
% bands between broken lines. The variable "bkl_Zon" gives the zone number |
178 |
% (nbkl+1 total) for a given index between 0 and nbkl, that is, nbkl+1 |
179 |
% total zones. Comments block is for eventual addition of multiple basin |
180 |
% calculations. |
181 |
load(blkFile); |
182 |
ydim=length(bkl_Ylat); |
183 |
AreaZon=zeros(ydim+1,1+nBas); |
184 |
for j = 1:ydim+1 |
185 |
izon = find(bkl_Zon == j-1); |
186 |
AreaZon(j,1) = sum(ac(izon)); |
187 |
% for b = 1:nBas, |
188 |
% tmp = ac.*mskBc(:,b); |
189 |
% AreaZon(j,1+b) = sum(tmp(izon)); |
190 |
% end |
191 |
end |
192 |
|
193 |
% Latitute plotting information. Average latitude of a broken line |
194 |
% (ylatHF) is calculated from a mean value of the y value of all the edges. |
195 |
% The latitude at the surface flux points is a mean of the broken line mean |
196 |
% values. |
197 |
YlatAv=sum(bkl_Ysg,1)./(1+bkl_Npts'); %' |
198 |
ylatHT = [-90,YlatAv,90]; |
199 |
ylatSF = ( ylatHT(2:ydim+2) + ylatHT(1:ydim+1) )./2; |
200 |
|
201 |
% The variable "bkl_Flg" is -1/1 if edge (on a given broken) has a u point |
202 |
% and -2/2 if it has a v point. Positive/negative values contribute |
203 |
% positively/negatively to northward heat transport (this depends on the |
204 |
% orientation of the cell). A zero value indicates an end of edges that |
205 |
% contribute to a broken line. The u and v information is parced into two |
206 |
% seperate fields, ufac and vfac (-2/2 are reduced to -1/1 for vfac). |
207 |
ufac = zeros([size(bkl_Flg),1+nBas]); |
208 |
vfac = zeros([size(bkl_Flg),1+nBas]); |
209 |
ufac(:,:,1) = rem(bkl_Flg,2); |
210 |
vfac(:,:,1) = fix(bkl_Flg/2); |
211 |
% for jl=1:ydim, |
212 |
% ie=bkl_Npts(jl); |
213 |
% for b=1:nBas, |
214 |
% ufac(1:ie,jl,1+b)=mskBw(bkl_IJuv(1:ie,jl),b).*ufac(1:ie,jl,1); |
215 |
% vfac(1:ie,jl,1+b)=mskBs(bkl_IJuv(1:ie,jl),b).*vfac(1:ie,jl,1); |
216 |
% end |
217 |
% end |
218 |
ufacabs = abs(ufac); |
219 |
vfacabs = abs(vfac); |
220 |
|
221 |
% Prepare mask(s). |
222 |
% ??? I temporarily took out the code to configure the masks beyond this |
223 |
% global one. Does this need to account for a ridge if present? |
224 |
mskG=ones(ydim+1,1+nBas); |
225 |
|
226 |
% Area factors. "ArW_Dif" and "ArS_Dif" the areas for the western and |
227 |
% southern edge of cells, respectively The "_Dif" suffix indicates the |
228 |
% areas used for the diffusivity because there is an extra "dxc" or "dyc" |
229 |
% from the gradient (here for computational efficiency reasons). The |
230 |
% division by "dxc" and "dyc" is associates with gradient of temperature. |
231 |
% |
232 |
% ??? Why is the land mask (hw and hs) only in the diffusive area term? |
233 |
ArW = dyg*reshape(drf,[1,length(drf)]); |
234 |
ArS = dxg*reshape(drf,[1,length(drf)]); |
235 |
ArW_Dif=hw.*((dyg./dxc)*reshape(drf,[1,length(drf)])); |
236 |
ArS_Dif=hs.*((dxg./dyc)*reshape(drf,[1,length(drf)])); |
237 |
|
238 |
% Compute the temperature and its gradient and the velocity points: |
239 |
% tbi/tdi = temperature between/difference i points (at u points) |
240 |
% tbj/tdj = temperature between/difference j points (at v points) |
241 |
% The cube is first split and the extra points are added to the files. |
242 |
% Then the means and differences are taken. Note that the division of dxc |
243 |
% and dyc for the gradient is not applied until later for computational |
244 |
% efficiency purposes. The arrays are then croped and reshaped to the |
245 |
% format for the other field variables, [6*nc*nc,nr]. Note that the |
246 |
% split_C_cub function adds a row/column of tracer points in front of the |
247 |
% first row/column of the tile matries. This, when the differences and |
248 |
% gradients are computed and cropped, the off indecies are selected from |
249 |
% [2:nc+1] rather than [1:nc]. (This was a bit mystifying to me). |
250 |
t6bi=zeros(nc,nc+1,nr,nt,6); t6di=t6bi; q6bi=t6bi; |
251 |
t6bj=zeros(nc+1,nc,nr,nt,6); t6dj=t6bj; q6bj=t6bj; |
252 |
t6t=split_C_cub(t); |
253 |
t6bi([1:nc],:,:,:,:) = ( t6t([1:nc],:,:,:,:) + t6t([2:nc+1],:,:,:,:) )./2; |
254 |
t6bj(:,[1:nc],:,:,:) = ( t6t(:,[1:nc],:,:,:) + t6t(:,[2:nc+1],:,:,:) )./2; |
255 |
t6di([1:nc],:,:,:,:) = ( t6t([1:nc],:,:,:,:) - t6t([2:nc+1],:,:,:,:) ); |
256 |
t6dj(:,[1:nc],:,:,:) = ( t6t(:,[1:nc],:,:,:) - t6t(:,[2:nc+1],:,:,:) ); |
257 |
tbi = t6bi([1:nc],[2:nc+1],:,:,:); |
258 |
tbj = t6bj([2:nc+1],[1:nc],:,:,:); |
259 |
tdi = t6di([1:nc],[2:nc+1],:,:,:); |
260 |
tdj = t6dj([2:nc+1],[1:nc],:,:,:); |
261 |
tbi=reshape(permute(tbi,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
262 |
tbj=reshape(permute(tbj,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
263 |
tdi=reshape(permute(tdi,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
264 |
tdj=reshape(permute(tdj,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
265 |
if isequal(flu,'A') |
266 |
q6t=split_C_cub(q); |
267 |
q6bi([1:nc],:,:,:,:) = (q6t([1:nc],:,:,:,:)+q6t([2:nc+1],:,:,:,:))./2; |
268 |
q6bj(:,[1:nc],:,:,:) = (q6t(:,[1:nc],:,:,:)+q6t(:,[2:nc+1],:,:,:))./2; |
269 |
qbi = q6bi([1:nc],[2:nc+1],:,:,:); |
270 |
qbj = q6bj([2:nc+1],[1:nc],:,:,:); |
271 |
qbi=reshape(permute(qbi,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
272 |
qbj=reshape(permute(qbj,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
273 |
|
274 |
p6t=split_C_cub(p); |
275 |
p6bi([1:nc],:,:,:,:) = (p6t([1:nc],:,:,:,:)+p6t([2:nc+1],:,:,:,:))./2; |
276 |
p6bj(:,[1:nc],:,:,:) = (p6t(:,[1:nc],:,:,:)+p6t(:,[2:nc+1],:,:,:))./2; |
277 |
pbi = p6bi([1:nc],[2:nc+1],:,:,:); |
278 |
pbj = p6bj([2:nc+1],[1:nc],:,:,:); |
279 |
pbi=reshape(permute(pbi,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
280 |
pbj=reshape(permute(pbj,[1,5,2,3,4]),[6*nc*nc,nr,nt]); |
281 |
end |
282 |
|
283 |
% Prepare output arrays. "nout" is the number of transport output fields. |
284 |
% It is currently hard-coded, but could eventually be an input parameters |
285 |
% to set which output fields are desired if some of then become |
286 |
% computationally expensive. |
287 |
% SenHT = Sensible heat transport |
288 |
% SenSF = Sensible implied surface flux |
289 |
% IntV = Integrated volume transport |
290 |
% IntT = Integrated temperature |
291 |
SenHT = zeros(ydim+2,1+nBas,nt,nout); |
292 |
SenSF = zeros(ydim+1,1+nBas,nt,nout); |
293 |
IntV = zeros(ydim,nr,1+nBas,nt); |
294 |
IntT = zeros(ydim,nr,1+nBas,nt); |
295 |
IntM = zeros(ydim,nr,1+nBas,nt); |
296 |
if isequal(flu,'A') |
297 |
LatHT = zeros(ydim+2,1+nBas,nt,nout); |
298 |
PotHT = zeros(ydim+2,1+nBas,nt,nout); |
299 |
LatSF = zeros(ydim+1,1+nBas,nt,nout); |
300 |
IntQ = zeros(ydim,nr,1+nBas,nt); |
301 |
IntP = zeros(ydim,nr,1+nBas,nt); |
302 |
end |
303 |
Psi = zeros(ydim+2,1+nBas,nt); |
304 |
|
305 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
306 |
% Make heat transport calculations % |
307 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
308 |
|
309 |
% Preparation for calculation of zonal average temperature. The |
310 |
% tempereature multiplied by the appropriate length scale ("tbi_temp", |
311 |
% "tbj_temp") is summed up ("IntT" in the next section) and |
312 |
% divided by the total length ("IntM", composed from summing "hw_temp", |
313 |
% "hs_temp"). |
314 |
hw_temp = zeros(size(hw)); |
315 |
hs_temp = zeros(size(hs)); |
316 |
for k=1:nr, |
317 |
hw_temp(:,k) = dyg.*hw(:,k); |
318 |
hs_temp(:,k) = dxg.*hs(:,k); |
319 |
end |
320 |
|
321 |
for it = 1:length(i_time) |
322 |
|
323 |
% uz / vz = Volume transport though cell faces (velocity times area). |
324 |
% Used for zonal mean volume transport (4). |
325 |
% utz1/vtz1 = Eulerian sensible heat transport through cell faces (1). |
326 |
% utz2/vtz2 = Sensible heat transport through cell faces by Eulerian |
327 |
% mean circulations (2). |
328 |
% dtx1/dty1 = Temperatude gradient at cell face times the area (when |
329 |
% multiplied by the diffusion will be the horizontal |
330 |
% diffusion heat transport) (6). |
331 |
uz = ArW.*hu(:,:,it); |
332 |
vz = ArS.*hv(:,:,it); |
333 |
utz1 = sum(ArW.*ut(:,:,it),2); |
334 |
vtz1 = sum(ArS.*vt(:,:,it),2); |
335 |
utz2 = sum(ArW.*hu(:,:,it).*tbi(:,:,it),2); |
336 |
vtz2 = sum(ArS.*hv(:,:,it).*tbj(:,:,it),2); |
337 |
if isequal(flu,'A') |
338 |
uqz1 = sum(ArW.*uq(:,:,it),2); |
339 |
vqz1 = sum(ArS.*vq(:,:,it),2); |
340 |
uqz2 = sum(ArW.*hu(:,:,it).*qbi(:,:,it),2); |
341 |
vqz2 = sum(ArS.*hv(:,:,it).*qbj(:,:,it),2); |
342 |
upz1 = sum(ArW.*(up(:,:,it)+hu(:,:,it).*repmat(PHIref,[6*nc*nc 1])),2); |
343 |
vpz1 = sum(ArS.*(vp(:,:,it)+hv(:,:,it).*repmat(PHIref,[6*nc*nc 1])),2); |
344 |
upz2 = sum(ArW.*hu(:,:,it).*(pbi(:,:,it)+repmat(PHIref,[6*nc*nc 1])),2); |
345 |
vpz2 = sum(ArS.*hv(:,:,it).*(pbj(:,:,it)+repmat(PHIref,[6*nc*nc 1])),2); |
346 |
end |
347 |
if isequal(flu,'O') |
348 |
dtx1 = sum(ArW_Dif.*Kux(:,:,it).*tdi(:,:,it),2); |
349 |
dty1 = sum(ArS_Dif.*Kvy(:,:,it).*tdj(:,:,it),2); |
350 |
Kuztz1 = sum(UbTgm(:,:,it),2); |
351 |
Kvztz1 = sum(VbTgm(:,:,it),2); |
352 |
end |
353 |
|
354 |
% Preparation for calculation of zonal average temperature. The |
355 |
% temperature multiplied by the appropriate length scale ("tbi_temp", |
356 |
% "tbj_temp") is summed up ("IntT" in the next section) and |
357 |
% divided by the total length ("IntM", composed from summing "hw_temp", |
358 |
% "hs_temp"). |
359 |
tbi_temp = hw_temp.*tbi(:,:,it); |
360 |
tbj_temp = hs_temp.*tbj(:,:,it); |
361 |
if isequal(flu,'A') |
362 |
qbi_temp = hw_temp.*qbi(:,:,it); |
363 |
qbj_temp = hs_temp.*qbj(:,:,it); |
364 |
pbi_temp = hw_temp.*(pbi(:,:,it)+repmat(PHIref,[6*nc*nc 1])); |
365 |
pbj_temp = hs_temp.*(pbj(:,:,it)+repmat(PHIref,[6*nc*nc 1])); |
366 |
end |
367 |
|
368 |
% Block 1: |
369 |
% With the vertical integral of heat transport calculated across cell |
370 |
% edges, the zonal integral (along the broken line) is computed to |
371 |
% determine the total northward heat transport. The first for loop is |
372 |
% over the individual broken lines (determining the northward HT at the |
373 |
% representative latitude). The second loop is over the basins. The |
374 |
% third loop is over the individual edges along a specific broken line. |
375 |
% Note that an individual cell can have two edges (u and v) that have a |
376 |
% HT contributions. Hence the variable containing indecies of cells |
377 |
% with edges along the broken lines, "bkl_IJuv", has some repeats. |
378 |
% Note that the variable "bkl_Npts" is the number of edges along a |
379 |
% given broken line. Note also that the latitude axis starts at 2 |
380 |
% because heat transport at extremes (latitute = -90/90) is zero by |
381 |
% definition. Recall that index (1) is total Eulerian transport, (2) |
382 |
% is from the mean circulations, and (3) is from the horizontal |
383 |
% diffusion. |
384 |
% |
385 |
% Block 2: |
386 |
% Here zonal average circulation and temperature / moisture is |
387 |
% calculated. The zonal average volume transport v (IntV) and t |
388 |
% (IntT/IntM) are computed first and are multiplied together at the |
389 |
% end. |
390 |
for jl=1:ydim |
391 |
ie=bkl_Npts(jl); |
392 |
for b=1:1+nBas |
393 |
ij=bkl_IJuv(1:ie,jl); |
394 |
% Block 1: |
395 |
SenHT(1+jl,b,it,1) = SenHT(1+jl,b,it,1) + ... |
396 |
sum(ufac(1:ie,jl,b).*utz1(ij) + ... |
397 |
vfac(1:ie,jl,b).*vtz1(ij)); |
398 |
SenHT(1+jl,b,it,2) = SenHT(1+jl,b,it,2) + ... |
399 |
sum(ufac(1:ie,jl,b).*utz2(ij) + ... |
400 |
vfac(1:ie,jl,b).*vtz2(ij)); |
401 |
if isequal(flu,'A') |
402 |
LatHT(1+jl,b,it,1) = LatHT(1+jl,b,it,1) + ... |
403 |
sum(ufac(1:ie,jl,b).*uqz1(ij) + ... |
404 |
vfac(1:ie,jl,b).*vqz1(ij)); |
405 |
LatHT(1+jl,b,it,2) = LatHT(1+jl,b,it,2) + ... |
406 |
sum(ufac(1:ie,jl,b).*uqz2(ij) + ... |
407 |
vfac(1:ie,jl,b).*vqz2(ij)); |
408 |
PotHT(1+jl,b,it,1) = PotHT(1+jl,b,it,1) + ... |
409 |
sum(ufac(1:ie,jl,b).*upz1(ij) + ... |
410 |
vfac(1:ie,jl,b).*vpz1(ij)); |
411 |
PotHT(1+jl,b,it,2) = PotHT(1+jl,b,it,2) + ... |
412 |
sum(ufac(1:ie,jl,b).*upz2(ij) + ... |
413 |
vfac(1:ie,jl,b).*vpz2(ij)); |
414 |
end |
415 |
if isequal(flu,'O') |
416 |
SenHT(1+jl,b,it,6) = SenHT(1+jl,b,it,6) + ... |
417 |
sum(ufac(1:ie,jl,b).*dtx1(ij) + ... |
418 |
vfac(1:ie,jl,b).*dty1(ij)); |
419 |
SenHT(1+jl,b,it,7) = SenHT(1+jl,b,it,7) + ... |
420 |
sum(ufac(1:ie,jl,b).*Kuztz1(ij) + ... |
421 |
vfac(1:ie,jl,b).*Kvztz1(ij)); |
422 |
end |
423 |
% Block 2: |
424 |
IntV(jl,:,b,it) = IntV(jl,:,b,it) ... |
425 |
+ ufac(1:ie,jl,b)'*uz(ij,:) ... |
426 |
+ vfac(1:ie,jl,b)'*vz(ij,:) ; |
427 |
IntT(jl,:,b,it) = IntT(jl,:,b,it) ... |
428 |
+ ufacabs(1:ie,jl,b)'*tbi_temp(ij,:) ... |
429 |
+ vfacabs(1:ie,jl,b)'*tbj_temp(ij,:); |
430 |
IntM(jl,:,b,it) = IntM(jl,:,b,it) ... |
431 |
+ ufacabs(1:ie,jl,b)'*hw_temp(ij,:) ... |
432 |
+ vfacabs(1:ie,jl,b)'*hs_temp(ij,:); |
433 |
if isequal(flu,'A') |
434 |
IntQ(jl,:,b,it) = IntQ(jl,:,b,it) ... |
435 |
+ ufacabs(1:ie,jl,b)'*qbi_temp(ij,:) ... |
436 |
+ vfacabs(1:ie,jl,b)'*qbj_temp(ij,:); |
437 |
IntP(jl,:,b,it) = IntP(jl,:,b,it) ... |
438 |
+ ufacabs(1:ie,jl,b)'*pbi_temp(ij,:) ... |
439 |
+ vfacabs(1:ie,jl,b)'*pbj_temp(ij,:); |
440 |
end |
441 |
end |
442 |
end |
443 |
|
444 |
% Prepare HT output: Calculate HT by zonal flows and tabulate |
445 |
% residuals. Also, the multiplicative constants (Cp,rho,grav,LhVap) are |
446 |
% applied here to put moisture and potential temperature fluxes in |
447 |
% terms of heat transports. |
448 |
tmp = IntV(:,:,:,it) .* IntT(:,:,:,it) ... |
449 |
./ change(IntM(:,:,:,it),'==',0,NaN); |
450 |
SenHT(2:ydim+1,:,it,4) = sum(change(tmp,'==',NaN,0),2); |
451 |
% SenHT(2:ydim+1,:,it,4) = sum( IntV(:,:,:,it) ... |
452 |
% .* IntT(:,:,:,it) ... |
453 |
% ./ IntM(:,:,:,it),2); |
454 |
SenHT(:,:,it,3) = SenHT(:,:,it,1) - SenHT(:,:,it,2); |
455 |
SenHT(:,:,it,5) = SenHT(:,:,it,2) - SenHT(:,:,it,4); |
456 |
if isequal(flu,'O') |
457 |
% SenHT(:,:,it,6) = DiffKh.*SenHT(:,:,it,6); |
458 |
SenHT(:,:,it,:) = (CpO*RhoO)*SenHT(:,:,it,:); |
459 |
if flag_tot==1 |
460 |
SenHT(:,:,it,7)=SenHT(:,:,it,7)-SenHT(:,:,it,1); |
461 |
end |
462 |
elseif isequal(flu,'A') |
463 |
SenHT(:,:,it,:) = (CpA./grav).*SenHT(:,:,it,:); |
464 |
LatHT(2:ydim+1,:,it,4) = sum( IntV(:,:,:,it) ... |
465 |
.* IntQ(:,:,:,it) ... |
466 |
./ IntM(:,:,:,it),2); |
467 |
LatHT(:,:,it,3) = LatHT(:,:,it,1) - LatHT(:,:,it,2); |
468 |
LatHT(:,:,it,5) = LatHT(:,:,it,2) - LatHT(:,:,it,4); |
469 |
LatHT(:,:,it,:) = (LhVap./grav).*LatHT(:,:,it,:); |
470 |
|
471 |
PotHT(2:ydim+1,:,it,4) = sum( IntV(:,:,:,it) ... |
472 |
.* IntP(:,:,:,it) ... |
473 |
./ IntM(:,:,:,it),2); |
474 |
PotHT(:,:,it,3) = PotHT(:,:,it,1) - PotHT(:,:,it,2); |
475 |
PotHT(:,:,it,5) = PotHT(:,:,it,2) - PotHT(:,:,it,4); |
476 |
PotHT(:,:,it,:) = 1/grav * PotHT(:,:,it,:); |
477 |
end |
478 |
Psi(2:ydim+1,:,it) = - sum( IntV(:,:,:,it) ,2 ); |
479 |
|
480 |
% Implied surface heat flux from heat transports (implied heating). |
481 |
% Tabulated as the difference in heat transports between two broken |
482 |
% lines divided by the zonal band area. |
483 |
mskG = reshape(mskG,(ydim+1)*(1+nBas),1); |
484 |
I = find(mskG==0); |
485 |
mskG = reshape(mskG,ydim+1,1+nBas); |
486 |
var = zeros(ydim+1,1+nBas); |
487 |
for n=1:min(nout,6), |
488 |
varT = SenHT([2:ydim+2],:,it,n) ... |
489 |
- SenHT([1:ydim+1],:,it,n); |
490 |
varT = reshape(varT,(ydim+1)*(1+nBas),1); varT(I)=NaN; |
491 |
varT = reshape(varT,ydim+1,1+nBas); |
492 |
SenSF([1:ydim+1],:,it,n) = varT./AreaZon; |
493 |
if isequal(flu,'A') |
494 |
for n=1:min(nout,6) |
495 |
varQ = LatHT([2:ydim+2],:,it,n) ... |
496 |
- LatHT([1:ydim+1],:,it,n); |
497 |
varQ = reshape(varQ,(ydim+1)*(1+nBas),1); varQ(I)=NaN; |
498 |
varQ = reshape(varQ,ydim+1,1+nBas); |
499 |
LatSF([1:ydim+1],:,it,n) = varQ./AreaZon; |
500 |
end |
501 |
end |
502 |
end |
503 |
end |
504 |
|
505 |
|
506 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
507 |
% Assign outputs, put in units of PW % |
508 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
509 |
|
510 |
SenHT = SenHT*1e-15; |
511 |
|
512 |
HT.time = i_time; |
513 |
HT.SenHT = reshape(SenHT,ydim+2,nt,nout); |
514 |
HT.SenSF = reshape(SenSF,ydim+1,nt,nout); |
515 |
HT.ylatHT = ylatHT; |
516 |
HT.ylatSF = ylatSF; |
517 |
HT.AreaZon = AreaZon; |
518 |
HT.PsiSurf = 1e-6*reshape(Psi,ydim+2,nt); |
519 |
|
520 |
if isequal(flu,'A') |
521 |
LatHT = LatHT*1e-15; |
522 |
PotHT = PotHT*1e-15; |
523 |
HT.LatHT = reshape(LatHT,ydim+2,nt,nout); |
524 |
HT.LatSF = reshape(LatSF,ydim+1,nt,nout); |
525 |
HT.PotHT = reshape(PotHT,ydim+2,nt,nout); |
526 |
end |
527 |
|