5 |
% dim is the dimension over which the rmw will be applied |
% dim is the dimension over which the rmw will be applied |
6 |
%optional: doCycle states whether the boundary condition is cyclic (1) or |
%optional: doCycle states whether the boundary condition is cyclic (1) or |
7 |
% not (0; default). If doCycle==0, the no. of averaged points |
% not (0; default). If doCycle==0, the no. of averaged points |
8 |
% decreases from 1+2*halfWindow to halfWindow at the edges. |
% decreases from 1+2*halfWindow to halfWindow at the edges, |
9 |
|
% and we mask all of those edge points with NaNs. |
10 |
%output: fldOut is the resulting field |
%output: fldOut is the resulting field |
11 |
% |
% |
12 |
%notes: - NaNs are discarded in the rmw, implying that an average is |
%notes: - NaNs are discarded in the rmw, implying that an average is |
24 |
if nargin==3; doCycle=0; else; doCycle=varargin{1}; end; |
if nargin==3; doCycle=0; else; doCycle=varargin{1}; end; |
25 |
|
|
26 |
%switch to array format if needed |
%switch to array format if needed |
27 |
if fld_isa_gcmfaces; fldOut=convert2array(fldOut); end; |
if fld_isa_gcmfaces; fldIn=convert2array(fldIn); end; |
28 |
|
|
29 |
%switch dim to first dimension |
%switch dim to first dimension |
30 |
sizeIn=size(fldIn); |
sizeIn=size(fldIn); |
63 |
fldCnt=fldCnt+fac*tmp1; |
fldCnt=fldCnt+fac*tmp1; |
64 |
end |
end |
65 |
|
|
66 |
fldCnt(fldCnt==0)=NaN; |
fldCnt(fldCnt<2*halfWindow)=NaN; |
67 |
fldOut=fldOut./fldCnt; |
fldOut=fldOut./fldCnt; |
68 |
|
|
69 |
if ~doCycle; |
if ~doCycle; |