disp('med_tau_plt_DYNAMO_2011');

ytilt = y1(:,44);
% kk=find(abs(taucx-tauib)>.03+.01*v1);
% taucx(kk) = NaN;
% taucy(kk) = NaN;
clear taucxmm taucymm taubm tauibm dum nm tauibmm tauibmx
% uu(1:13) = 0:12;
% uu(14:17) = 14:2:20;
uu(1:17) = 0:16;
reldir_hr = thet1rel;

for i=1:length(uu)-1
   ii = find(v1x>=uu(i) & v1x<uu(i+1));
   ppp = find(isfinite(taucx(ii)) & isfinite(taucy(ii)) & isfinite(taub(ii)) & reldir_hr(ii)>-90 & reldir_hr(ii)<90);% & ytilt(ii)>1.5);
   if isempty(ppp)
      taucxmm(i) = NaN;
      taucymm(i) = NaN;
      tauibmm(i) = NaN;
      taubmm(i) = NaN;
      taucxmx(i) = NaN;
      taucymx(i) = NaN;
      tauibmx(i) = NaN;
      taubmx(i) = NaN;
      wu(i) = NaN;
      wv(i) = NaN;
      nm(i) = 0;
      dum(i) = NaN;
   else
      taucxmm(i) = nanmedian1(taucx(ii(ppp)));
      taucymm(i) = nanmedian1(taucy(ii(ppp)));
      tauibmm(i) = nanmedian1(tauib(ii(ppp)));
   	  taubmm(i) = nanmedian1(taub(ii(ppp)));
      wu(i) = nanmedian1(y1(ii(ppp),117));
      wv(i) = nanmedian1(y1(ii(ppp),119));
    
   	  nm(i) = length(ppp);
      dum(i) = nanmedian1(v1(ii(ppp)));%
      taucxmx(i) = nanmean1(taucx(ii(ppp)));
      taucymx(i) = nanmean1(taucy(ii(ppp)));
      tauibmm(i) = nanmedian1(tauib(ii(ppp)));
   	  taubmx(i) = nanmean1(taub(ii(ppp)));
   end;
end;

ii = find(nm>2);

figure; plot(dum,taubmm,dum(ii),taucxmm(ii),dum,taubmx,'x',dum(ii),taucxmx(ii),'-x',dum(ii),tauibmm(ii),'d',[0 16],[0 0]);
legend('bulk median','DC median','bulk mean','DC mean','ID median','Location','NorthWest')
xlabel('U (m/s)'); ylabel('Taux (N/m^2)'); axis([0 16 -.025 0.5]); grid;
title([jdollars,'Wind-bin Averaged Hourly Stress vs. Wind Speed']);

figure; plot(taubmm(ii),taucxmm(ii),'o',taubmx(ii),taucxmx(ii),'x',taubmm(ii),tauibmm(ii),'d',[-.10 .4],[-.10 .4]);
axis([-.025 .4 -.025 .4]); xlabel('Bulk Streamwise Stress (N/m^2)'); ylabel('Turb Streamwise Stress (N/m^2)');
title([jdollars,' Wind-bin Averaged Hourly Stress: x = mean,o = median, diamond = ID']); grid;

figure; plot(dum(ii),-.004-tauibmm(ii)/10,dum(ii),taucymm(ii),'-o',dum(ii),taucymx(ii),'-x',[0 16],[0 0]);
xlabel('U (m/s)'); ylabel('Tau xstream (N/m^2)'); axis([0 16 -.1 0.1]); grid;
title([jdollars,'  Wind-bin Averaged Hourly Cross-stream Stress: o = median, x = -0.004 - mean(tauib)/10']);

figure;plot(dum(ii),-wu(ii),'-kd',dum(ii),-wv(ii),'-rd',[0 16],[0 0]);
xlabel('U (m/s)'); ylabel('-<WU> (black) & -<WV> (red) median components');
axis([0 16 -.1 0.4]); grid; title([jdollars,' Wind-bin Median Hourly WU & WV Covariances']);
