didread=0;
if didread~=1;
   x=load('d:\cwf\flux_sum.txt');%read file with half-hour average data; set your local directory 
   jd=x(:,1);%julian day at beginning of half hour average
   u=x(:,2); %true wind speed, m/s; etl sonic anemometer
   dir=x(:,3);%true wind direction (from), deg (clockwise rel north)
   tsnk=x(:,4);%sea snake temperature, C (0.05 m depth)
   tsg=x(:,5);%tsg water temperature, C (5 m depth)
   sal=x(:,6);%tsg salinity, psu (5 m depth)
   ta=x(:,7);%air temperature, C (z=14.5 m)
   qs=x(:,8);%sea surface specific humidity, g/kg (from snake when in water, see field 17)
   qa=x(:,9);%air specific humidity, g/kg (z=14.5  m)
   Rs=x(:,10);%downward solar flux, W/m^2 (ETL units)
   Rl=x(:,11);%downward IR flux, W/m^2 (ETL units)
   rain=x(:,12);%rainrate, mm/hr (ETL STI optical rain gauge, uncorrected)
   ushp=x(:,13);%ship speed, m/s (SCS ODEC)
   head=x(:,14);%ship heading, deg clockwise rel north (SCS laser ring gyro)
   urel=x(:,15);%relative wind speed, m/s (ETL sonic)
   reldir=x(:,16);%relative wind direction (from), deg clockwise rel ship's bow(ETL sonic)
   zt=x(:,17);%depth for flux Ts reference, =0.05 when snake is in the water, 5.0 otherwise
   sig_u=x(:,18);%std dev of ship speed, m/s (>.1 indicates manauver during half hour average)
   taub=x(:,19);%bulk wind stress along mean wind, N/m^2
   hsb=x(:,20);%bulk sensible heat flux, W/m^2
   hlb=x(:,21);%bulk latent heat flux, W/m^2 (includes Webb et al. correction)
   hrain=x(:,22);%rain heat flux, W/m^2 as per Gosnell et al
   lat=x(:,23);%latitude, deg  (SCS pcode)
   lon=x(:,24);%longitude, deg (SCS pcode)
   Rnl=x(:,25);%net longwave flux, W/m^2 using emissivity=0.97
   hnet=x(:,26);%net heat flux into ocean, W/m^2
   ts=x(:,27);%Ts used in bulk flux calculation, =tsnk if zt=0.05
end;


%****************  diurnal averages  *************
hr=0:23;hr=hr+.5;
dj=1/24;
jdx=jd-floor(jd);
for j=0:23
   ck=j*dj;
   i=j+1;
   m=find(jdx>ck & jdx<ck+dj);
   rainm(i)=mean(rain(m));
   clr(i)=max(Rs(m));
   rsm(i)=mean(Rs(m));
   rlm(i)=mean(Rl(m));
   rnlm(i)=mean(Rnl(m));
	hnm(i)=mean(hnet(m));
   um(i)=mean(u(m));
   hlm(i)=mean(hlb(m));
   tsm(i)=mean(ts(m));
   tsgm(i)=mean(tsg(m));
end;

figure;plot(hr,rainm);xlabel('Hour of the Day');ylabel('Rainrate (mm/hr)');
figure;plot(hr,clr,hr,rsm,hr,hnm);xlabel('Hour of the Day');ylabel('Solar and Net Heat Flux (W/m^2)');
figure;plot(hr(1:12),rsm(1:12)./clr(1:12));xlabel('Hour of the Day');ylabel('Solar Cloud Transmission Coeff.');
figure;plot(hr,um);xlabel('Hour of the Day');ylabel('Wind Speed (m/s)');
figure;plot(hr,hlm,hr,-rnlm);xlabel('Hour of the Day');ylabel('Latent and Net IR Heat Fluxes (W/m^2)');
figure;plot(hr,rlm);xlabel('Hour of the Day');ylabel('Downward IR Flux (W/m^2)');
figure;plot(hr,tsm,hr,tsgm);xlabel('Hour of the Day');ylabel('Ocean Near Surface Temperatures (C)');

%*****************