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

Contents 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.10 - (show annotations) (download)
Sat Nov 19 15:22:40 2016 UTC (8 years, 8 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.9: +8 -1 lines
- grid_load.m: remove call to gcmfaces_lines_zonal and gcmfaces_lines_transp
- calc_MeridionalTransport.m, calc_mermean_T.m, calc_overturn.m, calc_zonmean_T.m,
  calc_zonmedian_T.m, gcmfaces_section.m, diags_display.m, diags_grid_parms.m, figureL.m,
  example_transports_disp.m: call gcmfaces_lines_zonal and / or gcmfaces_lines_transp to
  initialize LATS_MASKS, LONS_MASKS, or LINES_MASKS if needed.

1 function [FLD]=calc_overturn(fldU,fldV,doFlip,list_factors);
2 %object: compute meridional overturning streamfunction
3 %inputs: fldU and fldV are the fields of grid point transport
4 %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 %output: FLD is the streamfunction
9 %
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 % the result is converted to Sv, and sign is changed.
13
14 gcmfaces_global;
15
16 if nargin<3; doFlip=1; end;
17 if nargin<4; list_factors={'dh','dz'}; end;
18
19 %check that LATS_MASKS has already been defined:
20 if ~isfield(mygrid,'LATS_MASKS');
21 fprintf('one-time initialization of gcmfaces_lines_zonal: begin\n');
22 gcmfaces_lines_zonal;
23 fprintf('one-time initialization of gcmfaces_lines_zonal: end\n');
24 end;
25
26 %initialize output:
27 n3=max(size(fldU.f1,3),1); n4=max(size(fldV.f1,4),1);
28 FLD=NaN*squeeze(zeros(length(mygrid.LATS_MASKS),n3+1,n4));
29
30 %prepare fldU/fldV:
31 fldU(isnan(fldU))=0; fldV(isnan(fldV))=0;
32
33 dxg=mk3D(mygrid.DXG,fldU); dyg=mk3D(mygrid.DYG,fldU);
34 if size(fldU.f1,3)==length(mygrid.DRF); drf=mk3D(mygrid.DRF,fldU); else; drf=fldU; drf(:)=1; end;
35 facW=drf; facW(:)=1; facS=facW;
36 for ii=1:length(list_factors);
37 tmp1=list_factors{ii};
38 if strcmp(tmp1,'dh'); facW=facW.*dyg; facS=facS.*dxg;
39 elseif strcmp(tmp1,'dz'); facW=facW.*drf; facS=facS.*drf;
40 elseif strcmp(tmp1,'hfac'); facW=facW.*mygrid.hFacW; facS=facS.*mygrid.hFacS;
41 elseif isempty(tmp1); 1;
42 else; fprintf('error in calc_overturn : non supported factor\n'); return;
43 end;
44 end;
45
46 for k4=1:n4;
47 fldU(:,:,:,k4)=fldU(:,:,:,k4).*facW;
48 fldV(:,:,:,k4)=fldV(:,:,:,k4).*facS;
49 end;
50
51 %use array format to speed up computation below:
52 fldU=convert2array(fldU); fldV=convert2array(fldV);
53
54 for iy=1:length(mygrid.LATS_MASKS);
55
56 %get list ofpoints that form a zonal band:
57 mskW=mygrid.LATS_MASKS(iy).mskWedge;
58 vecW=gcmfaces_subset(mskW,fldU);
59 mskS=mygrid.LATS_MASKS(iy).mskSedge;
60 vecS=gcmfaces_subset(mskS,fldV);
61 trsp=nansum(vecW,1)+nansum(vecS,1);
62
63 %store:
64 if doFlip;
65 FLD(iy,1:n3,:)=flipdim(cumsum(flipdim(trsp,2),2),2);
66 else;
67 FLD(iy,2:n3+1,:)=cumsum(trsp,2);
68 end;
69
70 %convert to Sv and change sign:
71 FLD(iy,:,:)=-1e-6*FLD(iy,:,:);
72
73 end;
74
75 if doFlip;
76 FLD(:,end,:)=0;
77 else;
78 FLD(:,1,:)=0;
79 end;
80

  ViewVC Help
Powered by ViewVC 1.1.22