%% program to change the bottom files, make it a straight channel 
% Stef Boersen
% stef.boersen@rhdhv.com 
% 17-11-2017

%% load old bottom files 

fileID=fopen('../bathymetry.xyb','r');
formatSpec = '%16f%16f%f%[^\n\r]';
dataArray = textscan(fileID, formatSpec, 'Delimiter', '', 'WhiteSpace', '',   'ReturnOnError', false);
fclose(fileID);
data = table(dataArray{1:end-1}, 'VariableNames', {'Xcor','Ycor','Zval'}); % hier gooi je de laatste kolom weg 

%% rewrite data

x_cor=data.Xcor;
y_cor=data.Ycor;
z_val=data.Zval;

depth=round((z_val(1)+z_val(end))/2,1);
z_val=z_val./z_val; % ones van maken 

z_val=depth

%% write depth file
stor_mat=zeros(length(x_cor),3);
stor_mat(:,1)=x_cor; % x coordinaten wegschrijven
stor_mat(:,2)=y_cor; % y coordinaten wegschrijven
stor_mat(:,3)=z_val; % diepte

%%

file_id = fopen('../bat_straight_channel.xyb','w');
fprintf(file_id,'%16.7f%16.7f%16.7f\n',stor_mat');
fclose(file_id);

plot(stor_mat(:,1),stor_mat(:,3))

