function s = readMKL2018(path)
%

% MKL
OPT.ncpath1      = path; % local
OPT.Filename1    = 'Resultaten ligging BKL_TKL_MKL beoordeling in augustus 2018.xlsx';

% jarkus database for transect info
OPT.ncpath      = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/jarkus/profiles/';
OPT.Filename   = 'transect.nc';

% general settings
OPT.refdatenum   = datenum(1970,1,1);

%% Read data form jarkus transect.nc
id       = ncread([OPT.ncpath OPT.Filename],'id');
along    = ncread([OPT.ncpath OPT.Filename],'alongshore');
cross    = ncread([OPT.ncpath OPT.Filename],'cross_shore');
areaname = ncread([OPT.ncpath OPT.Filename],'areaname');
x        = ncread([OPT.ncpath OPT.Filename],'x');
y        = ncread([OPT.ncpath OPT.Filename],'y');

year_MKL    = 2018;
time = datenum(num2str(year_MKL),'yyyy') - OPT.refdatenum;

jarkusyear = str2num(datestr(OPT.refdatenum+ncread([OPT.ncpath OPT.Filename],'time'),'yyyy')); %#ok<ST2NM>

timenc = ncread([OPT.ncpath OPT.Filename],'time');

% now read the .xls file for 2018
disp('reading MKL 2018 ')
MKL2018  = xls2struct(fullfile(OPT.ncpath1, OPT.Filename1),'units',0);

% define vars in MKL2018.xls and remove the nans
xlsdatenum = datenum(MKL2018.Year);

% make header uniform to usual header and check nans
MKL2018.XMkl = MKL2018.XMkl__m___RSP_;
nnans_from_values = cellfun(@(x) ~strcmp(x,'-'),MKL2018.XMkl);

NotNans  = (~isnan(xlsdatenum) & nnans_from_values);
xlscode  = MKL2018.Kv(NotNans);
xlsraai  = MKL2018.Nr(NotNans);
xlsMaxSc = MKL2018.XMaxSea(NotNans);
xlsMinLc = MKL2018.XMinLand(NotNans);
xlsZup   = MKL2018.ZUpperBeachVolume(NotNans);
xlsZlo   = MKL2018.ZLowerBeachVolume(NotNans);
xlsxMKLc = MKL2018.XMkl(NotNans);
xlsVolc  = MKL2018.Volume(NotNans);
xlsID    = xlscode*1e6 + xlsraai;

% convert array of cells into array of doubles
xlsMaxS = cellfun(@(x) double(x),xlsMaxSc);
xlsMinL = cellfun(@(x) double(x),xlsMinLc);
xlsxMKL = cellfun(@(x) double(x),xlsxMKLc);
xlsVol  = cellfun(@(x) double(x),xlsVolc);

datenum_MKL = xlsdatenum(~isnan(xlsdatenum));
date_MKL    = datenum_MKL - OPT.refdatenum;

%% convert Xmkl in RD coordinates and in WGS84 and follow the alongshore def
% MKL2018 in RD coordinates
MKL2018_x    = NaN(length(id),length(jarkusyear)); MKL2018_y   = NaN(length(id),length(jarkusyear));
MKL2018MaxS  = NaN(length(id),length(jarkusyear)); MKL2018MinL = NaN(length(id),length(jarkusyear));
MKL2018date  = NaN(length(id),length(jarkusyear));
MKL2018_Zup  = NaN(length(id),length(jarkusyear)); MKL2018_Zlo = NaN(length(id),length(jarkusyear));
MKL2018_Xmkl = NaN(length(id),length(jarkusyear)); MKL2018_Vol = NaN(length(id),length(jarkusyear));

[ids, xlsids] = ismember(id, xlsID);
for i = 1:length(id)
    if ids(i)
        
        MKL2018_Xmkl(i,year_MKL == jarkusyear) = xlsxMKL(xlsids(i));
        MKL2018MaxS(i,year_MKL == jarkusyear)  = xlsMaxS(xlsids(i)); 
        MKL2018MinL(i,year_MKL == jarkusyear)  = xlsMinL(xlsids(i)); 
        MKL2018date(i,year_MKL == jarkusyear)  = date_MKL(xlsids(i));
        MKL2018_Zup(i,year_MKL == jarkusyear)  = xlsZup(xlsids(i)); 
        MKL2018_Zlo(i,year_MKL == jarkusyear)  = xlsZlo(xlsids(i));
        MKL2018_Vol(i,year_MKL == jarkusyear)  = xlsVol(xlsids(i));
        
        MKL2018_x(i,year_MKL == jarkusyear) = interp1(cross', x(:,i), xlsxMKL(xlsids(i)));
        MKL2018_y(i,year_MKL == jarkusyear) = interp1(cross', y(:,i), xlsxMKL(xlsids(i)));
    end
end
% MKL in WGS84 coordinates
[MKL2018_lon, MKL2018_lat] = convertCoordinates(MKL2018_x,MKL2018_y,'CS1.code',28992,'CS2.code',4326);

s.id = id;
s.areaname = areaname';
s.time     = timenc;

s.MKL_lat  = MKL2018_lat';
s.MKL_lon  = MKL2018_lon';
s.MKL_x    = MKL2018_x';
s.MKL_y    = MKL2018_y';

s.Xmkl     = MKL2018_Xmkl';
s.Volume   = MKL2018_Vol';

s.timeMKL  = MKL2018date';
s.hoog     = MKL2018_Zup';
s.laag     = MKL2018_Zlo';
s.XzeeMKL  = MKL2018MaxS';
s.XMinLand = MKL2018MinL';

