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

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

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


Revision 1.6 - (hide annotations) (download)
Mon Sep 24 23:05:20 2012 UTC (12 years, 10 months ago) by gforget
Branch: MAIN
Changes since 1.5: +28 -5 lines
- calc_barostream.m : add list_factors argument to accomodate e.g. tracer class transports.
- calc_overturn.m : add doFlip,list_factors args to accomodate e.g. tracer class transports.
- calc_barostream.m : introduce list_factors to allow use for e.g. tracer class transports.
- layers_remap.m (new) : remap variables (e.g. transports) from depth to tracer classes.
                       Uses regrid_dblres.m and regrid_sum.m and mimics pkg/layers.
- regrid_dblres.m (new) : double the resolution (only along 3rd dimension for now)
                       for a variable P (extensive or intensive) a number of times.
- regrid_sum.m (new) : add 3rd dimension elements of extensive variable P,
                       according to values of a tracer field collocated with P,
                       to the tracer grid defined by trGrid (1D vector)

1 gforget 1.6 function [FLD]=calc_overturn(fldU,fldV,doFlip,list_factors);
2 gforget 1.2 %object: compute meridional overturning streamfunction
3     %inputs: fldU and fldV are the fields of grid point transport
4 gforget 1.6 %optional: doFlip (default is 1). If 1 then flip the vertical
5     % axis back and forth, hence intergrating from the
6     % 'bottom'. If 0 then dont.
7     % list_factors (default is {'dh','dz'})
8 gforget 1.2 %output: FLD is the streamfunction
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.6 % the result is converted to Sv, and sign is changed.
13 gforget 1.1
14     global mygrid;
15    
16 gforget 1.6 if nargin<3; doFlip=1; end;
17     if nargin<4; list_factors={'dh','dz'}; end;
18    
19 gforget 1.1 %initialize output:
20     n3=max(size(fldU.f1,3),1); n4=max(size(fldV.f1,4),1);
21 gforget 1.3 FLD=NaN*squeeze(zeros(length(mygrid.LATS_MASKS),n3+1,n4));
22 gforget 1.1
23     %prepare fldU/fldV:
24     fldU(isnan(fldU))=0; fldV(isnan(fldV))=0;
25    
26 gforget 1.6 dxg=mk3D(mygrid.DXG,fldU); dyg=mk3D(mygrid.DYG,fldU);
27     if size(fldU.f1,3)==length(mygrid.DRF); drf=mk3D(mygrid.DRF,fldU); else; drf=fldU; drf(:)=1; end;
28     facW=drf; facW(:)=1; facS=facW;
29     for ii=1:length(list_factors);
30     tmp1=list_factors{ii};
31     if strcmp(tmp1,'dh'); facW=facW.*dyg; facS=facS.*dxg;
32     elseif strcmp(tmp1,'dz'); facW=facW.*drf; facS=facS.*drf;
33     elseif strcmp(tmp1,'hfac'); facW=facW.*mygrid.hFacW; facS=facS.*mygrid.hFacS;
34     elseif isempty(tmp1); 1;
35     else; fprintf('error in calc_UV_div: non supported factor\n'); return;
36     end;
37     end;
38    
39 gforget 1.1 for k4=1:n4;
40 gforget 1.6 fldU(:,:,:,k4)=fldU(:,:,:,k4).*facW;
41     fldV(:,:,:,k4)=fldV(:,:,:,k4).*facS;
42 gforget 1.1 end;
43    
44     %use array format to speed up computation below:
45     fldU=convert2array(fldU); fldV=convert2array(fldV);
46    
47 gforget 1.3 for iy=1:length(mygrid.LATS_MASKS);
48 gforget 1.1
49     %get list ofpoints that form a zonal band:
50 gforget 1.5 mskW=mygrid.LATS_MASKS(iy).mskWedge;
51     vecW=gcmfaces_subset(mskW,fldU);
52     mskS=mygrid.LATS_MASKS(iy).mskSedge;
53     vecS=gcmfaces_subset(mskS,fldV);
54     trsp=sum(vecW,1)+sum(vecS,1);
55 gforget 1.1
56     %store:
57 gforget 1.6 FLD(iy,1:n3,:)=flipdim(cumsum(flipdim(trsp,2),2),2);
58    
59     %convert to Sv and change sign:
60     FLD(iy,1:n3,:)=-1e-6*FLD(iy,1:n3,:);
61 gforget 1.1
62     end;
63    
64     FLD(:,end,:)=0;
65    
66    

  ViewVC Help
Powered by ViewVC 1.1.22