fixing ndt boundary conditions tile and domain bounds, adding debug prints
[wrf-fire-matlab.git] / detection / doy2date.m
blob42e47a79bac3277abd56bf4281d79469fc4a33a2
1 function d=doy2date(s)
2 % convert geotime string yyjjjhhmmss to date string
3 dayspermonth = [0 31 28 31 30 31 30 31 31 30 31 30 31];
4 year=str2num(s(1:2));
5 dayofyear=str2num(s(3:5));
6 hours=str2num(s(6:7));
7 minutes=str2num(s(8:9));
8 seconds=str2num(s(10:11));
9 if mod(year,4)==0 & mod(year,100) ~=0,
10     dayspermonth(2)=29; % leap year
11 end
12 c = cumsum(dayspermonth);
13 idx=find(dayofyear<=c);
14 if isempty(idx),
15     error('bad day of the year')
16 end
17 month = idx(1)-1;
18 dayofmonth = dayofyear - c(month);
19 d = datestr([year+2000,month,dayofmonth,hours,minutes,seconds]);
20 end