%% 

function [] = plot_stn_daily_composite(soil_stn, soil_wrf)

addpath('/Users/yang560/Dropbox/PNNL/Matlab_functions/utilities/')
make_it_tight = true;
subplot = @(m,n,p) subtightplot (m, n, p, [0.05 0.05], [0.07 0.07], [0.07 0.07]);
if ~make_it_tight,  clear subplot;  end

figure
set(gcf,'PaperPositionMode', 'auto')
set(gcf,'Position', [0 0 800 600])
data_len = size(soil_stn, 2);

stn_list = {'E11','E21','E12', 'E13','E15','E31', 'E32', 'E33'...
            'E34','E35','E36','E37','E38','E39','E40', 'E9'};

soil_stn_mean = nanmean(soil_stn,3);
soil_wrf_mean = nanmean(soil_wrf,3);

subplot(3,2,1)
plot(1:data_len, soil_stn_mean(1,:),'k-o');hold on
plot(1:data_len, soil_wrf_mean(1,:,1,1),'Linewidth', 2); hold on; %% lev, day, stn, runoption
plot(1:data_len, soil_wrf_mean(1,:,1,2),'Linewidth', 2); hold on; 
legend('STAMP','Default (A1)','gSSURGO (A2)')
ylabel('soil moisture (m^3 m^{-3})')
xlim([1 data_len]); ylim([.1 0.35])
title_left('a) Soil type')
grid on;legend boxoff;

subplot(3,2,2)
plot(1:data_len, soil_stn_mean(1,:),'k-o');hold on
plot(1:data_len, soil_wrf_mean(1,:,1,2),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,3),'Linewidth', 2); hold on; 
legend('STAMP','old SM table (A2)','new SM table (A3)') 

xlim([1 data_len]); ylim([.1 0.35])
title_left('b) Soil table')
grid on;legend boxoff;


subplot(3,2,3)
plot(1:data_len, soil_stn_mean(1,:),'k-o');hold on
plot(1:data_len, soil_wrf_mean(1,:,1,3),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,4),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,5),'Linewidth', 2); hold on; 
legend('STAMP','Default Vegetation (A3)','MODIS climatological (A4)','MODIS time-varying (A5)')
ylabel('soil moisture (m^3 m^{-3})')

xlim([1 data_len]); ylim([.1 0.35])
title_left('c) Dynamic vegetation')
grid on;legend boxoff;

subplot(3,2,4)
plot(1:data_len, soil_stn_mean(1,:),'k-o');hold on
plot(1:data_len, soil_wrf_mean(1,:,1,5),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,6),'Linewidth', 2); hold on; 
legend('STAMP','NLDAS-2 prcp (A5)','Stage-IV prcp (A6)')

xlim([1 data_len]); ylim([.1 0.35])
title_left('d) Precipitation forcing')
grid on;legend boxoff;

subplot(3,2,5)
plot(1:data_len, soil_stn_mean(1,:),'k-o');hold on
plot(1:data_len, soil_wrf_mean(1,:,1,6),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,7),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,8),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,9),'Linewidth', 2); hold on; 
legend('STAMP','no routing (A6)','surface routing (A7)','subsurface routing (A8)','routing (A9)') 
ylabel('soil moisture (m^3 m^{-3})')
xlabel('day')
xlim([1 data_len]); ylim([.1 0.35])
title_left('e) Routing')
grid on;legend boxoff;


subplot(3,2,6)
plot(1:data_len, soil_stn_mean(1,:),'k-o');hold on
plot(1:data_len, soil_wrf_mean(1,:,1,10),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,11),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,12),'Linewidth', 2); hold on; 
plot(1:data_len, soil_wrf_mean(1,:,1,13),'Linewidth', 2); hold on; 
legend('STAMP','100m (B2)','250m (B3)', '500m (B4)', '1000m (B5)')
xlabel('day')
xlim([1 data_len]); ylim([.1 0.35])
title_left('f) Routing resolution')
grid on;legend boxoff;

%  print('-depsc', ['station_number_1_10_',num2str(stn_number)])
end