% loads HiWinGS_2013_10minMeans_r2 bulk met data
% saves bulk met to txt file if desired
% runs COARE 3.5 and saves HiWinGS_2013_10minC35outputs_r2

load ('/Volumes/User/bblomquist/Documents/Cruises/HiWinGS_2013/MeanNBulkfluxes/HiWinGS_2013_10minMeans_r2.mat');

% met file format:
% Yday Lat Lon SOG COG Heading Cspd Cdir Wspd Wdir WspdR WdirR rdir Pair RH Tair Qair Tsea Tsnake Solar IR   Pcp
% UTC  deg deg m/s deg deg     m/s  deg  m/s  deg  m/s   deg   deg   mb  %  C    g/Kg C    C      W/m2  W/m2 mm/hr

% dfl = '/Volumes/User/bblomquist/Documents/Cruises/HiWinGS_2013/MeanNBulkfluxes/HiWinGS_2013_10minMeans_r2.txt';
% M = [Yday,Lat,Lon,SOG,COG,Heading,Cspd,Cdir,Wspd,Wdir,WspdR,WdirR,rdir,Pair,RH,Tair,Qair,Tsea,Tsnake,Solar,IR,Pcp];
% save(dfl,'M','-ascii','-tabs');

zu = ones(length(RH),1).*16;
zt = ones(length(RH),1).*14;
zq = ones(length(RH),1).*14;
zi = ones(length(RH),1).*NaN;
cp = ones(length(RH),1).*NaN;
sigH = ones(length(RH),1).*NaN;

A = coare35vn(WspdR,zu,Tair,zt,RH,zq,Pair,Tsea,Solar,IR,Lat,zi,Pcp,cp,sigH);

% Output:  A=[usr tau hsb hlb hbb hsbb hlwebb tsr qsr zot zoq Cd Ch Ce  L zet dter dqer tkt Urf Trf Qrf RHrf UrfN Rnl Le rhoa UN U10 U10N Cdn_10 Chn_10 Cen_10 RF Qs Evap T10 Q10 RH10 us wbar zo];
%              1   2   3   4   5   6    7      8   9  10  11  12 13 14  15 16   17  18   19  20  21  22  23   24   25 26  27  28  29  30   31     32     33    34 35  36  37  38   39  40  41  42

A = [Yday,A];

dfl = '/Volumes/User/bblomquist/Documents/Cruises/HiWinGS_2013/MeanNBulkfluxes/HiWinGS_2013_10minC35outputs_r2.txt';
save(dfl,'A','-ascii','-tabs');



