mv drawfire.m max_hfx.m to vis3d
[wrf-fire-matlab.git] / drawfire.m
blobb38ab7d39d8ba0a515c59216702585c7ccca46cf
1 function p=drawfire(f,ifire,nframes)
2 % p=drawfire(f)
3 % show heatflux stored in wrfout
4 if ischar(f)
5     vars={'FIRE_AREA','FGRNHFX','LFN','TIGN_G','FUEL_FRAC','FXLONG','FXLAT','NFUEL_CAT','Times'};
6     p=nc2struct(f,vars,{'DX','DY'});
7     % all preprocessing here 
8     p.times=char(p.times');
9     for n=1:size(p.fgrnhfx,3)
10         p.fgrnhfx_max(n)=max(max(p.fgrnhfx(:,:,n)));
11     end
12 else
13     p=f;  % structure passed in
14 end
15 % graphics only
16 if ~exist('nframes','var')
17     nframes=size(p.fgrnhfx,3);
18 end
19 [i,j,v]=find(p.fgrnhfx(:,:,nframes));
20 is=min(i);
21 ie=max(i);
22 js=min(j);
23 je=max(j);
24 r=max(ie-is,je-js)/2;
25 ci = (is+ie)/2;
26 cj = (js+je)/2;
27 is=round(ci-r);
28 ie=round(ci+r);
29 js=round(cj-r);
30 je=round(cj+r);
31 for n=1:nframes
32     figure(1)
33     subplot(2,2,1)
34     mesh(p.fxlong(is:ie,js:je,n),p.fxlat(is:ie,js:je,n),p.fgrnhfx(is:ie,js:je,n)),
35     titl('FGRNHFX')
36     subplot(2,2,2)
37     mesh(p.fxlong(is:ie,js:je,n),p.fxlat(is:ie,js:je,n),p.lfn(is:ie,js:je,n))
38     hold on
39     contour(p.fxlong(is:ie,js:je,n),p.fxlat(is:ie,js:je,n),p.lfn(is:ie,js:je,n),[0 0])
40     % view(0.9,90)
41     hold off
42     titl('LFN')
43     subplot(2,2,3)
44     mesh(p.fxlong(is:ie,js:je,n),p.fxlat(is:ie,js:je,n),p.fuel_frac(is:ie,js:je,n))
45     titl('FUEL_FRAC')
46     % colorbar
47     % view(0.9,90)
48     subplot(2,2,4)
49     d=p.fuel_frac(is:ie,js:je,n);
50     if n>1, 
51         d=d-p.fuel_frac(is:ie,js:je,n-1);
52     end
53     mesh(p.fxlong(is:ie,js:je,n),p.fxlat(is:ie,js:je,n),d)
54     % colorbar
55     titl('FUEL_FRAC diff')
56     % view(0.9,90)
57     drawnow
58     fprintf('frame %i at %s fgrnhfx max %f\n',n,p.times(n,:),p.fgrnhfx_max(n))
59     pause(0.3)
60 end
61     function titl(s)  % n and p from outer scope
62         title([s,' frame ',num2str(n),' at ',p.times(n,:),' ifire=',num2str(ifire)],...
63             'interpreter','none')
64     end
65 end