Merge branch 'fixf'
[wrf-fire-matlab.git] / debug / check_uah_vah.m
blob8d553954e720fe88c92fa36287146ca74329687e
1 % function check_uah_vah
3 %filename='wrfrst_d01_0001-01-01_00:01:00'; % wrfrst, not wrfout
4 %filename,height
6 % to validate computation of uah,vah
8 % run wrf with fire_print_file=1
9 % start matlab in em_fire
10 % cd to the run directory
11 % run this script 
13 height=20*0.3048;                           % 6ft
15 id=10003
17 if(id==0),
18     p=nc2struct(filename,{'U_2','V_2','PH_2','PHB','HGT','Z0','UAH','VAH',...
19     'XLONG','XLAT'},{'DX','DY'},1);
20     z0=p.z0; u=p.u_2; v=p.v_2; ph= p.ph_2; phb=p.phb; uahw=p.uah; vahw=p.vah;
21 else
22     z0=read_array_m('z0',id);
23     u=read_array_m('u_2',id);
24     v=read_array_m('v_2',id);
25     ph=read_array_m('ph_2',id);
26     s=size(ph_2);k=s(3);
27     u=u_2(:,:,1:k-1,:); % vertically staggered
28     v=v_2(:,:,1:k-1,:);
29     phb=read_array_m('phb',id);
30     uahw=read_array_m('uah',id);
31     vahw=read_array_m('vah',id);
32 end
34 altw=(ph_2+phb)/9.81; % geopotential altitude at w-points
36 % [uah,vah]=uah_vah(z0,u_2,v_2,altw,height);
37 uah_vah  % want all in base workspace to dissect
39 err_uah=big(uah-uahw)
40 err_vah=big(vah-vahw)
42 % end