% program to load the data from the map file 
% Stef Boersen
% stef.boersen@rhdhv.com 
% 17-11-2017

%% load data 
if f_load==1
    info=ncinfo([data_dir,'t02_map.nc']);
    time=ncread([data_dir,'t02_map.nc'],'time');

    x_cor_sed_2D = ncread([data_dir,'t02_map.nc'],'mesh2d_edge_x'); % x-coordinates of sediment transport points
    y_cor_sed_2D = ncread([data_dir,'t02_map.nc'],'mesh2d_edge_y'); % y-coordinates of sediment transport points

    x_cor_sed_1D = ncread([data_dir,'t02_map.nc'],'mesh1d_edge_x'); % x-coordinates of sediment transport points
    y_cor_sed_1D = ncread([data_dir,'t02_map.nc'],'mesh1d_edge_y'); % y-coordinates of sediment transport points

    sus_1D=ncread([data_dir,'t02_map.nc'],'mesh1d_ssn'); % load suspended transport 1D
    sus_2D=ncread([data_dir,'t02_map.nc'],'mesh2d_ssn'); % load suspended transport 2D

    bedload_1D=ncread([data_dir,'t02_map.nc'],'mesh1d_sbn'); % load bedload transport 1D
    bedload_2D=ncread([data_dir,'t02_map.nc'],'mesh2d_sbn'); % load suspended transport 2D
    
    mesh1d_node_x = ncread([data_dir,'t02_map.nc'],'mesh1d_node_x');
    mesh1d_node_y = ncread([data_dir,'t02_map.nc'],'mesh1d_node_y'); 
    
    mesh2d_face_x = ncread([data_dir,'t02_map.nc'],'mesh2d_face_x');
    mesh2d_face_y = ncread([data_dir,'t02_map.nc'],'mesh2d_face_y');
    
    mesh1d_ucmag = ncread([data_dir,'t02_map.nc'],'mesh1d_ucmag'); 
    %velocity magnitude 1D-grid
    %location = 'node'
    %SIZE:  99x4
    mesh2d_ucmag = ncread([data_dir,'t02_map.nc'],'mesh2d_ucmag'); 
    %velocity magnitude 2D-grid
    %location = 'face' (ofwel de 2D-tegel, daarom:  'Flow element center velocity magnitude')
    %SIZE: 594x4
    
    mesh2d_waterdepth = ncread([data_dir,'t02_map.nc'],'mesh2d_waterdepth');
    mesh1d_waterdepth = ncread([data_dir,'t02_map.nc'],'mesh1d_waterdepth');
    
    %mesh2d_bottomdepth= ncread([data_dir,'t02_map.nc'],'mesh2d_mor_bl');
    %mesh1d_bottomdepth= ncread([data_dir,'t02_map.nc'],'mesh1d_mor_bl');
%% reduce index of data

% bedload_1D   = squeeze(bedload_1D);
% bedload_2D   = squeeze(bedload_2D);
% sus_1D       = squeeze(sus_1D);
% sus_2D       = squeeze(sus_2D);
% x_cor_sed_2D = squeeze(x_cor_sed_2D);
% y_cor_sed_2D = squeeze(y_cor_sed_2D);
% x_cor_sed_1D = squeeze(x_cor_sed_1D);
% y_cor_sed_1D = squeeze(y_cor_sed_1D);
end