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

Contents 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.7 - (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.6: +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_zonmedian_T(fld);
2 %object: compute zonal median
3 %inputs: fld is the field of interest
4 %output: FLD is the zonal median field
5 %
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
9 gcmfaces_global;
10
11 %check that LATS_MASKS has already been defined:
12 if ~isfield(mygrid,'LATS_MASKS');
13 fprintf('one-time initialization of gcmfaces_lines_zonal: begin\n');
14 gcmfaces_lines_zonal;
15 fprintf('one-time initialization of gcmfaces_lines_zonal: end\n');
16 end;
17
18 %initialize output:
19 n3=max(size(fld.f1,3),1); n4=max(size(fld.f1,4),1);
20 FLD=NaN*squeeze(zeros(length(mygrid.LATS_MASKS),n3,n4));
21
22 %apply mask:
23 nr=size(mygrid.mskC.f1,3);
24 if n3==nr;
25 for i4=1:n4; fld(:,:,:,i4)=fld(:,:,:,i4).*mygrid.mskC; end;
26 else;
27 for i3=1:n3; for i4=1:n4; fld(:,:,i3,i4)=fld(:,:,i3,i4).*mygrid.mskC(:,:,1); end; end;
28 end;
29
30 %use array format to speed up computation below:
31 fld=convert2array(fld);
32 n1=size(fld,1); n2=size(fld,2);
33 fld=reshape(fld,n1*n2,n3*n4);
34
35 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 median along this band:
42 tmp1=nanmedian(fld(mm,:),1);
43
44 %store:
45 if ~isempty(mm);
46 FLD(iy,:,:)=reshape(tmp1,n3,n4);
47 end;
48
49 end;
50
51

  ViewVC Help
Powered by ViewVC 1.1.22