function metm = auto_read_met_day_STRATUS_2019(path_working_ddd,ddd,yyyy,adj)
%{
Reads hourly met files for one day and retunrs 10-min averages
Loops through 24 hours, calling auto_read_met_STRATUS_2018 for each hour

Inputs: path_working_ddd: path to daily folder containing hourly files
        ddd: day-of-year variable
        yyyy: year string
        adj: temperature adjustments array, 1x6

Output: metm: 144x19 array of bulk met data
        Returns NaN for data gaps

    1   jd_met          10 min timestamp, decimal DOY @ start of interval
    2   Tsea            sea snake surface SST
    3   psp1            psp1 radiation, W/m2
    4   pir1            pir1 radiation, W/m2
    5   psp2            psp2 radiation, W/m2
    6   pir2            pir2 radiation, W/m2
    7   Tc1             pir1 case temperature
    8   Td1             pir1 dome temperature
    9   Tc2             pir2 case temperature
    10  Td2             pir2 dome temperature
    11  Pmb             vaisala pressure from mean2 box
    12  rwdir_wxt       rel wind direction ,0-360 deg from bow
    13  rwspd_wxt       rel wind speed, m/s
    14  Tair_wxt        air temperature, C
    15  RH_wxt          RH, %
    16  Pmb_wxt         air pressure, mb or hPa
    17  rain_wxt        rain rate, mm/hr
    18  U_wxt           U wind component, WXT
    19  V_wxt           V wind component, WXT
%}

fclose all;

metm = NaN(144,19);
delta = double(10/1440);
last = ddd + 143*delta;
jd_ref = ddd:delta:last;	% ref 10-min timestamp
metm(:,1) = jd_ref';
jd = sprintf('%03i',ddd);

for hhh = 0:23              % cycle thru 24 hourly met files
    hr = sprintf('%02i',hhh);
    dfl2 = fullfile(path_working_ddd,['met2' yyyy(3:4),jd,hr,'_raw.txt']);
    dfl3 = fullfile(path_working_ddd,['wxt0' yyyy(3:4),jd,hr,'_raw.txt']);
    % read this hours 10-min avg data from both systems if files exist
    % met is 6x11 array
    if exist(dfl2,'file')==2 && exist(dfl3,'file')==2
    met = auto_read_met_STRATUS_2019(dfl2,dfl3,ddd,hhh,adj);
    else
        continue % no data this hour
    end
    jdmet = met(:,1);
    % copy this hours data into metm array
    for jj = 1:length(jdmet)
        diff = jd_ref - jdmet(jj);
        [val,idx] = min(abs(diff));
        % allow 2 sec tolerance for timestamp match
        if val<double(2.0/86400) && length(idx)==1
            metm(idx,2:19) = met(jj,2:19);
        end
    end
end

% compute relative winds from averaged UV components
[rwspd,rwdir] = uv_to_sd(metm(:,18),metm(:,19));
rwdir(rwdir>180) = rwdir(rwdir>180) - 360;  % +/- 180 deg format
metm(:,12:13) = [rwdir,rwspd];

% adjust UV windspeeds for flow distortion effects
metm(:,18) = metm(:,18)/0.95;  % U = bow-on component
metm(:,19) = metm(:,19)/1.15;  % V = cross-wind component

end
