clear all;
A =importdata('S:\cruises\HIWINGS_2013\Knorr\Scientific_analysis\MeanNBulkfluxes\HiWinGS_2013_1minMeansNFluxes_r1.txt');
A=A.data;

yday=A(:,1);    %Decimal yearday (UTC)
Lat=A(:,2);     %Latitude (deg)
Lon=A(:,3);     %Longitude (deg)
SOG=A(:,4);     %Speed over ground (m/s)
COG=A(:,5);     %Course over ground (deg)
Heading=A(:,6); %Ship's heading (deg)
cspd=A(:,7);    %Current speed (m/s) at 14m depth
cdir=A(:,8);    %Current direction (deg) from at 14m depth
U10=A(:,9);     %Wind speed (m/s) relative to earth adjusted to 10 m
wdir=A(:,10);   %Wind direction (deg) from relative to earth
Ur10=A(:,11);   %Wind speed (m/s) relative to water adjusted to 10 m
wdirR=A(:,12);  %Wind direction (deg) from relative to water
rdir=A(:,13);   %Relative Wind direction (deg) from
Pair10=A(:,14); %Pressure (mb) adjusted to 10 m
RH10=A(:,15);   %Relative humidity(%) adjusted to 10 m
T10=A(:,16);    %Temperature (C) adjusted to 10 m
Tsea=A(:,17);   %Sea temperature (C) from ship at 5m depth
SST=A(:,18);    %Sea surface temperature (C) from Tsea minus cool skin
Q10=A(:,19);    %Specific humidity (g/Kg) adjusted to 10 m
Qsea=A(:,20);   %Specific humidity (g/Kg) 'near' ocean surface from Tsea
SSQ=A(:,21);    %Sea surface specific humidity (g/Kg) from Qsea minus cool skin
stress=A(:,22); %Surface stress (N/m2) measured relative to water
shf=A(:,23);    %Sensible heat flux (W/m2)
lhf=A(:,24);    %Latent heat flux (W/m2)
rhf=A(:,25);    %Sensible heat flux from rain (W/m2)
Solarup=A(:,26); %Reflected solar (W/m2) estimated from Payne (1972)
Solardn=A(:,27); %Measured downwelling solar (W/m2)
IRup=A(:,28);   %Upwelling IR (W/m2) computed from SST 
IRdn=A(:,29);   %Measured downwelling IR (W/m2)
E=A(:,30);      %Evaporation rate (mm/hr)
P=A(:,31);      %Precipitation rate (mm/hr)


figure(1);clf
subplot(3,1,1)
plot(yday,U10,'b',yday,Ur10,'k',yday,cspd,'r')
axis([yday(1) yday(length(yday)) 0 35]);grid
ylabel('Speed (m/s)','fontsize',12)
legend('U_{10}','U_{r10}','C_{14}',2)
title('HiWinGS 2013','fontsize',16)
subplot(3,1,2)
plot(yday,wdir,'b.',yday,wdirR,'k.',yday,cdir,'r--')
axis([yday(1) yday(length(yday)) 0 360]);grid
legend('WD Earth','WD Ocean','Current',2)
ylabel('Direction (^o)','fontsize',12)
subplot(3,1,3)
area(yday,stress,'edgecolor','blue','facecolor','blue')
axis([yday(1) yday(length(yday)) 0 5]);grid
ylabel('Stress (N/m^2)','fontsize',12)
xlabel('Yearday 2013','fontsize',16)
orient tall
% print -djpeg90 HiWinGS2013_WindNStress.jpg

