52 |
%apply the running mean |
%apply the running mean |
53 |
fldOut=zeros(sizeCur); |
fldOut=zeros(sizeCur); |
54 |
for tcur=-halfWindow:halfWindow |
for tcur=-halfWindow:halfWindow |
55 |
|
%To have halfWindow*2 coeffs rather than halfWindow*2+1, centered to the current |
56 |
|
%point, it is convenient to reduce the weight of the farthest points to 1/2. |
57 |
|
%This became necessary to get proper annual means, from monthly data, with halfWindow=6. |
58 |
|
if abs(tcur)==halfWindow; fac=1/2; else; fac=1; end; |
59 |
tmp1=circshift(fldIn,[tcur zeros(1,length(sizeCur)-1)]); |
tmp1=circshift(fldIn,[tcur zeros(1,length(sizeCur)-1)]); |
60 |
fldOut=fldOut+tmp1; |
fldOut=fldOut+fac*tmp1; |
61 |
tmp1=circshift(fldMsk,[tcur zeros(1,length(sizeCur)-1)]); |
tmp1=circshift(fldMsk,[tcur zeros(1,length(sizeCur)-1)]); |
62 |
fldCnt=fldCnt+tmp1; |
fldCnt=fldCnt+fac*tmp1; |
63 |
end |
end |
64 |
|
|
65 |
fldCnt(fldCnt==0)=NaN; |
fldCnt(fldCnt==0)=NaN; |