Skip to content
Snippets Groups Projects
Commit 3ac97419 authored by Dr. rer. nat. Jürgen Mey's avatar Dr. rer. nat. Jürgen Mey :eye:
Browse files

added eroschange.m and erostimeseries.m that help to analyse the model output

parent b665b59c
No related branches found
No related tags found
No related merge requests found
function D = eroschange(variable,first,last)
narginchk(1,inf);
nargoutchk(0,1);
if nargin == 1
first = 2;
end
switch variable
case 'topo'
filetype = 'alt';
iylabel = 'Elevation (m)';
case 'sediment'
filetype = 'sed';
iylabel = 'Sediment thickness (m)';
case 'water'
filetype = 'water';
iylabel = 'Water depth (m)';
case 'capacity'
filetype = 'capacity';
iylabel = 'Capacity';
case 'discharge'
filetype = 'discharge';
iylabel = 'Water discharge (m^3/s)';
case 'flux'
filetype = 'flux';
iylabel = 'Water discharge (m^3/s)';
case 'downward'
filetype = 'downward';
iylabel = 'Mean settling velocity (m/s)';
case 'hum'
filetype = 'hum';
iylabel = 'Water discharge on topography (m^3/s)';
case 'qs'
filetype = 'qs';
iylabel = 'Sediment flux (m^3/s)';
case 'slope'
filetype = 'slope';
iylabel = 'Slope';
case 'stock'
filetype = 'stock';
iylabel = 'Sediment stock (m^3)';
case 'stress'
filetype = 'stress';
iylabel = 'Shear stress (Pa)';
end
T = dir('*.ini');
Z = dir(['*.',filetype]);
[t,~] = fread_timeVec(T.name,length(Z));
if isempty(t)
t=1:length(Z);
end
if isnan(t)
t=1:length(Z);
end
[~,index] = sortrows({Z.date}.');
Z = Z(index);
if nargin == 1
[z1,~] = fopengrd(Z(first).name);
[z2,~] = fopengrd(Z(end).name);
elseif nargin == 2
[z1,~] = fopengrd(Z(first).name);
[z2,~] = fopengrd(Z(end).name);
else
[z1,~] = fopengrd(Z(first).name);
[z2,~] = fopengrd(Z(last).name);
end
fig = figure;imagesc(z2-z1),colorbar
D = z2-z1;
title(['Change in ',iylabel]);
function Q = erostimeseries(variable)
p = inputParser;
expectedInput_variable = {'topo','water','sediment','flux','qs',...
'discharge','downward','stress','hum','slope','capacity','stock'};
addRequired(p,'variable',@(x) any(validatestring(x,expectedInput_variable)));
parse(p,variable);
switch variable
case 'topo'
filetype = 'alt';
iylabel = 'Elevation (m)';
case 'sediment'
filetype = 'sed';
iylabel = 'Mean sediment thickness along path (m)';
case 'water'
filetype = 'water';
iylabel = 'Water depth (m)';
case 'capacity'
filetype = 'capacity';
iylabel = 'Capacity';
case 'discharge'
filetype = 'discharge';
iylabel = 'Water discharge (m^3/s)';
case 'flux'
filetype = 'flux';
iylabel = 'Water discharge (m^3/s)';
case 'downward'
filetype = 'downward';
iylabel = 'Mean settling velocity (m/s)';
case 'hum'
filetype = 'hum';
iylabel = 'Water discharge on topography (m^3/s)';
case 'qs'
filetype = 'qs';
iylabel = 'Sediment flux (m^3/s)';
case 'slope'
filetype = 'slope';
iylabel = 'Slope';
case 'stock'
filetype = 'stock';
iylabel = 'Sediment stock (m^3)';
case 'stress'
filetype = 'stress';
iylabel = 'Shear stress (Pa)';
end
T = dir('*.ini');
Z = dir(['*.',filetype]);
F = dir('*.flux');
[t,~] = fread_timeVec(T.name,length(Z));
if isempty(t)
t=1:length(Z);
end
if isnan(t)
t=1:length(Z);
end
[~,index] = sortrows({Z.date}.');
Z = Z(index);
F = F(index);
[z,~] = fopengrd(F(2).name);
fig = figure;imagesc(z)
[x,y,~]=improfile;
close(fig)
for i = 1:length(Z)
[z,~] = fopengrd(Z(i).name);
z(z==0)=NaN;
c = improfile(z,x,y);
if strcmp(filetype,'sed')==1
Q(i) = nanmean(c);
else
Q(i) = nansum(c);
end
end
t(1)=[];
Q(1)=[];
figure;plot(t,Q)
ylabel(iylabel);
xlabel('Time');
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment