function sst = interp_rosr_FATIMA_2022(dfl,dnums)
%{
    reads rosr sst from .mat file specified by dfl and returns array with the
    following columns:
    
    1   dnum      10 Hz timestamp
    2   cog       sst, degC
    
    input parameters: dfl = string path to scs file
                      dnums = datenum time grid for resampling sst
%}

load(dfl,'rosr'); % load table with raw rosr sst data

dnum_raw = datenum(rosr.dt);
N = length(dnums);

if dnums(1) >= dnum_raw(1) && dnums(end) <= dnum_raw(end) % complete overlap
    sst = interp1(dnum_raw,rosr.sst,dnums);
elseif dnums(1) < dnum_raw(end) && dnums(end) > dnum_raw(end)
    ii = find(dnums<dnum_raw(end),1,'last');
    sst = interp1(dnum_raw,rosr.sst,dnums(1:ii));
    sst(ii+1:N) = NaN;
elseif dnums(1) < dnum_raw(1) && dnums(end) > dnum_raw(1)
    ii = find(dnums>dnum_raw(1),1,'first');
    sst = interp1(dnum_raw,rosr.sst,dnums(ii:end));
    sst = [NaN(ii-1,1);sst];
elseif dnums(1) > dnum_raw(end) || dnums(end) < dnum_raw(1)
    sst = NaN(N,1); % timeseries don't overlap
end
end