load d:\temp\index.txt
Uns=Un(index);
Sus=Su(index,1:50);
Sws=Sw(index,1:50);
Sts=St(index,1:50);
Sqs=Sq(index2,1:50);
Sujs=Suj(index,1:50);
Swjs=Swj(index,1:50);
Ctws=Ctw(index,1:50);
Cqws=Cqw(index2,1:50);
Cuwjs=Cuwj(index,1:50);

Su1=[];Sw1=[];St1=[];Sq1=[];Suj1=[];Swj1=[];Cuw1=[];Ctw1=[];Cqw1=[];Cuwj1=[];Uu1=[];Uq1=[];
Su2=[];Sw2=[];St2=[];Sq2=[];Suj2=[];Swj2=[];Cuw2=[];Ctw2=[];Cqw2=[];Cuwj2=[];Uu2=[];Uq2=[];
Su3=[];Sw3=[];St3=[];Sq3=[];Suj3=[];Swj3=[];Cuw3=[];Ctw3=[];Cqw3=[];Cuwj3=[];Uu3=[];Uq3=[];
Su4=[];Sw4=[];St4=[];Sq4=[];Suj4=[];Swj4=[];Cuw4=[];Ctw4=[];Cqw4=[];Cuwj4=[];Uu4=[];Uq4=[];
Su5=[];Sw5=[];St5=[];Sq5=[];Suj5=[];Swj5=[];Cuw5=[];Ctw5=[];Cqw5=[];Cuwj5=[];Uu5=[];Uq5=[];
for ii=1:length(index);
   if delta(ii)>5,
      if Uns(ii)<=10.3,
         Uu1=[Uu1 Uns(ii)];
         Su1=[Su1
            Sus(ii,1:50)];
         Sw1=[Sw1
            Sws(ii,1:50)];
         St1=[St1
            Sts(ii,1:50)];
         Suj1=[Suj1
            Sujs(ii,1:50)];
         Swj1=[Swj1
            Swjs(ii,1:50)];
         Ctw1=[Ctw1
            Ctws(ii,1:50)];
         Cuwj1=[Cuwj1
            Cuwjs(ii,1:50)];
      end;
      if Uns(ii)>9 & Uns(ii)<=12,
         Uu2=[Uu2 Uns(ii)];
         Su2=[Su2
            Sus(ii,1:50)];
         Sw2=[Sw2
            Sws(ii,1:50)];
         St2=[St2
            Sts(ii,1:50)];
         Suj2=[Suj2
            Sujs(ii,1:50)];
         Swj2=[Swj2
            Swjs(ii,1:50)];
         Ctw2=[Ctw2
            Ctws(ii,1:50)];
         Cuwj2=[Cuwj2
            Cuwjs(ii,1:50)];
      end;
      if Uns(ii)>10.5 & Uns(ii)<=15,
         Uu3=[Uu3 Uns(ii)];
         Su3=[Su3
            Sus(ii,1:50)];
         Sw3=[Sw3
            Sws(ii,1:50)];
         St3=[St3
            Sts(ii,1:50)];
         Suj3=[Suj3
            Sujs(ii,1:50)];
         Swj3=[Swj3
            Swjs(ii,1:50)];
         Ctw3=[Ctw3
            Ctws(ii,1:50)];
         Cuwj3=[Cuwj3
            Cuwjs(ii,1:50)];
      end;
      if Uns(ii)>14 & Uns(ii)<=16.5,
         Uu4=[Uu4 Uns(ii)];
         Su4=[Su4
            Sus(ii,1:50)];
         Sw4=[Sw4
            Sws(ii,1:50)];
         St4=[St4
            Sts(ii,1:50)];
         Suj4=[Suj4
            Sujs(ii,1:50)];
         Swj4=[Swj4
            Swjs(ii,1:50)];
         Ctw4=[Ctw4
            Ctws(ii,1:50)];
         Cuwj4=[Cuwj4
            Cuwjs(ii,1:50)];
      end;
      if Uns(ii)>14.5,
         Uu5=[Uu5 Uns(ii)];
         Su5=[Su5
            Sus(ii,1:50)];
         Sw5=[Sw5
            Sws(ii,1:50)];
         St5=[St5
            Sts(ii,1:50)];
         Suj5=[Suj5
            Sujs(ii,1:50)];
         Swj5=[Swj5
            Swjs(ii,1:50)];
         Ctw5=[Ctw5
            Ctws(ii,1:50)];
         Cuwj5=[Cuwj5
            Cuwjs(ii,1:50)];
      end;
   end;
end;

