Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '812b0fa306da73e35371012638b39c'
- Loading branch information
Showing
15 changed files
with
697 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
function frame3d(swind,amin,amax,astep,qstep,qs,... | ||
fxlong,fxlat,xlong,xlat,zsf,fgrnhfx,uf,vf,u,v,w,ph,phb,hgt) | ||
|
||
clf,hold off | ||
|
||
r = size(fxlong)./(size(xlong)+1); % refinement ratio | ||
ideal = all(xlong ==0); % not populated in ideal case | ||
|
||
if ideal, | ||
% do not have xlong and xlat in ideal case, but we made the coordinates up | ||
% for fxlong and fxlat, so interpolate | ||
n=size(xlong); | ||
[xa,ya]=ndgrid(r(1)*[1/2:1:n(1)],r(2)*[1/2:1:n(2)]); % centers of atm cells in fire grid | ||
axlong = interp2(fxlong,xa,ya); % fake coordinates for display | ||
axlat = interp2(fxlat,xa,ya); % fake coordinates for display | ||
xscale=1; | ||
yscale=1; | ||
else | ||
axlong=xlong; axlat=xlat; % in real case, xlong xlat populated | ||
er=6378e3; % earth radius in m | ||
deg2rad=2*pi/360; % 1 degree in radians | ||
% degrees to meters, long and lat | ||
lat_deg2m=er*deg2rad; | ||
long_deg2m=er*deg2rad*cos(deg2rad*mean(xlat(find(xlat)))); | ||
xscale=1/long_deg2m; | ||
yscale=1/lat_deg2m; | ||
end | ||
aspect_ratio = [xscale yscale 1]; | ||
|
||
% compute the corresponding part of the fire grid | ||
dmin=1+r.*(amin(1:2)-1); | ||
dmax=r.*amax(1:2); | ||
|
||
% surface colored by heat flux | ||
i=dmin(1):dmax(1);j=dmin(2):dmax(2); | ||
hs=surf(fxlong(i,j),fxlat(i,j),zsf(i,j),fgrnhfx(i,j),'EdgeColor','none','FaceAlpha',0.7); | ||
caxis([0,1e6]); % for heat flux color | ||
axis tight, colorbar | ||
hold on | ||
[c,hc]=contour3(fxlong(i,j),fxlat(i,j),zsf(i,j)); | ||
for h=hc(:)', set(h,'EdgeColor','black');end % color the contours black | ||
|
||
|
||
% surface wind arrows | ||
if swind, | ||
ii=dmin(1):qstep(1):dmax(1);jj=dmin(2):qstep(2):dmax(2); | ||
hq=quiver3(fxlong(ii,jj),fxlat(ii,jj),zsf(ii,jj),xscale*uf(ii,jj),yscale*vf(ii,jj),zeros(size(vf(ii,jj))),qs); | ||
set(hq,'Color','black') | ||
end | ||
|
||
% geopotential altitude of the centers of lower cell face | ||
% ph is perturbation from the background phb | ||
% note ph and phb are staggered just as w | ||
a = (ph+phb)/9.81; | ||
% check if the lowest background geopotential height is terrain height | ||
err_hgt = big(hgt-phb(:,:,1)/9.81) | ||
% interpolate the geopotential and w velocity from staggered grid to cell centers | ||
ac = (a(:,:,1:end-1)+a(:,:,2:end))/2; | ||
wc = (w(:,:,1:end-1)+w(:,:,2:end))/2; | ||
% interpolate u and v components of wind velocity from staggered grid to cell centers | ||
uc = (u(1:end-1,:,:)+u(2:end,:,:))/2; % from front and rear face to the center | ||
vc = (v(:,1:end-1,:)+v(:,2:end,:))/2; % from front and rear face to the center | ||
|
||
% atmosphere wind arrows | ||
ia=amin(1):astep(1):amax(1); | ||
ja=amin(2):astep(2):amax(2); | ||
colors={'white','red','green','blue','black'}; | ||
for k=amin(3):astep(3):amax(3), | ||
q1=u(ia,ja,k)*xscale; | ||
q2=v(ia,ja,k)*yscale; | ||
q3=w(ia,ja,k); | ||
hqa=quiver3(axlong(ia,ja),axlat(ia,ja),ac(ia,ja,k),q1,q2,q3,qs); | ||
set(gca,'DataAspectRatio',[xscale yscale 1]); | ||
i=1+mod(k-1,length(colors)); | ||
set(hqa,'Color',colors{i}); | ||
end | ||
|
||
if ideal | ||
xlabel('x (m)') | ||
ylabel('y (m)') | ||
else | ||
% set(gca,'PlotBoxAspectRatioMode','auto'); | ||
xlabel('longitude (deg)') | ||
ylabel('latitutude (deg)') | ||
end | ||
zlabel('z (m)') | ||
set(gca,'DataAspectRatio',[xscale yscale 1]); | ||
hold off | ||
drawnow | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
disp('1. install mexnc under the same directory as wrf-fire, then') | ||
disp('2. start matlab in wrf/WRFV3/test/em_fire to set up the paths properly') | ||
disp(' or cd there and run startup while in the directory') | ||
disp('3. read a wrfrst file into the workspace as in') | ||
disp(' >> ncload wrfrst_d01_0001-01-01_00:01:00') | ||
|
||
% note the variables are read here without the WRF permutation of dimensions | ||
ideal=1; | ||
rst=1; | ||
|
||
if rst, | ||
u=u_2; | ||
v=v_2; | ||
w=w_2; | ||
ph = ph_2; | ||
end | ||
|
||
clf | ||
amin=[15,15,1]; % the atm grid part to show | ||
amax=[30,30,2]; | ||
amin=[1,1,1]; % the atm grid part to show | ||
amax=[41,41,2]; | ||
|
||
qstep=[5,5]; % quiver step for wind on the surface fire grid | ||
astep=[1,1,1]; % quiver step for wind on the atmosphere grid | ||
qs=1.5; % scaling for quiver arrows | ||
r=[10,10]; % refinement factor | ||
swind=1; % plot surface wind | ||
|
||
%------------------------------------------------- | ||
|
||
frame3d(swind,amin,amax,astep,qstep,qs,... | ||
fxlong,fxlat,xlong,xlat,zsf,fgrnhfx,uf,vf,u,v,w,ph,phb,hgt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
% function wrfout2frame3d(file,steps) | ||
disp('1. file=''wrfout file''') | ||
disp('2. steps=[1:20] % time steps to display') | ||
disp('3. wrfout2frame3d') | ||
|
||
fxlong =ncread(file,'FXLONG'); | ||
fxlat =ncread(file,'FXLAT'); | ||
xlong =ncread(file,'XLONG'); | ||
xlat =ncread(file,'XLAT'); | ||
zsf =ncread(file,'ZSF'); | ||
fgrnhfx=ncread(file,'FGRNHFX'); | ||
uf =ncread(file,'UF'); | ||
vf =ncread(file,'VF'); | ||
u =ncread(file,'U'); | ||
v =ncread(file,'V'); | ||
w =ncread(file,'W'); | ||
ph =ncread(file,'PH'); | ||
phb =ncread(file,'PHB'); | ||
hgt =ncread(file,'HGT'); | ||
itimestep=ncread(file,'ITIMESTEP'); | ||
|
||
|
||
% note the variables are read here without the WRF permutation of dimensions | ||
|
||
amin=[15,15,1]; % the atm grid part to show | ||
amax=[30,30,2]; | ||
amin=[10,10,1]; % the atm grid part to show | ||
amax=[30,30,1]; | ||
|
||
qstep=[20,20]; % quiver step for wind on the surface fire grid | ||
astep=[2,2,1]; % quiver step for wind on the atmosphere grid | ||
qs=1e-3; % scaling for quiver arrows | ||
swind=0; % do not display surface wind | ||
|
||
%------------------------------------------------- | ||
|
||
a=avifile('fire.avi'); | ||
for k=steps, | ||
frame3d(swind,amin,amax,astep,qstep,qs,... | ||
fxlong(:,:,k),fxlat(:,:,k),xlong(:,:,k),xlat(:,:,k),... | ||
zsf(:,:,k),fgrnhfx(:,:,k),uf(:,:,k),vf(:,:,k),... | ||
u(:,:,:,k),v(:,:,:,k),w(:,:,:,k),... | ||
ph(:,:,:,k),phb(:,:,:,k),hgt(:,:,k)) | ||
title(['Timestep ',num2str(itimestep(k))]) | ||
F=getframe(gcf); | ||
a=addframe(a,F); | ||
end | ||
a=close(a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../ideal.exe |
Oops, something went wrong.