Skip to content

Commit 2de0f73

Browse files
Add split meta metric macro
1 parent 963a978 commit 2de0f73

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/metrics.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,33 @@ macro mean_inverse(metric, obs, sim)
8080
end
8181

8282

83+
"""
84+
Applies split meta metric approach
85+
86+
If using with other macros such as `@normalize` or `@bound`,
87+
these must come first.
88+
89+
# References
90+
1. Fowler, K., Peel, M., Western, A., Zhang, L., 2018.
91+
Improved Rainfall-Runoff Calibration for Drying Climate:
92+
Choice of Objective Function.
93+
Water Resources Research 54, 3392–3408.
94+
https://doi.org/10.1029/2017WR022466
95+
96+
# Example
97+
```julia
98+
julia> using Statistics
99+
julia> import Streamfall: @normalize, @split, KGE
100+
julia> @normalize @split KGE repeat([1,2], 365) repeat([3,2], 365) 365 mean
101+
0.3217309561946589
102+
```
103+
"""
104+
macro split(metric, obs, sim, n, agg_func=mean)
105+
obj, o, s, t, func = eval(metric), eval(obs), eval(sim), eval(n), eval(agg_func)
106+
return naive_split_metric(o, s; n_members=t, metric=obj, comb_method=func)
107+
end
108+
109+
83110
"""The Nash-Sutcliffe Efficiency score"""
84111
NSE(obs, sim) = 1.0 - sum((obs .- sim).^2) / sum((obs .- mean(obs)).^2)
85112

0 commit comments

Comments
 (0)