1 |
gforget |
1.1 |
function [FLD]=calc_zonmedian_T(fld,LATS_MASKS); |
2 |
gforget |
1.2 |
%object: compute zonal median |
3 |
|
|
%inputs: fld is the field of interest |
4 |
|
|
% LATS_MASKS is the set of quasi longitudinal lines along |
5 |
|
|
% which transports will integrated (LATS_MASKS should |
6 |
|
|
% have been produced by line_zonal_TUV_MASKS.m) |
7 |
|
|
%output: FLD is the zonal median field |
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 |
|
|
FLD=NaN*squeeze(zeros(length(LATS_MASKS),n3,n4)); |
14 |
|
|
|
15 |
|
|
%use array format to speed up computation below: |
16 |
|
|
fld=convert2array(fld.*mygrid.mskC); |
17 |
|
|
n1=size(fld,1); n2=size(fld,2); |
18 |
|
|
fld=reshape(fld,n1*n2,n3*n4); |
19 |
|
|
|
20 |
|
|
for iy=1:length(LATS_MASKS); |
21 |
|
|
|
22 |
|
|
%get list ofpoints that form a zonal band: |
23 |
|
|
mm=convert2array(LATS_MASKS(iy).mmt); |
24 |
|
|
mm=find(~isnan(mm)); |
25 |
|
|
|
26 |
|
|
%do the median along this band: |
27 |
|
|
tmp1=nanmedian(fld(mm,:),1); |
28 |
|
|
|
29 |
|
|
%store: |
30 |
|
|
FLD(iy,:,:)=reshape(tmp1,n3,n4); |
31 |
|
|
|
32 |
|
|
end; |
33 |
|
|
|
34 |
|
|
|