function scs = read_scs_day_CAPRICORN_2016(path_scs_data,ddd)
%{
    Reads selected variables from netCDF file for specified
    day of year (2016).  Sample frequency is 5 sec.
    Unit conversions applied as necessary.

    Output array is 17280 x 37 for a whole day:
    1       jd                  decimal day of year
    2       lat                 seapath latitude
    3       lon                 seapath longitude, deg E
    4       sog                 seapath sog, m/s
    5       cog                 seapath cog, deg
    6       hed                 gyro heading, deg
    7       wspd_port           true wspd, port, m/s @ 25 m
    8       wdir_port           true wdir, port, deg
    9       rwspd_port          rel wspd, port, m/s
    10      rwdir_port          rel wdir, port, 0-360 deg
    11      wspd_stbd           true wspd, stbd, m/s @ 25 m
    12      wdir_stbd           true wdir, stbd, deg
    13      rwspd_stbd          rel wspd, stbd, m/s
    14      rwdir_stbd          rel wdir, stbd, 0-360 deg
    15      wspd_sonic          true wspd, sonic, m/s @ 22.5 m
    16      wdir_sonic          true wdir, sonic, deg
    17      rwspd_sonic         rel wspd, sonic, m/s
    18      rwdir_sonic         rel wdir, sonic, 0-360 deg
    19      ta_port             air temp, port, C @ 31.4 m main mast
    20      ta_stbd             air temp, stbd, C @ 31.4 m main mast
    21      rh_port             rel humidity, port, % @ 31.4 m main mast
    22      rh_stbd             rel humidity, stbd, % @ 31.4 m main mast
    23      Pmb                 atm preessure, mb @ 20.6 m on bridge
    24      rain                accumulated rain, RM Young, mm @ 22m
    25      rain_rate           rain rate, RM Young, mm/hr
    26      rain_optical        accumulated rain, optical disdrometer, mm
    27      rain_rate_optical   rain rate, optical disdrometer, mm/hr
    28      PSP_port            solar rad flux, port, W/m2 @ 25.2 m
    29      PSP_stbd            solar rad flux, stbd, W/m2 @ 25.2 m
    30      PIR_port            IR rad flux, port, W/m2 @ 25.2 m
    31      PIR_stbd            IR rad flux, stbd, W/m2 @ 25.2 m
    32      SST_IR              ISAR infrared sea surface temp, C @ 19.5 m on bridge
    33      SST                 TSG water temp, C on port drop keel
    34      Sal                 TSG salinity, psu
    35      uship_long          longitudinal speed through water, m/s
    36      uship_trans         transverse speed through water, + to starboard, m/s
    37      SST_depth           depth of SST measurement, m (varies depending
                                on drop keel position
%}

%% get metadata from nc file
info = ncinfo(path_scs_data);          % metadata
N = info.Dimensions(4).Length;         % length of variable arrays
dt = double(info.Attributes(5).Value)/86400; % delta time in dec doy
startTstr = info.Attributes(4).Value;  % start time in sec since 0000 1/1/16
startTfields = strsplit(startTstr,' ');
startT = 1 + str2double(startTfields{1})/86400; % start time as decimal doy
jd_scs = startT:dt:startT+dt*(N-1);    % scs timestamp

%% identify indices for this day
stjd = ddd;
endjd = ddd+1;
ii = find(jd_scs>= stjd,1,'first');
jj = find(jd_scs< endjd,1,'last');
NN = jj-ii+1;

%% format output array
scs = NaN(17280,38);
scs(:,1) = stjd:dt:endjd-dt;
[~,mm] = min(abs(scs(:,1)-jd_scs(ii)));
[~,nn] = min(abs(scs(:,1)-jd_scs(jj)));
scs(mm:nn,2) = ncread(path_scs_data,'latitude',ii,NN);
scs(mm:nn,3) = ncread(path_scs_data,'longitude',ii,NN);
scs(mm:nn,4) = ncread(path_scs_data,'speedOG',ii,NN)*0.514444;
scs(mm:nn,5) = ncread(path_scs_data,'courseOG',ii,NN);
scs(mm:nn,6) = ncread(path_scs_data,'shipHeading',ii,NN);
scs(mm:nn,7) = ncread(path_scs_data,'portTrueWindSpeed',ii,NN)*0.514444;
scs(mm:nn,8) = ncread(path_scs_data,'portTrueWindDir',ii,NN);
scs(mm:nn,9) = ncread(path_scs_data,'portRelWindSpeed',ii,NN)*0.514444;
scs(mm:nn,10) = ncread(path_scs_data,'portRelWindDir',ii,NN);
scs(mm:nn,11) = ncread(path_scs_data,'stbdTrueWindSpeed',ii,NN)*0.514444;
scs(mm:nn,12) = ncread(path_scs_data,'stbdTrueWindDir',ii,NN);
scs(mm:nn,13) = ncread(path_scs_data,'stbdRelWindSpeed',ii,NN)*0.514444;
scs(mm:nn,14) = ncread(path_scs_data,'stbdRelWindDir',ii,NN);
scs(mm:nn,15) = ncread(path_scs_data,'ultraTrueWindSpeed',ii,NN)*0.514444;
scs(mm:nn,16) = ncread(path_scs_data,'ultraTrueWindDir',ii,NN);
scs(mm:nn,17) = ncread(path_scs_data,'ultraRelWindSpeed',ii,NN)*0.514444;
scs(mm:nn,18) = ncread(path_scs_data,'ultraRelWindDir',ii,NN);
scs(mm:nn,19) = ncread(path_scs_data,'portAirTemp',ii,NN);
scs(mm:nn,20) = ncread(path_scs_data,'stbdAirTemp',ii,NN);
scs(mm:nn,21) = ncread(path_scs_data,'portHumidity',ii,NN);
scs(mm:nn,22) = ncread(path_scs_data,'stbdHumidity',ii,NN);
scs(mm:nn,23) = ncread(path_scs_data,'atmPressure',ii,NN);

temp = ncread(path_scs_data,'rain',ii,NN);
temp2 = NaN(length(scs),1);
temp2(1:length(temp)) = temp;
zz = 1:3600/5:86400/5; % indices for top of each hour
temp2(zz) = 0;         % be sure rain resets to zero at top of hour
scs(:,24) = temp2;     % Raw rain

% compute cumulative rain over entire day...
temp3 = zeros(length(scs),1);
temp3(1:720) = temp2(1:720);  % first hour
for yy = 2:24         % subsequent hours
    temp3(zz(yy):zz(yy)+719) = temp2(zz(yy):zz(yy)+719) + temp3(zz(yy)-2);
end;
scs(:,38) = temp3;

% compute rain rate from daily cumulative
scs(mm:nn-1,25) = diff(scs(mm:nn,38))*3600/5;
scs(nn,25) = scs(nn-1,25);
zz = scs(:,25)<0; scs(zz,25) = 0;

scs(mm:nn,26) = NaN; % optical rain not in nc file after 3/17
scs(mm:nn,27) = NaN;
% scs(mm:nn,26) = ncread(path_scs_data,'opticalRain',ii,NN);
% scs(mm:nn-1,27) = diff(scs(mm:nn,26))*3600/5;
% scs(nn,27) = scs(nn-1,27);
% zz = scs(:,27)<0; scs(zz,27) = 0;

scs(mm:nn,28) = ncread(path_scs_data,'portPyranometer',ii,NN);
scs(mm:nn,29) = ncread(path_scs_data,'stbdPyranometer',ii,NN);
scs(mm:nn,30) = ncread(path_scs_data,'portRadiometer',ii,NN);
scs(mm:nn,31) = ncread(path_scs_data,'stbdRadiometer',ii,NN);
scs(mm:nn,32) = ncread(path_scs_data,'isarWaterTemp',ii,NN);
scs(mm:nn,33) = ncread(path_scs_data,'waterTemp',ii,NN);
scs(mm:nn,34) = ncread(path_scs_data,'salinity',ii,NN);
scs(mm:nn,35) = ncread(path_scs_data,'longitudinalWaterSpeed',ii,NN)*0.514444;
scs(mm:nn,36) = ncread(path_scs_data,'transverseWaterSpeed',ii,NN)*0.514444;
scs(mm:nn,37) = ncread(path_scs_data,'portKeelExtension',ii,NN)+6.1;

end