Uq1=[];
Uq2=[];
Uq3=[];
Uq4=[];
%for ii=1:length(index2);
%   if deltaq(ii)>5,
%      if Uns(ii)<8.9,
%         Uq1=[Uq1 Uns(ii)];
%         Sq1=[Sq1
%            Sqs(ii,1:50)];
%         Cqw1=[Cqw1
%            Cqws(ii,1:50)];
%      end;
%      if Uns(ii)<10.4 & Uns(ii)>=8.9,
%         Uq2=[Uq2 Uns(ii)];
%         Sq2=[Sq2
%            Sqs(ii,1:50)];
%         Cqw2=[Cqw2
%            Cqws(ii,1:50)];
%      end;
%      if Uns(ii)<13.2 & Uns(ii)>=10.4,
%         Uq3=[Uq3 Uns(ii)];
%         Sq3=[Sq3
%            Sqs(ii,1:50)];
%         Cqw3=[Cqw3
%            Cqws(ii,1:50)];
%      end;
%      if Uns(ii)<15.9 & Uns(ii)>=13.2,
%         Uq4=[Uq4 Uns(ii)];
%         Sq4=[Sq4
%            Sqs(ii,1:50)];
%         Cqw4=[Cqw4
%            Cqws(ii,1:50)];
%      end;
%      if Uns(ii)<=25 & Uns(ii)>15.9,
%         Uq5=[Uq5 Uns(ii)];
%         Sq5=[Sq5
%            Sqs(ii,1:50)];
%         Cqw5=[Cqw5
%            Cqws(ii,1:50)];
%      end;
%   end;
%end;
for ii=1:length(index2);
   if deltaq(ii)<0 & deltaq(ii)>-1,
      Uq1=[Uq1 Uns(ii)];
      Sq1=[Sq1
         Sqs(ii,1:50)];
      Cqw1=[Cqw1
         Cqws(ii,1:50)];
   end;
end;

Uu1=median(Uu1);Uu2=median(Uu2);Uu3=median(Uu3);Uu4=median(Uu4);Uu5=median(Uu5);
Uq1=median(Uq1);Uq2=median(Uq2);Uq3=median(Uq3);Uq4=median(Uq4);Uq5=median(Uq5);
Sum1=median(Su1(:,1:50));Sum2=median(Su2(:,1:50));Sum3=median(Su3(:,1:50));Sum4=median(Su4(:,1:50));Sum5=median(Su5(:,1:50));
Swm1=median(Sw1(:,1:50));Swm2=median(Sw2(:,1:50));Swm3=median(Sw3(:,1:50));Swm4=median(Sw4(:,1:50));Swm5=median(Sw5(:,1:50));
Stm1=median(St1(:,1:50));Stm2=median(St2(:,1:50));Stm3=median(St3(:,1:50));Stm4=median(St4(:,1:50));Stm5=median(St5(:,1:50));
%Sqm1=median(Sq1(:,1:50));Sqm2=median(Sq2(:,1:50));Sqm3=median(Sq3(:,1:50));Sqm4=median(Sq4(:,1:50));Sqm5=median(Sq5(:,1:50));
Sqm1=median(Sq1(:,1:50));
Ctwm1=median(Ctw1(:,1:50));Ctwm2=median(Ctw2(:,1:50));Ctwm3=median(Ctw3(:,1:50));Ctwm4=median(Ctw4(:,1:50));Ctwm5=median(Ctw5(:,1:50));
%Cqwm1=median(Cqw1(:,1:50));Cqwm2=median(Cqw2(:,1:50));Cqwm3=median(Cqw3(:,1:50));Cqwm4=median(Cqw4(:,1:50));Cqwm5=median(Cqw5(:,1:50));
Cqwm1=median(Cqw1(:,1:50));
Cuwjm1=median(Cuwj1(:,1:50));Cuwjm2=median(Cuwj2(:,1:50));Cuwjm3=median(Cuwj3(:,1:50));Cuwjm4=median(Cuwj4(:,1:50));Cuwjm5=median(Cuwj5(:,1:50));

figure(1);semilogx(Fs,Fs.*Cuwjm1,'k-',Fs,Fs.*Cuwjm2,'k:',Fs,Fs.*Cuwjm3,'k-.',Fs,Fs.*Cuwjm4,'k--',Fs,Fs.*Cuwjm5,'k-','LineWidth',3);title('Composite W-U Cospectra','Fontsize',16);xlabel('Frequency in Hz');ylabel('F*C_w_u','Fontsize',16);text(1.2e-3,-0.07,'U = 8.1 ms^-^1','FontSize',16);text(1.2e-3,-0.08,'U = 10.3 ms^-^1','FontSize',16);text(1.2e-3,-0.09,'U = 12.9 ms^-^1','FontSize',16);text(1.2e-3,-0.10,'U = 15.3 ms^-^1','FontSize',16);text(1.2e-3,-0.11,'U = 16.1 ms^-^1','FontSize',16);
set(gca,'LineWidth',2,'FontSize',16);
figure(2);semilogx(Fs,Fs.*Ctwm1,'b:',Fs,Fs.*Ctwm3,'k',Fs,Fs.*Ctwm5,'k--','LineWidth',3);title('Composite W-T Cospectrum','FontSize',16);xlabel('Frequency in Hz','FontSize',16);ylabel('F*C_w_t','Fontsize',16);text(1.1e-3,2.4e-2,'deltaT > 5 deg','Fontsize',16);text(1.1e-3,2.2e-2,'dot   U = 9.5 ms^-^1','FontSize',16);text(1.1e-3,2e-2,'solid U = 13.2 ms^-^1','FontSize',16);text(1.1e-3,1.8e-2,'dash U = 16.1 ms^-^1','FontSize',16)
set(gca,'LineWidth',2,'FontSize',16);
%figure(3);semilogx(Fs,Fs.*Cqwm1,'b:',Fs,Fs.*Cqwm3,'k',Fs,Fs.*Cqwm5,'k--','LineWidth',3);title('Composite W-Q Cospectrum','FontSize',16);xlabel('Frequency in Hz','FontSize',16);ylabel('F*C_w_q','Fontsize',16);text(1.1e-3,19e-3,'deltaQ > 5 g/kg','Fontsize',16);text(1.1e-3,17e-3,'dot   U = 7.7 ms^-^1','FontSize',16);text(1.1e-3,15e-3,'solid U = 11.0 ms^-^1','FontSize',16);text(1.1e-3,13e-3,'dash U = 16.9 ms^-^1','FontSize',16)
figure(3);semilogx(Fs,Fs.*Cqwm1,'LineWidth',3);title('Composite W-Q Cospectrum','FontSize',16);xlabel('Frequency in Hz','FontSize',16);ylabel('F*C_w_q','Fontsize',16);text(1.1e-3,19e-3,'-1 < deltaQ < 0 g/kg','Fontsize',16);
set(gca,'LineWidth',2,'FontSize',16);

