1 function out=add_tign_col(raw,t)
2 % out=add_tign_col(raw,t)
4 % raw spreadsheed loaded by [num,txt,raw]=xlsread('filename.xls')
7 % column 2 is longitude
8 % t structure created from wrfout as follows:
9 % t=read_wrfout_tign('wrfout...')
10 % save t, copy t.mat to another computer if needed, load t
12 % out cell array ready to be written to csh file by
13 % cell2csv(out,'filename.csv')
14 % One column is added with the fire arrival time.
15 % Load the csv file into excel and change the format of the
17 % Copy the other columns from the original file if needed.
21 % [num,txt,raw]=xlsread('AssetsDB-20170216.xls');
22 % out=add_tign_col(raw,t);
23 % cell2csv(out,'AssetsDB.csv')
27 insert_col_pos=3; % number of the column to add
28 end_times=t.times(end,:);
29 end_datenum = datenum(end_times); % in days from some instant in the past
30 end_minutes=t.xtime(end); % from simulation start
31 start_datenum=end_datenum-end_minutes/(24*60);
32 fprintf('Simulation start %s UTC\n',datestr(start_datenum,0));
33 fprintf('Simulation end %s UTC\n',datestr(end_datenum,0));
36 out(:,1:insert_col_pos-1)=raw(:,1:insert_col_pos-1);
37 out(:,insert_col_pos+1:end)=raw(:,insert_col_pos:end);
38 out(1,insert_col_pos)={'Time burned'};
39 lats=cell2mat(raw(2:end,1));
40 lons=cell2mat(raw(2:end,2));
41 tign=gridinterp(t.fxlat,t.fxlong,t.tign_g,lats,lons);
46 %h=mesh(t.fxlat,t.fxlong,t.tign_g);
47 %alpha=0.1;set(h,'EdgeAlpha',alpha,'FaceAlpha',alpha)
49 h=contour3(t.fxlat,t.fxlong,t.tign_g,[0:4*3600:max(tign)],'b');
51 plot3(lats,lons,tign,'k*')
57 burn_datenum = start_datenum + tign/(24*60*60);
59 fprintf('lat=%8.4f long=%8.4f tign=%g',lats(i),lons(i),tign(i))
60 %plot(lats(i),lons(i),'k*'),drawnow
61 if isnan(burn_datenum(i)) | burn_datenum(i) >= end_datenum-1/100,
64 burn_datestr{i} = datestr(burn_datenum(i),'yyyy-mm-dd HH:MM:SS');
66 fprintf(' %s\n',burn_datestr{i})
68 out(2:end,insert_col_pos)=burn_datestr;