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
a98a09b9
Commit
a98a09b9
authored
Jan 24, 2020
by
Nicolas Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
9a6e972e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
weighted_age_metrics.m
weighted_age_metrics.m
+26
-0
No files found.
weighted_age_metrics.m
0 → 100644
View file @
a98a09b9
%
% Copyright 2019-2020 LIST (Luxembourg Institute of Science and Technology), all right reserved.
%
% Author: Nicolas Rodriguez (nicolas.bjorn.rodriguez@gmail.com)
%
function
[
FYW
,
MA
,
mA
]
=
weighted_age_metrics
(
MD
,
frc
,
dT
,
weights
)
% MD: master distribution
% MA: mean age
% mA: median age
temp
=
find
(
cumsum
(
MD
*
dT
)
<=
0.5
);
if
~
isempty
(
temp
)
mA
=
temp
(
end
)
*
dT
;
% hours
else
mA
=
NaN
;
end
temp
=
(
dT
:
dT
:
dT
*
length
(
MD
));
% vector of ages (hours)
MA
=
trapz
(
temp
,
temp
.*
MD
);
% hours
[
r
,
~
]
=
size
(
frc
);
FYW
=
NaN
(
r
,
1
);
for
k
=
1
:
r
FYW
(
k
,
1
)
=
sum
(
frc
(
k
,:)
.*
weights
'
)/
sum
(
weights
);
end
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