disp('med_tau_plt_STRATUS_2017');

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(ytaucx(ii)) & isfinite(ytaucy(ii)) & isfinite(ytaub(ii)) & ...
              (reldir_hr(ii)>rdir_lo & reldir_hr(ii)<rdir_hi) & ytilt(ii)<tilt_lim);
   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 20],[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 20 -.025 0.6]); grid;
title([jdollars,' Wind-bin Hr Avg Stress vs. Wind Speed']);

figure; plot(taubmm(ii),taucxmm(ii),'o',taubmx(ii),taucxmx(ii),'x',taubmm(ii),tauibmm(ii),'d',[-.10 .6],[-.10 .6]);
axis([-.025 .6 -.025 .6]); xlabel('Bulk Streamwise Stress (N/m^2)'); ylabel('Turb Streamwise Stress (N/m^2)');
title([jdollars,' Wind-bin Hr Avg 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 20],[0 0]);
xlabel('U (m/s)'); ylabel('Tau xstream (N/m^2)'); axis([0 20 -.1 0.1]); grid;
title([jdollars,'  Wind-bin Hr Avg X-stream Stress: o = median, x = -0.004 - mean(tauib)/10']);

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