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

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

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


Revision 1.8 - (hide annotations) (download)
Fri Mar 20 14:17:21 2015 UTC (10 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q
Changes since 1.7: +2 -1 lines
- fix case of n4 greater than 1.

1 gforget 1.7 function [FLD,X,Y]=calc_zonmean_T(fld);
2 gforget 1.3 %object: compute zonal mean
3     %inputs: fld is the field of interest
4     %output: FLD is the zonal mean field
5 gforget 1.4 %
6     %notes: mygrid.LATS_MASKS is the set of quasi longitudinal lines along which
7     % means will computed, as computed in gcmfaces_lines_zonal
8 gforget 1.1
9     global mygrid;
10    
11     %initialize output:
12     n3=max(size(fld.f1,3),1); n4=max(size(fld.f1,4),1);
13 gforget 1.4 FLD=NaN*squeeze(zeros(length(mygrid.LATS_MASKS),n3,n4));
14 gforget 1.1
15     %use array format to speed up computation below:
16 gforget 1.7 fld=convert2array(fld);
17     n1=size(fld,1); n2=size(fld,2);
18     fld=reshape(fld,n1*n2,n3*n4);
19 gforget 1.1 rac=reshape(convert2array(mygrid.RAC),n1*n2,1)*ones(1,n3*n4);
20 gforget 1.7 if n3==length(mygrid.RC);
21 gforget 1.8 hFacC=reshape(convert2array(mygrid.hFacC),n1*n2,n3);
22     hFacC=repmat(hFacC,[1 n4]);
23 gforget 1.7 else;
24     hFacC=reshape(convert2array(mygrid.mskC(:,:,1)),n1*n2,1)*ones(1,n3*n4);
25     hFacC(isnan(hFacC))=0;
26 gforget 1.1 end;
27 gforget 1.6 %masked area only:
28     rac(isnan(fld))=0;
29     hFacC(isnan(fld))=0;
30     fld(isnan(fld))=0;
31    
32 gforget 1.1 rac=rac.*hFacC;
33     fld=fld.*rac;
34    
35 gforget 1.7 for iy=1:length(mygrid.LATS_MASKS);
36    
37     %get list ofpoints that form a zonal band:
38     mm=convert2array(mygrid.LATS_MASKS(iy).mskCedge);
39     mm=find(~isnan(mm)&mm~=0);
40    
41     %do the area weighed average along this band:
42     tmp1=sum(fld(mm,:),1);
43     tmp2=sum(rac(mm,:),1);
44     tmp2(tmp2==0)=NaN;
45     tmp1=tmp1./tmp2;
46    
47     %store:
48     FLD(iy,:,:)=reshape(tmp1,n3,n4);
49    
50     end;
51 gforget 1.1
52 gforget 1.7 X=[]; Y=[];
53     if size(FLD,2)==length(mygrid.RC);
54     X=mygrid.LATS*ones(1,length(mygrid.RC));
55     Y=ones(length(mygrid.LATS),1)*(mygrid.RC');
56     elseif size(FLD,2)==1;
57     X=mygrid.LATS;
58     Y=ones(length(mygrid.LATS),1);
59     end;
60 gforget 1.1

  ViewVC Help
Powered by ViewVC 1.1.22