Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HYCAR-Hydro
airGR
Commits
d585f712
Commit
d585f712
authored
Jun 21, 2021
by
Dorchies David
Browse files
refactor: move fatal error of multi|compo for RMSE to ErrorCrit_RMSE
parent
dd7ef429
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/ErrorCrit_RMSE.R
View file @
d585f712
ErrorCrit_RMSE
<-
function
(
InputsCrit
,
OutputsModel
,
warnings
=
TRUE
,
verbose
=
TRUE
)
{
## Arguments check
if
(
!
inherits
(
OutputsModel
,
"OutputsModel"
))
{
stop
(
"'OutputsModel' must be of class 'OutputsModel'"
)
}
if
(
!
inherits
(
InputsCrit
,
"Single"
))
{
stop
(
"'ErrorCrit_RMSE' can only be used with 'InputsCrit' of class 'Single'"
)
}
EC
<-
.ErrorCrit
(
InputsCrit
=
InputsCrit
,
Crit
=
"RMSE"
,
OutputsModel
=
OutputsModel
,
warnings
=
warnings
)
CritValue
<-
NA
if
(
EC
$
CritCompute
)
{
## ErrorCrit
Numer
<-
sum
((
EC
$
VarSim
-
EC
$
VarObs
)
^
2
,
na.rm
=
TRUE
)
Denom
<-
sum
(
!
is.na
(
EC
$
VarObs
))
if
(
Numer
==
0
)
{
Crit
<-
0
}
else
{
...
...
@@ -22,22 +25,22 @@ ErrorCrit_RMSE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose =
if
(
is.numeric
(
Crit
)
&
is.finite
(
Crit
))
{
CritValue
<-
Crit
}
## Verbose
if
(
verbose
)
{
message
(
sprintf
(
"Crit. %s = %.4f"
,
EC
$
CritName
,
CritValue
))
}
}
## Output
OutputsCrit
<-
list
(
CritValue
=
CritValue
,
CritName
=
EC
$
CritName
,
CritBestValue
=
EC
$
CritBestValue
,
Multiplier
=
EC
$
Multiplier
,
Ind_notcomputed
=
EC
$
Ind_TS_ignore
)
class
(
OutputsCrit
)
<-
c
(
"RMSE"
,
"ErrorCrit"
)
return
(
OutputsCrit
)
}
R/UtilsErrorCrit.R
View file @
d585f712
...
...
@@ -9,11 +9,7 @@
stop
(
"'InputsCrit' must be of class 'InputsCrit'"
,
call.
=
FALSE
)
}
if
(
inherits
(
InputsCrit
,
"Multi"
)
|
inherits
(
InputsCrit
,
"Compo"
))
{
if
(
Crit
==
"RMSE"
)
{
stop
(
"'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' with RMSE"
,
call.
=
FALSE
)
}
else
{
stop
(
paste0
(
"'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with "
,
Crit
),
call.
=
FALSE
)
}
stop
(
paste0
(
"'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with "
,
Crit
),
call.
=
FALSE
)
}
...
...
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