disp('prt_CAPRICORN_2016_flux_hr');
fclose('all');
clear jazz;

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

thet1rel2 = thet1rel;
thet1rel2(thet1rel2<0) = thet1rel2(thet1rel2<0)+360;

npz = length(jda);
jazz(1,1:npz) = jda';           % date
jazz(2,1:npz) = yushp;          % uship
jazz(3,1:npz) = v1;             % u true
jazz(4,1:npz) = thet1;          % true dir
jazz(5,1:npz) = v1rel;          % u rel
jazz(6,1:npz) = thet1rel2;      % rel dir - save in 0-360 deg format
jazz(7,1:npz) = yhead;          % ship heading
jazz(8,1:npz) = y4(:,3)';       % SST best
jazz(9,1:npz) = y4(:,5)';       % Ta best
jazz(10,1:npz) = y4(:,4)';      % qs best
jazz(11,1:npz) = y4(:,7)';      % qa best
jazz(12,1:npz) = yhsc;          % hs covariance
jazz(13,1:npz) = yhsib;         % hs ID
jazz(14,1:npz) = yhsb;          % hs bulk
jazz(15,1:npz) = yhlc_bl;       % hl blend of cov results
jazz(16,1:npz) = yhlib_lic;     % hl ID
jazz(17,1:npz) = yhlb;          % hl bulk
jazz(18,1:npz) = taucx;         % stress stream-wise covariance
jazz(19,1:npz) = taucy;         % stress cross-stream covariance
jazz(20,1:npz) = tauib;         % stress ID
jazz(21,1:npz) = taub;          % stress bulk
jazz(22,1:npz) = y4(:,8)';      % rs best
jazz(23,1:npz) = y4(:,9)';      % rl best
jazz(24,1:npz) = y4(:,11)';     % ORG rain rate
jazz(25,1:npz) = yj;            % ship plume contam index
jazz(26,1:npz) = y1(:,44)';     % tilt of good data
jazz(27,1:npz) = yjm;           % maneuver index
switch IDflag
    case 'a'
        jazz(28,1:npz) = y1(:,138)';    % ct
        jazz(29,1:npz) = y1(:,140);     % cql
        jazz(30,1:npz) = y1(:,134)';    % cu
        jazz(31,1:npz) = y1(:,136)';    % cw
    case 'b'
        jazz(28,1:npz) = y1(:,139)';    % ct
        jazz(29,1:npz) = y1(:,141);     % cql
        jazz(30,1:npz) = y1(:,135)';    % cu
        jazz(31,1:npz) = y1(:,137)';    % cw
end;
jazz(32,1:npz) = yhrain;        % Rain heat flux
jazz(33,1:npz) = hl_webar';     % Hl webb flux
jazz(34,1:npz) = y1(:,151)';    % lat
jazz(35,1:npz) = y1(:,150)';    % lon
jazz(36,1:npz) = y1(:,27)';     % zu
jazz(37,1:npz) = y1(:,28)';     % zt
jazz(38,1:npz) = y1(:,29)';     % zq
jazz(39,1:npz) = ysog;          % uship scs
jazz(40,1:npz) = v1_scs;        % u true scs
jazz(41,1:npz) = thet1_scs;     % true dir scs
jazz(42,1:npz) = ycog;          % ship course scs
jazz(43,1:npz) = y1(:,6)';      % Ts scs, raw ship measurement
jazz(44,1:npz) = y1(:,3)';      % T scs
jazz(45,1:npz) = y4(:,4)';      % qs scs
jazz(46,1:npz) = y4(:,7)';      % qa scs
jazz(47,1:npz) = y1(:,7)';      % rs scs
jazz(48,1:npz) = y1(:,8)';      % rl scs
jazz(49,1:npz) = y3(:,4)'*NaN;  % w'c' licor - NOT COMPUTED
jazz(50,1:npz) = y3(:,2)';      % Specific Humidity from Licor (g/kg)
jazz(51,1:npz) = y3(:,12)';     % Stv of Specific Humidity from Licor (g/kg)
jazz(52,1:npz) = y3(:,4)';      % CO2 concentration from Licor (umol/mol)
jazz(53,1:npz) = y3(:,14)';     % Stv of CO2 concentration from Licor (umol/mol)
jazz(54,1:npz) = y4(:,10)';     % atmospheric pressure best (mbar)
jazz(55,1:npz) = v1';           % Wind speed (m/s) relative to earth
jazz(56,1:npz) = thet1';        % Wind direction (deg) from relative to earth
jazz(57,1:npz) = rnl_hr';       % net longwave heat flux
jazz(58,1:npz) = hnetb_hr';     % net heat flux, bulk, W/m2 hourly
jazz(59,1:npz) = hnet_hr';      % net heat flux, turb, W/m2 hourly

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


