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

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

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


Revision 1.6 - (hide annotations) (download)
Fri Nov 18 15:45:25 2016 UTC (8 years, 8 months ago) by gforget
Branch: MAIN
Changes since 1.5: +3 -1 lines
- calc_zonmean_T.m, calc_zonmedian_T.m, calc_mermean_T.m: fix case when mm can be empty
  (issue reported by A. Nguyen).

1 gforget 1.3 function [FLD]=calc_zonmedian_T(fld);
2 gforget 1.2 %object: compute zonal median
3     %inputs: fld is the field of interest
4     %output: FLD is the zonal median field
5 gforget 1.3 %
6     %notes: mygrid.LATS_MASKS is the set of quasi longitudinal lines along which
7     % medians will be 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.3 FLD=NaN*squeeze(zeros(length(mygrid.LATS_MASKS),n3,n4));
14 gforget 1.1
15 gforget 1.4 %apply mask:
16     nr=size(mygrid.mskC.f1,3);
17     if n3==nr;
18     for i4=1:n4; fld(:,:,:,i4)=fld(:,:,:,i4).*mygrid.mskC; end;
19     else;
20     for i3=1:n3; for i4=1:n4; fld(:,:,i3,i4)=fld(:,:,i3,i4).*mygrid.mskC(:,:,1); end; end;
21     end;
22    
23 gforget 1.1 %use array format to speed up computation below:
24 gforget 1.4 fld=convert2array(fld);
25 gforget 1.1 n1=size(fld,1); n2=size(fld,2);
26     fld=reshape(fld,n1*n2,n3*n4);
27    
28 gforget 1.3 for iy=1:length(mygrid.LATS_MASKS);
29 gforget 1.1
30     %get list ofpoints that form a zonal band:
31 gforget 1.5 mm=convert2array(mygrid.LATS_MASKS(iy).mskCedge);
32     mm=find(~isnan(mm)&mm~=0);
33 gforget 1.1
34     %do the median along this band:
35     tmp1=nanmedian(fld(mm,:),1);
36    
37     %store:
38 gforget 1.6 if ~isempty(mm);
39     FLD(iy,:,:)=reshape(tmp1,n3,n4);
40     end;
41 gforget 1.1
42     end;
43    
44    

  ViewVC Help
Powered by ViewVC 1.1.22