1 function vprofile(p,x1,x2,tstep)
2 % vprofile(filename,x1,x2,tstep)
3 % compute and plot vertical profiles at given location and time
5 % p string, WRF file name, or structure p where the file was read using the command
6 % p=wrfatm2struct(filename,tstep);
7 % x1 distance in m from lower left end of domain in coordinate 1
8 % x2 distance in m from lower left end of domain in coordinate 2
9 % tstep the index in input files to compute this at, or empty
12 % vprofile('wrfinput_d01',100,100,[])
13 % vprofile('wrfout_d01_0001-01-01_00:00:00',100,100,1)
15 % the data for this time step
17 p=wrfatm2struct(filename,tstep);
19 % horizontal coordinates in terms of mesh index, cell centered
24 % interpolate the vertical profiles
25 altitude=interp_12(p.altitude,i1,i2);
27 disp(['Time is ',p.times{1}])
30 u=interp_12(p.u,i1+0.5,i2); % staggered in x1
31 v=interp_12(p.v,i1,i2+0.5); % staggered in x2
32 [direction,speed]=pol(u,v); % wind from north to south is direction zero
35 fprintf('Wind profile at (%gm %gm) from lower left corner of domain\n',x1,x2)
36 z0 = interp2(p.z0, i1, i2);
38 fprintf('Rougness height from LANDUSE %5.3fm\n',z0);
39 fz0 = interp2(p.fz0, fi1, fi2);
41 fprintf('Roughness height on fire mesh %5.3fm\n',fz0);
44 fwh = interp2(p.fwh, fi1, fi2);
46 fprintf('Wind height fire mesh %5.3fm\n',fwh);
48 uf = interp2(p.uf, fi1, fi2);
49 vf = interp2(p.vf, fi1, fi2);
53 fprintf('No fuel at this location, wind not interpolated.\n')
56 fprintf('layer altitude U V speed direction (degrees)\n')
57 fprintf('z0 %7.3f %7.3f %7.3f %7.3f\n',dz0,0,0,0) % at roughness height
60 fprintf('fwh %7.3f %7.3f %7.3f %7.3f %7.3f\n',fwh,uf,vf,sf,df)
62 fprintf('reduced %7.3f %7.3f %7.3f %7.3f\n',uf,vf,sf,df)
65 fprintf('%3i %7.3f %7.3f %7.3f %7.3f %7.3f\n',i,altitude(i),u(i),v(i),speed(i),direction(i))
68 mm=[layers,size(p.u,3)];
71 speedfile=sprintf('speed_%i.png',m);
72 directionfile=sprintf('direction_%i.png',m);
73 windufile=sprintf('windu_%i.png',m);
74 windvfile=sprintf('windv_%i.png',m);
76 plot(speed(1:m),altitude(1:m))
85 print('-dpng',speedfile)
87 plot(direction(1:m),altitude(1:m))
93 xlabel('direction degrees')
95 title('Wind direction');
96 print('-dpng',directionfile)
98 plot(u(1:m),altitude(1:m))
107 print('-dpng',windufile)
109 plot(v(1:m),altitude(1:m))
118 print('-dpng',windvfile)
121 disp('PNG files with figures created')
124 % t=interp2(t,i1,i2);
125 % q=interp2(qvapor,i1,i2);
129 function [d,s]=pol(u,v)
130 [d,s]=cart2pol(-v,u); % wind from north to south is direction zero
131 d=180*d/pi; % convert to degrees