##################
# Example 1: Looking at the difference between 'KGE', 'NSE', 'wNSE', 'wsNSE',
# 'APFB' and 'KGElf' for detecting differences in high flows
# Loading daily streamflows of the Ega River (Spain), from 1961 to 1970
data(EgaEnEstellaQts)
obs <- EgaEnEstellaQts
# Simulated daily time series, created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values.
sim <- obs
hQ.thr <- quantile(obs, probs=0.9, na.rm=TRUE)
hQ.index <- which(obs >= hQ.thr)
hQ.n <- length(hQ.index)
sim[hQ.index] <- sim[hQ.index] + rnorm(hQ.n, mean=mean(sim[hQ.index], na.rm=TRUE))
# Traditional Kling-Gupta eficiency (Gupta and Kling, 2009)
KGE(sim=sim, obs=obs)
# Traditional Nash-Sutcliffe eficiency (Nash and Sutcliffe, 1970)
NSE(sim=sim, obs=obs)
# Weighted Nash-Sutcliffe efficiency (Hundecha and Bardossy, 2004)
wNSE(sim=sim, obs=obs)
# wsNSE (Zambrano-Bigiarini and Bellin, 2012):
wsNSE(sim=sim, obs=obs)
# APFB (Mizukami et al., 2019):
APFB(sim=sim, obs=obs)
##################
# Example 2: Looking at the difference between 'KGE', 'NSE', 'wsNSE',
# 'dr', 'rd', 'md', 'APFB' and 'KGElf' for detecting differences in low flows
# Loading daily streamflows of the Ega River (Spain), from 1961 to 1970
data(EgaEnEstellaQts)
obs <- EgaEnEstellaQts
# Simulated daily time series, created equal to the observed values and then
# random noise is added only to low flows, i.e., those equal or lower than
# the quantile 0.4 of the observed values.
sim <- obs
lQ.thr <- quantile(obs, probs=0.4, na.rm=TRUE)
lQ.index <- which(obs <= lQ.thr)
lQ.n <- length(lQ.index)
sim[lQ.index] <- sim[lQ.index] + rnorm(lQ.n, mean=mean(sim[lQ.index], na.rm=TRUE))
# Traditional Kling-Gupta eficiency (Gupta and Kling, 2009)
KGE(sim=sim, obs=obs)
# Traditional Nash-Sutcliffe eficiency (Nash and Sutcliffe, 1970)
NSE(sim=sim, obs=obs)
# Weighted seasonal Nash-Sutcliffe efficiency (Zambrano-Bigiarini and Bellin, 2012):
wsNSE(sim=sim, obs=obs, lambda=0.05, j=1/2)
# Refined Index of Agreement (Willmott et al., 2012):
dr(sim=sim, obs=obs)
# Relative Index of Agreement (Krause et al., 2005):
rd(sim=sim, obs=obs)
# Modified Index of Agreement (Krause et al., 2005):
md(sim=sim, obs=obs)
# KGElf (Garcia et al., 2017):
KGElf(sim=sim, obs=obs)
##################
# Example 3:
# Loading daily streamflows of the Ega River (Spain), from 1961 to 1970
data(EgaEnEstellaQts)
obs <- EgaEnEstellaQts
# Generating a simulated daily time series, initially equal to the observed series
sim <- obs
# Computing the 'wsNSE' for the "best" (unattainable) case
wsNSE(sim=sim, obs=obs)
##################
# Example 4: wsNSE for simulated values created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values and applying (natural)
# logarithm to 'sim' and 'obs' during computations.
wsNSE(sim=sim, obs=obs, fun=log)
# Verifying the previous value:
lsim <- log(sim)
lobs <- log(obs)
wsNSE(sim=lsim, obs=lobs)
##################
# Example 5: wsNSE for simulated values created equal to the observed values and then
# random noise is added only to high flows, i.e., those equal or higher than
# the quantile 0.9 of the observed values and applying a
# user-defined function to 'sim' and 'obs' during computations
fun1 <- function(x) {sqrt(x+1)}
wsNSE(sim=sim, obs=obs, fun=fun1)
# Verifying the previous value, with the epsilon value following Pushpalatha2012
sim1 <- sqrt(sim+1)
obs1 <- sqrt(obs+1)
wsNSE(sim=sim1, obs=obs1)
Run the code above in your browser using DataLab