Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
catchment-eco-hydro
Virtual_catchment_transient_ages
Commits
48e95f24
Commit
48e95f24
authored
Jan 24, 2020
by
Nicolas Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
age_metrics.m
age_metrics.m
+31
-0
No files found.
age_metrics.m
0 → 100644
View file @
48e95f24
%
% Copyright 2019-2020 LIST (Luxembourg Institute of Science and Technology), all right reserved.
%
% Author: Nicolas Rodriguez (nicolas.bjorn.rodriguez@gmail.com)
%
function
[
prct
,
frc
]
=
age_metrics
(
p
,
dT
,
T_group
,
age_prctiles
)
% calculates the percentiles of a given age distribution and the fractions of
% water younger than given age labels
% pre-allocation
prct
=
NaN
(
1
,
length
(
age_prctiles
)
+
1
);
frc
=
NaN
(
length
(
T_group
),
1
);
P
=
cumsum
(
p
*
dT
);
% cumulative age distr
frc
(
1
:
sum
(
T_group
<
length
(
P
)
*
dT
),
1
)
=
P
(
max
(
1
,
round
(
T_group
(
T_group
<
length
(
P
)
*
dT
)/
dT
)));
% fractions of water younger than T
x
=
dT
:
dT
:
dT
*
length
(
p
);
% ages in abscisse
for
k
=
1
:
length
(
age_prctiles
)
temp
=
find
(
P
<
age_prctiles
(
k
));
if
isempty
(
temp
)
prct
(
1
,
k
)
=
NaN
;
else
prct
(
1
,
k
)
=
temp
(
end
)
*
dT
;
% age percentiles in hours
end
end
prct
(
1
,
k
+
1
)
=
trapz
(
x
,
x
.*
p
);
% mean age in hours
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment