1 function r=compare_fire_area(f1,f2)
2 % r=compare_fire_area(f1,f2)
3 % finds the differences in fire area between two wrfouts
5 % f1, f2 wrfout file names
7 % structure with results
9 vars={'Times','FIRE_AREA','ROS'};
10 p1 = nc2struct(f1,vars,{});
11 p2 = nc2struct(f2,vars,{});
12 times1=char(p1.times)';
13 times2=char(p2.times)';
14 steps1=size(times1,1);
15 steps2=size(times2,1);
16 steps=min(steps1,steps2);
18 ssum = @(a) sum(a(:));
20 if(any(times1(step,:)-times2(step,:)))then
21 disp(['frame ',num2str(i),' file ',f1,' time ',times1(step,:)])
22 disp(['frame ',num2str(i),' file ',f2,' time ',times2(step,:)])
23 warning('times in input files are not the same')
25 fa1 = p1.fire_area(:,:,step); % fire areas this step
26 fa2 = p2.fire_area(:,:,step);
28 px1 = fa1>0; % 0-1 arrays burning/not burning
29 px2 = fa2>0; % 0-1 arrays burning/not burning
31 r.fire_area_1(1,step) = ssum(fa1);
32 r.fire_area_2(1,step) = ssum(fa2);
33 r.fire_area_set_diff(1,step) = ssum(abs(fa2-fa1));
34 r.fire_area_diff(1,step) = ssum(fa2)--ssum(fa1);
35 r.fire_area_diff_rel(1,step) = (ssum(fa2)-ssum(fa1))/((ssum(fa1)+ssum(fa1))/2+realmin);
36 r.fire_area_set_diff_rel(1,step) = ssum(abs(fa2-fa1))/((ssum(fa1)+ssum(fa1))/2+realmin);
37 r.fire_pixels_1(1,step) = ssum(px1);
38 r.fire_pixels_2(1,step) = ssum(px2);
39 r.fire_pixels_diff(1,step) = ssum(px2)-ssum(px1);
40 r.fire_pixels_diff_rel(1,step) = (ssum(px2)-ssum(px1))/((ssum(px1)+ssum(px1))/2+realmin);
41 r.fire_pixels_set_diff(1,step) = ssum(abs(px2-px1));
42 r.fire_pixels_set_diff_rel(1,step) = ssum(abs(px2-px1))/((ssum(px1)+ssum(px1))/2+realmin);
43 ros1=p1.ros(:,:,step);
44 ros2=p2.ros(:,:,step);
46 r.ros_diff_avg(1,step)=sum(rosd)/prod(size(rosd));
47 r.ros_diff_max(1,step)=max(rosd);
48 r.ros_diff_min(1,step)=min(rosd);