/[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.5 - (hide annotations) (download)
Mon Aug 29 16:49:04 2011 UTC (13 years, 11 months ago) by gforget
Branch: MAIN
Changes since 1.4: +2 -2 lines
>> clean up and speed up transport computations.

- added routines
gcmfaces_edge_mask		infer edge masks associated with an interior subdomain mask
gcmfaces_subset			extract subset of unmasked points from field (e.g. for transports)

- modified routines
gcmfaces_lines_zonal	use gcmfaces_edge_mask and make field names in
						LATS_MASKS more explicit (mskCint, mskCedge, etc.)
gcmfaces_lines_transp	same thing for section masks; also remove the
						longer arc masks (we only use the shorter arcs)
calc_zonmean_T			use new names (see gcmfaces_lines_zonal)
calc_zonmedian_T		use new names (see gcmfaces_lines_zonal)
calc_overturn			use new names (see gcmfaces_lines_zonal) and gcmfaces_subset
calc_MeridionalTransport use new names (see gcmfaces_lines_zonal) and gcmfaces_subset
calc_transports			use new names (see gcmfaces_lines_transp) and gcmfaces_subset
disp_transport			fix case of a single record

1 gforget 1.4 function [FLD]=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     fld=convert2array(fld);
17     n1=size(fld,1); n2=size(fld,2);
18     fld=reshape(fld,n1*n2,n3*n4);
19     fld(isnan(fld))=0;
20     rac=reshape(convert2array(mygrid.RAC),n1*n2,1)*ones(1,n3*n4);
21     if n3==length(mygrid.RC);
22     hFacC=reshape(convert2array(mygrid.hFacC),n1*n2,n3*n4);
23     else;
24 gforget 1.2 hFacC=reshape(convert2array(mygrid.mskC(:,:,1)),n1*n2,1)*ones(1,n3*n4);
25     hFacC(isnan(hFacC))=0;
26 gforget 1.1 end;
27     rac=rac.*hFacC;
28     fld=fld.*rac;
29    
30 gforget 1.2 %masked area only:
31     rac(isnan(fld))=0;
32 gforget 1.1
33 gforget 1.4 for iy=1:length(mygrid.LATS_MASKS);
34 gforget 1.1
35     %get list ofpoints that form a zonal band:
36 gforget 1.5 mm=convert2array(mygrid.LATS_MASKS(iy).mskCedge);
37     mm=find(~isnan(mm)&mm~=0);
38 gforget 1.1
39     %do the area weighed average along this band:
40     tmp1=sum(fld(mm,:),1);
41     tmp2=sum(rac(mm,:),1);
42     tmp2(tmp2==0)=NaN;
43     tmp1=tmp1./tmp2;
44    
45     %store:
46     FLD(iy,:,:)=reshape(tmp1,n3,n4);
47    
48     end;
49    
50    

  ViewVC Help
Powered by ViewVC 1.1.22