for lo = 20:91
for la = 1:101
tmplat = latsmall(lo,la);
tmplon = lonsmall(lo,la);
f = find(min((latNLDAS(:)-tmplat).^2+(lonNLDAS(:)-tmplon).^2)==((latNLDAS(:)-tmplat).^2+(lonNLDAS(:)-tmplon).^2));
y = floor(f/224)+1;
y = y(1);
x = mod(f,224);
x = x(1);
for yr = 1:15
tic;
for mo = 1:5
fprintf(' lo %d la %d yr %d mo %d \n',lo,la,yr+1994,mo);
for dy=1:31
pptNL(yr,lo,la,mo,dy)= nan;
if (mo == 2 || 5) && (dy==31)
continue;
else
date = [num2str(mo+4) '/' num2str(dy) '/' num2str(1994+yr)];
if (x-2<=0) || (y-2<=0) || (x-2>224) || (y-2>464) ||...
(x-1<=0) || (y-1<=0) || (x-1>224) || (y-1>464) ||...
(x-0<=0) || (y-0<=0) || (x-0>224) || (y-0>464) ||...
(x+1<=0) || (y+1<=0) || (x+1>224) || (y+1>464) ||...
(x+2<=0) || (y+2<=0) || (x+2>224) || (y+2>464)
continue
else
pptNL(yr,lo,la,mo,dy)= nanmean...
([PRECIP(x-2,y+2,datevec2doy(datevec(date)))...
PRECIP(x-2,y+1,datevec2doy(datevec(date)))...
PRECIP(x-2,y+0,datevec2doy(datevec(date)))...
PRECIP(x-2,y-1,datevec2doy(datevec(date)))...
PRECIP(x-2,y-2,datevec2doy(datevec(date)))...
PRECIP(x-1,y+2,datevec2doy(datevec(date)))...
PRECIP(x-1,y+1,datevec2doy(datevec(date)))...
PRECIP(x-1,y+0,datevec2doy(datevec(date)))...
PRECIP(x-1,y-1,datevec2doy(datevec(date)))...
PRECIP(x-1,y-2,datevec2doy(datevec(date)))...
PRECIP(x,y+2,datevec2doy(datevec(date)))...
PRECIP(x,y+1,datevec2doy(datevec(date)))...
PRECIP(x,y,datevec2doy(datevec(date)))...
PRECIP(x,y-1,datevec2doy(datevec(date)))...
PRECIP(x,y-2,datevec2doy(datevec(date)))...
PRECIP(x+1,y+2,datevec2doy(datevec(date)))...
PRECIP(x+1,y+1,datevec2doy(datevec(date)))...
PRECIP(x+1,y+0,datevec2doy(datevec(date)))...
PRECIP(x+1,y-1,datevec2doy(datevec(date)))...
PRECIP(x+1,y-2,datevec2doy(datevec(date)))...
PRECIP(x+2,y+2,datevec2doy(datevec(date)))...
PRECIP(x+2,y+1,datevec2doy(datevec(date)))...
PRECIP(x+2,y+0,datevec2doy(datevec(date)))...
PRECIP(x+2,y-1,datevec2doy(datevec(date)))...
PRECIP(x+2,y-2,datevec2doy(datevec(date)))...
]);
end
end
end
end
end
end
end