Ctwm1(1:14)=0;Ctwm1(21:50)=0;     %blue
Ctwm2(1:13)=0;Ctwm2(21:50)=0;     %green
Ctwm3(1:11)=0;Ctwm3(19:50)=0;     %red
Ctwm4(1:12)=0;Ctwm4(19:50)=0;     %cyan
Ctwm5(1:9)=0;Ctwm5(20:50)=0;      %magenta

figure(4);semilogx(Fs,Ctwm1,Fs,Ctwm2,Fs,Ctwm3,Fs,Ctwm4,Fs,Ctwm5);title('WT');text(2e-3,0.09,'bl=9');,text(2e-3,0.08,'gr=10');text(2e-3,0.07,'re=13');text(2e-3,0.06,'cy=15');text(2e-3,0.05,'ma=16');
figure(5);plot(Uu1,sum(Ctwm1.*deltaF)*1004*1.25,'o',Uu2,sum(Ctwm2.*deltaF)*1004*1.25,'o',Uu3,sum(Ctwm3.*deltaF)*1004*1.25,'o',Uu4,sum(Ctwm4.*deltaF)*1004*1.25,'o',Uu5,sum(Ctwm5.*deltaF)*1004*1.25,'o');
figure(6);plot(Uu1,sum(Ctwm1.*deltaF)*1004*1.25,'k.',Uu2,sum(Ctwm2.*deltaF)*1004*1.25,'k.',Uu3,(sum(Ctwm3.*deltaF)-0.0001)*1004*1.25,'k.',Uu4,(sum(Ctwm4.*deltaF)-0.0001)*1004*1.25,'k.',Uu5,(sum(Ctwm5.*deltaF)+0.00005)*1004*1.25,'k.','Markersize',30);
title('WT Cospectrum Correction','FontSize',16);xlabel('10-m Neutral Wind Speed in ms^-^1','FontSize',16);ylabel('Flux Correction in Wm^-^2','Fontsize',16);text(14,4,'deltaT < 1 deg','Fontsize',16);axis([9 18 3 6.5])
set(gca,'LineWidth',2,'FontSize',16);

[Uu1 Uu2 Uu3 Uu4 Uu5]
[Uq1 Uq2 Uq3 Uq4 Uq5]
%[size(Cqw1) size(Cqw2) size(Cqw3) size(Cqw4) size(Cqw5)]

figure(7);loglog(Fs(1:46),Fs(1:46).*Stm1(1:46),Fs(1:46),Fs(1:46).*Stm2(1:46),Fs(1:46),Fs(1:46).*Stm3(1:46),Fs(1:46),Fs(1:46).*Stm4(1:46),Fs(1:46),Fs(1:46).*Stm5(1:46),Fs(20:50),(Fs(20:50).^(-2/3))./(Fs(30).^(-2/3)).*Stm1(30).*Fs(30),':','LineWidth',3);title('Composite Temperature Spectrum','FontSize',16);xlabel('Frequency in Hz','FontSize',16);ylabel('F*S_t','Fontsize',16);%text(1e-2,1e-3,'U < 10 m/s','Fontsize',16);%text(1e-2,6e-4,'deltaT > 5 deg','Fontsize',16);
set(gca,'LineWidth',2,'FontSize',16);

[Uu1 Uu2 Uu3 Uu4 Uu5]
[sum(Ctwm1.*deltaF)*1004*1.25 sum(Ctwm2.*deltaF)*1004*1.25 (sum(Ctwm3.*deltaF)-0.0001)*1004*1.25 (sum(Ctwm4.*deltaF)-0.0001)*1004*1.25 (sum(Ctwm5.*deltaF)+0.00005)*1004*1.25]
