new file: surface_slice.py
[wrf-fire-matlab.git] / plot_tracer / fire_plot_cd.m
blobd253b31b5c9155851fd35ed96442e792a13d6fc0
1 function k=fire_plot_cd(xfg,yfg,xcd,ycd)
2 % k=fire_plot(xfg,yfg) - plot tracer arrays and return number of cells with
3 % nonzero tracers
4 if ndims(xfg)~=3,
5     error('xfg must have 3 dimensions')
6 end
7 if ndims(xfg)~=3,
8     error('xfg must have 3 dimensions')
9 end
10 [m,n,k]=size(xfg);
11 if k~=4,
12     error('dim3 of tracer array must be 4')
13 end
14 if any(size(xfg)~=size(yfg)),
15     error('xfg and yfg must be same dimension')
16 end
17 clf
18 k=0;
19 p=[1,2,4,3];
20  q=[1,2,3];
21  qq=[1,2];
22 for i=1:m,
23     for j=1:n,
24         tr_x=squeeze(xfg(i,j,:));
25         fire_x=squeeze(xcd(i,j,:));        
26         tr_y=squeeze(yfg(i,j,:));
27         fire_y=squeeze(ycd(i,j,:));
28       
29         %if(any(tr_x) | any(tr_y) | any(fire_x) | any(fire_y)),
30         if(any(tr_x) | any(tr_y)),  
31         %if(any(fire_x) | any(fire_y)),
32             k=k+1;
33             xcoord=tr_x(p)+i;
34             ycoord=tr_y(p)+j;
35             fire_xcoord=fire_x(q)+i;
36             fire_ycoord=fire_y(q)+j;
37             fire_xcoord1=fire_x(qq)+i;
38             fire_ycoord1=fire_y(qq)+j;
39             fill(xcoord,ycoord,[1,0,0]);
40             hold on
41             %if(any(fire_x) | any(fire_y)),
42             if((fire_x(q)~=0) | (fire_y(q)~=0)),  
43             plot(fire_xcoord,fire_ycoord,'ok');
44             plot([fire_xcoord(1),fire_xcoord(2),fire_xcoord(3)],[fire_ycoord(1),fire_ycoord(2),fire_ycoord(3)],'-b')
45             end 
46             if ((fire_x(qq)~=0) | (fire_y(qq)~=0)),
47             plot(fire_xcoord1,fire_ycoord1,'ok');
48             plot([fire_xcoord1(1),fire_xcoord1(2)],[fire_ycoord1(1),fire_ycoord1(2)],'-b')  
49             end
50             plot(xcoord,ycoord,'*g')
51             plot(i+[-0.5,+0.5,+0.5,-0.5,-0.5],j+[-0.5,-0.5,+0.5,+0.5,-0.5],'-k')
52             % drawnow
53         end
54     end
55     end
57 hold off
58 axis equal
59 fprintf('%g cells with nonzero tracers\n',k)