function [hmt337,hmt335,rbr] = read_trh_day_2023(path_data,dnum0,dnum1)
%{
    Reads hourly T/RH files for the 2023 intercomparison test
    and returns 1-min tables for all systems over specified
    date range, dnum0 to dnum1


    input parameters: path_data = string path to data folder
                      dnum0 = start date in matlab datenum format
                      dnum1 = end date in matlab datenum format
%}

%% initialize
fclose all;

ddd0 = dnum0 - datenum(2022,12,31);
ddd1 = dnum1 - datenum(2022,12,31);
YY = '23';
first_hr_337 = 1; first_hr_335 = 1; first_hr_rbr = 1;

for ddd = ddd0:ddd1
    DDD = sprintf('%03i',ddd);
    for hr = 0:23
        HR = sprintf('%02i',hr);
        fname_337 = ['hmt0',YY,DDD,HR,'_raw.txt'];
        fname_335 = ['hmt1',YY,DDD,HR,'_raw.txt'];
        fname_rbr = ['rbr0',YY,DDD,HR,'_raw.txt'];

        dfl1 = fullfile(path_data,fname_337);
        dfl2 = fullfile(path_data,fname_335);
        dfl3 = fullfile(path_data,fname_rbr);

        if exist(dfl1,'file')==0
            % do nothing, no data this hour
        elseif first_hr_337
            [~,hmt337] = read_hmt337_2023(dfl1);
            first_hr_337 = 0;
        else
            [~,temp] = read_hmt337_2023(dfl1);
            hmt337 = [hmt337;temp];
        end

        if exist(dfl2,'file')==0
            % do nothing, no data this hour
        elseif first_hr_335
            [~,hmt335] = read_hmt335_2023(dfl2);
            first_hr_335 = 0;
        else
            [~,temp] = read_hmt335_2023(dfl2);
            hmt335 = [hmt335;temp];
        end

        if exist(dfl3,'file')==0
            % do nothing, no data this hour
        elseif first_hr_rbr
            [~,rbr] = read_rbr_2023(dfl3);
            first_hr_rbr = 0;
        else
            [~,temp] = read_rbr_2023(dfl3);
            rbr = [rbr;temp];
        end
    end
end

end

