1 function run_moisture_test(varargin)
8 ncfile='moisture100.nc';
16 Times=ncread(ncfile,'Times');
17 [d,hours]=make_moisture_input(Times,t2,psfc,q2,rain);
18 setenv('DYLD_LIBRARY_PATH','/opt/local/lib:/opt/local/lib/gcc46')
19 system('./moisture_test.exe');
20 load moisture_output.txt
21 out.t2 =moisture_output(:,3);
22 out.t2_mid=midpoints(out.t2);
23 out.psfc =moisture_output(:,4);
24 out.q2 =moisture_output(:,5);
25 % rh_fire is computed from midpoint values in the fortran code
26 out.rain=moisture_output(:,6);
27 out.rh_fire=moisture_output(:,7);
28 out.fmc_equi =moisture_output(:,8);
29 out.tlag =moisture_output(:,9);
30 out.fmc_gc =moisture_output(:,10);
31 out.id='from moisture_test.exe';
34 out.hours_mid=midpoints(hours);
35 out.r=find(hours>=hr(1) & hours<=hr(2)); % range to display
37 orig.t2_mid=midpoints(orig.t2);
41 orig.rh_fire=rh_fire(~d);
42 orig.fmc_equi=fmc_equi(1,~d)';
43 orig.fmc_gc=fmc_gc(1,~d)';
44 orig.id=['from ',ncfile];
46 orig.hours_mid=midpoints(hours);
49 plot(hours,orig.fmc_gc,'r--',hours,out.fmc_gc,'k-')
52 title('Fuel moisture')
53 h=legend(orig.id,out.id);
54 set(h,'Interpreter','none')
56 plot(hours,orig.fmc_equi,'r--',hours,out.fmc_equi,'k-')
58 set(ylabel('kg/kg'),'Interpreter','none')
59 title('Equilibrium moisture')
60 h=legend(orig.id,out.id);
61 set(h,'Interpreter','none')
68 function plot_moisture(f,s)
70 [d,w]=equilibrium_moisture(s.rh_fire,s.t2_mid);
71 plot(s.hours_mid(s.r),d(s.r),'b--',...
72 s.hours_mid(s.r),w(s.r),'b-.',...
73 s.hours_mid(s.r),s.fmc_equi(s.r),'r--',...
74 s.hours(s.r),s.fmc_gc(s.r),'k-')
76 set(ylabel('Fuel moisture contents (kg / kg)'),'Interpreter','none')
77 h=title(['Fuel moisture ',s.id]);
78 set(h,'Interpreter','none')
79 h=legend('Drying','Wetting','Equilibrium','Actual');
80 set(h,'Interpreter','none')
84 function plot_all(f,s)
86 [d,w]=equilibrium_moisture(s.rh_fire,s.t2_mid);
87 plot(s.hours(s.r),s.t2(s.r)/max(s.t2),...
88 s.hours(s.r),s.psfc(s.r)/max(s.psfc),...
89 s.hours(s.r),s.q2(s.r)/max(s.q2),...
90 s.hours(s.r),s.rh_fire(s.r),...
91 s.hours_mid(s.r),s.fmc_equi(s.r),...
92 s.hours_mid(s.r),d(s.r),'g-.',...
93 s.hours_mid(s.r),w(s.r),'b-.',...
94 s.hours(s.r),s.fmc_gc(s.r))
95 h=title(['All variables ',s.id]);
96 set(h,'Interpreter','none');
98 h=legend('Scaled T2',...
103 'Drying equilibrium',...
104 'Wetting equilibrium',...
106 set(h,'Interpreter','none');
116 function T=midpoints(T2)
117 T=[T2(1);0.5*(T2(1:end-1)+T2(2:end))];