disp('prt_STRATUS_2017_flux_10');
fclose all;
clear flux10;

f = fullfile(da_path,['STRATUS_2017_flux_10_',datasetv,'_',dcname,'.txt']);
flist = fopen(f,'w');

reldir2 = reldir;
reldir2(reldir2<0) = reldir2(reldir2<0)+360;

npz = length(jdy);
flux10(1,1:npz) = jdy';                   % date
flux10(2,1:npz) = ushp';                  % uship
flux10(3,1:npz) = u_best';                % u true
flux10(4,1:npz) = dir';                   % true dir
flux10(5,1:npz) = urel';                  % u rel
flux10(6,1:npz) = reldir2';               % rel dir - save in 0-360 deg format
flux10(7,1:npz) = head';                  % ship heading
flux10(8,1:npz) = tsnk';                  % Ts seasnake
flux10(9,1:npz) = ta_best';               % T
flux10(10,1:npz) = qs_best';              % qs
flux10(11,1:npz) = qa_best';              % qa
flux10(12,1:npz) = hsc';                  % hs covariance
flux10(13,1:npz) = hsib';                 % hs ID
flux10(14,1:npz) = hsbb';                 % hs bulk
flux10(15,1:npz) = hlc_bl';               % hl covariance from licor
flux10(16,1:npz) = hlib_lic';             % hl ID
flux10(17,1:npz) = hlbb';                 % hl bulk
flux10(18,1:npz) = -(rhoair.*wuj)';       % stress streamwise covariance
flux10(19,1:npz) = -(rhoair.*wvj)';       %   "     xstream
flux10(20,1:npz) = (rhoair.*usib.^2)';    % stress ID
flux10(21,1:npz) = taubb';                % stress bulk
flux10(22,1:npz) = rs_best';              % solar flux
flux10(23,1:npz) = rl_best';              % IR flux
flux10(24,1:npz) = rain_best';            % rain rate
flux10(25,1:npz) = jplume';               % ship plume contam index
flux10(26,1:npz) = tiltx';                % tilt angle
flux10(27,1:npz) = jmanuv';               % maneuver index
flux10(28,1:npz) = ct';                   % ct
flux10(29,1:npz) = cql';                  % cq from Licor
flux10(30,1:npz) = cu';                   % cu
flux10(31,1:npz) = cw';                   % cw
flux10(32,1:npz) = HRF';                  % Rain heat flux
flux10(33,1:npz) = hl_webb';              % Hl webb flux
flux10(34,1:npz) = Lat';                  % lat
flux10(35,1:npz) = Lon';                  % lon
flux10(36,1:npz) = zu*ones(1,npz);        % zu
flux10(37,1:npz) = zWXT*ones(1,npz);      % zt
flux10(38,1:npz) = zWXT*ones(1,npz);      % zq
flux10(39,1:npz) = ushp';                 % uship scs
flux10(40,1:npz) = U_scs';                % u true scs
flux10(41,1:npz) = dir_scs';              % true dir scs
flux10(42,1:npz) = x(:,101)';             % ship course scs
flux10(43,1:npz) = tsg';                  % Ts scs
flux10(44,1:npz) = ta_im';                % T scs
flux10(45,1:npz) = qs_tsg';               % qs scs
flux10(46,1:npz) = qa_im';                % qa scs
flux10(47,1:npz) = rs_im';                % solar flux  IMET
flux10(48,1:npz) = rl_im';                % IR flux IMET
flux10(49,1:npz) = jdy'*NaN ;             % <w'c'> Licor - NOT COMPUTED
flux10(50,1:npz) = q_lic';                % Specific Humidity from Licor (g/kg)
flux10(51,1:npz) = sgq_lic';              % Stv of Specific Humidity from Licor (g/kg)
flux10(52,1:npz) = co2_lic';              % CO2 concentration from Licor (umol/mol)
flux10(53,1:npz) = sgco2_lic;             % Stv of CO2 concentration from Licor (umol/mol)
flux10(54,1:npz) = P_best';               % sea level atmospheric pressure (mbar)
flux10(55,1:npz) = u_best';               % Wind speed (m/s) relative to earth
flux10(56,1:npz) = dir';                  % Wind direction (deg) from relative to earth
flux10(57,1:npz) = rlcler';               % Longwave downwelling clear sky model (W/m2)
flux10(58,1:npz) = Rscl';                 % Shortwave solar radiance clear sky model (W/m2)
flux10(59,1:npz) = U10N';                 % 10m neutral windspeed, COARE 3.5
flux10(60,1:npz) = T10N';                 % 10m neutral temperature, COARE 3.5
flux10(61,1:npz) = Q10N';                 % 10m neutral specific humidity, COARE 3.5
flux10(62,1:npz) = U03N';                 % 3m neutral windspeed, COARE 3.5
flux10(63,1:npz) = T03N';                 % 3m neutral temperature, COARE 3.5
flux10(64,1:npz) = RH03';                 % 3m RH, COARE 3.5
flux10(65,1:npz) = rh_im';                % scs RH
flux10(66,1:npz) = P_im';                 % scs Pmb (sea level)
flux10(67,1:npz) = RH_wxt';               % PSD WXT RH, %

% vectorized print, 67 columns
% prepare format string for numeric data
fmtStr = '';
fmtStr = strcat('\r\n', fmtStr);
for i = 1:67
    fmtStr = strcat('%14.6f ', fmtStr);
end
fprintf(flist,fmtStr,flux10);
fclose('all');
disp(['File written as ' f]);

% save copy in .mat format
dfl = fullfile(da_path,['STRATUS_2017_flux_10_',datasetv,'_',dcname,'.mat']);
flux10 = flux10';
save(dfl,'flux10');
