/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_MeridionalTransport.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_MeridionalTransport.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Fri Jun 24 01:55:42 2011 UTC (14 years, 1 month ago) by gforget
Branch: MAIN
Changes since 1.1: +11 -1 lines
- added headers

1 gforget 1.2 function [FLD]=calc_MeridionalTransport(fldU,fldV,LATS_MASKS,varargin);
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     % LATS_MASKS is the set of quasi longitudinal lines along
5     % which transports will integrated (LATS_MASKS should
6     % have been produced by line_zonal_TUV_MASKS.m)
7     %optional: doScaleWithArea, if 1 then multiply fldU by
8     % dyg.*drf.*mygrid.hFacW and accordingly for fldV.
9     % If 0 (default) then it is assumed that those factors
10     % have already been included (e.g. by pkg/diagnostics).
11     %output: FLD is the integrated transport vector (one point per latitude).
12 gforget 1.1
13     global mygrid;
14    
15     if nargin==4; doScaleWithArea=varargin{1}; else; doScaleWithArea=0; end;
16    
17     %initialize output:
18     n3=max(size(fldU.f1,3),1); n4=max(size(fldV.f1,4),1);
19     FLD=NaN*squeeze(zeros(length(LATS_MASKS),n4));
20    
21     %prepare fldU/fldV:
22     fldU(isnan(fldU))=0; fldV(isnan(fldV))=0;
23    
24     if doScaleWithArea;
25     dxg=mk3D(mygrid.DXG,fldU); dyg=mk3D(mygrid.DYG,fldU); drf=mk3D(mygrid.DRF,fldU);
26     for k4=1:n4;
27     fldU(:,:,:,k4)=fldU(:,:,:,k4).*dyg.*drf.*mygrid.hFacW;
28     fldV(:,:,:,k4)=fldV(:,:,:,k4).*dxg.*drf.*mygrid.hFacS;
29     end;
30     end;
31    
32     %use array format to speed up computation below:
33     fldU=convert2array(fldU); fldV=convert2array(fldV);
34     n1=size(fldU,1); n2=size(fldU,2);
35     fldU=reshape(fldU,n1*n2,n3*n4); fldV=reshape(fldV,n1*n2,n3*n4);
36    
37     for iy=1:length(LATS_MASKS);
38    
39     %get list ofpoints that form a zonal band:
40     mmu=convert2array(LATS_MASKS(iy).mmu);
41     nnu=find(~isnan(mmu)); mmu=mmu(nnu)*ones(1,n3*n4);
42     mmv=convert2array(LATS_MASKS(iy).mmv);
43     nnv=find(~isnan(mmv)); mmv=mmv(nnv)*ones(1,n3*n4);
44    
45     %do the area weighed average along this band:
46     tmpu=sum(fldU(nnu,:).*mmu,1);
47     tmpv=sum(fldV(nnv,:).*mmv,1);
48    
49     %store:
50     FLD(iy,:)=reshape(sum(tmpu+tmpv,2),[1 n4]);
51    
52     end;
53    
54    

  ViewVC Help
Powered by ViewVC 1.1.22