1 |
gforget |
1.3 |
function [FLD]=calc_MeridionalTransport(fldU,fldV,varargin); |
2 |
gforget |
1.2 |
%object: compute net meridional transports of e.g. heat or fresh water |
3 |
|
|
%inputs: fldU and fldV are the fields of grid point transport |
4 |
|
|
%optional: doScaleWithArea, if 1 then multiply fldU by |
5 |
gforget |
1.4 |
% dyg.*drf and accordingly for fldV. |
6 |
gforget |
1.2 |
% If 0 (default) then it is assumed that those factors |
7 |
|
|
% have already been included (e.g. by pkg/diagnostics). |
8 |
|
|
%output: FLD is the integrated transport vector (one point per latitude). |
9 |
gforget |
1.3 |
% |
10 |
|
|
%notes: mygrid.LATS_MASKS is the set of quasi longitudinal lines along which |
11 |
|
|
% transports will integrated, as computed in gcmfaces_lines_zonal |
12 |
gforget |
1.1 |
|
13 |
gforget |
1.6 |
gcmfaces_global; |
14 |
gforget |
1.1 |
|
15 |
gforget |
1.3 |
if nargin==3; doScaleWithArea=varargin{1}; else; doScaleWithArea=0; end; |
16 |
gforget |
1.1 |
|
17 |
gforget |
1.6 |
%check that LATS_MASKS has already been defined: |
18 |
|
|
if ~isfield(mygrid,'LATS_MASKS'); |
19 |
|
|
fprintf('one-time initialization of gcmfaces_lines_zonal: begin\n'); |
20 |
|
|
gcmfaces_lines_zonal; |
21 |
|
|
fprintf('one-time initialization of gcmfaces_lines_zonal: end\n'); |
22 |
|
|
end; |
23 |
|
|
|
24 |
gforget |
1.1 |
%initialize output: |
25 |
|
|
n3=max(size(fldU.f1,3),1); n4=max(size(fldV.f1,4),1); |
26 |
gforget |
1.3 |
FLD=NaN*squeeze(zeros(length(mygrid.LATS_MASKS),n4)); |
27 |
gforget |
1.1 |
|
28 |
|
|
%prepare fldU/fldV: |
29 |
|
|
fldU(isnan(fldU))=0; fldV(isnan(fldV))=0; |
30 |
|
|
|
31 |
|
|
if doScaleWithArea; |
32 |
|
|
dxg=mk3D(mygrid.DXG,fldU); dyg=mk3D(mygrid.DYG,fldU); drf=mk3D(mygrid.DRF,fldU); |
33 |
|
|
for k4=1:n4; |
34 |
gforget |
1.4 |
fldU(:,:,:,k4)=fldU(:,:,:,k4).*dyg.*drf; |
35 |
|
|
fldV(:,:,:,k4)=fldV(:,:,:,k4).*dxg.*drf; |
36 |
gforget |
1.1 |
end; |
37 |
|
|
end; |
38 |
|
|
|
39 |
|
|
%use array format to speed up computation below: |
40 |
|
|
fldU=convert2array(fldU); fldV=convert2array(fldV); |
41 |
|
|
|
42 |
gforget |
1.3 |
for iy=1:length(mygrid.LATS_MASKS); |
43 |
gforget |
1.1 |
|
44 |
|
|
%get list ofpoints that form a zonal band: |
45 |
gforget |
1.5 |
mskW=mygrid.LATS_MASKS(iy).mskWedge; |
46 |
|
|
vecW=gcmfaces_subset(mskW,fldU); |
47 |
|
|
mskS=mygrid.LATS_MASKS(iy).mskSedge; |
48 |
|
|
vecS=gcmfaces_subset(mskS,fldV); |
49 |
|
|
|
50 |
|
|
%store vertically integrated transport: |
51 |
|
|
FLD(iy,:)=nansum(nansum(vecW,1)+nansum(vecS,1),2); |
52 |
gforget |
1.1 |
|
53 |
|
|
end; |
54 |
|
|
|
55 |
|
|
|