figure(2);clf
subplot(4,1,1)
plot(yday,T10,'b',yday,Tsea,'k',yday,SST,'r')
legend('T_{10}','T_{sea}','SST',2);grid;
ylabel('T(^oC)','fontsize',12)
axis([yday(1) yday(length(yday)) -5 25])
title('HiWinGS 2013','fontsize',16)
subplot(4,1,2)
plot(yday,Q10,'b',yday,Qsea,'m',yday,SSQ,'r')
legend('Q_{10}','Q_{sea}','SSQ',2);grid;
ylabel('Q(g/Kg)','fontsize',12)
axis([yday(1) yday(length(yday)) 0 20])
subplot(4,1,3)
plot(yday,Pair10,'b')
ylabel('P10m(mb)','fontsize',12)
axis([yday(1) yday(length(yday)) 960 1040]);grid;
subplot(4,1,4)
plot(yday,P,'b')
ylabel('Rain (mm)','fontsize',12)
xlabel('Yearday 2013','fontsize',16)
axis([yday(1) yday(length(yday)) 0 100]);grid;
orient tall
% print -djpeg90 HiWinGS2013_TQPRain.jpg

figure(3);clf
subplot(2,1,1)
plot(yday,Solardn,'b',yday,Solarup,'k',yday,IRdn,'r',yday,IRup,'m')
axis([yday(1) yday(length(yday)) -800 500]);grid;
ylabel('Radiative Fluxes','fontsize',12)
legend('SW_{down}','SW_{up}','LW_{down}','LW_{up}',2)
subplot(2,1,2)
plot(yday,lhf,'b',yday,shf,'k',yday,rhf,'r')
axis([yday(1) yday(length(yday)) -10 400]);grid;
ylabel('Heat Fluxes','fontsize',12)
xlabel('Yearday 2013','fontsize',16)
legend('LHF','SHF','Rain',2)

Qnet=Solarup+Solardn+IRup+IRdn+lhf+shf+rhf;


figure(4);clf
subplot(4,1,1);
plot(yday,U10,yday,cspd)
axis([yday(1) yday(length(yday)) 0 35]);grid
ylabel('Speed (m/s)','fontsize',12)
legend('Wind Speed at 10m Height','Current Speed at 14m Depth',2)
title('HiWinGS 2013','fontsize',16)
subplot(4,1,2)
plot(yday,SST,'r',yday,T10,'b','linewidth',2)
legend('SST','T_{10}',1,'Location','NorthWest')
ylabel('Temperature (^oC)','fontsize',12)
axis([yday(1) yday(length(yday)) -5 25]);grid
subplot(4,1,3)
plot(yday,SSQ,'r',yday,Q10,'b','linewidth',2)
legend('SSQ','Q_{10}',1,'Location','NorthWest')
ylabel('Spec Humidity (g/Kg)','fontsize',12)
axis([yday(1) yday(length(yday)) 0 20]);grid
subplot(4,1,4)
plot(yday,P,'b',yday,E,'r',yday,P-E,'k')
legend('P','E','P-E',2)
ylabel('Fresh Water Flux (mm)','fontsize',12);grid
xlabel('Yearday 2013','fontsize',16)
axis([yday(1) yday(length(yday)) 0 100])
% legend('P','E',2)
orient tall
% print -djpeg90 HiWinGS2013_MeanMet.jpg


figure(5);clf
subplot(3,1,1);
plot(yday,IRdn+IRup,'r',yday,Solardn+Solarup,'b',[yday(1) yday(length(yday))],[0 0],'k')
axis([yday(1) yday(length(yday)) -700 200]);grid
ylabel('Radiative Fluxes','fontsize',12)
legend('LW_{net}','SW_{net}',3)
title('HiWinGS 2013','fontsize',16)
hold
subplot(3,1,2)
plot(yday,lhf,yday,shf,'m',yday,rhf,'k','linewidth',1)
axis([yday(1) yday(length(yday)) -10 800]);grid
ylabel('Heat Fluxes','fontsize',12)
legend('LHF','SHF','Rain',2)
hold
subplot(3,1,3)
plot(yday,Qnet,[yday(1) yday(length(yday))],[0 0],'k--')
axis([yday(1) yday(length(yday)) -500 1000]);grid;
ylabel('Net Heat Flux (W/m^2)','fontsize',12)
xlabel('Yearday 2013','fontsize',16)
orient tall
% print -djpeg90 HiWinGS2013_HeatBudget.jpg
